Files
clang-p2996/llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test
Georgii Rymar 07d448135f [llvm-readobj][test] - Stop using binaries in gnu-phdrs.test, split and refine it.
gnu-phdrs.test uses 2 precompiled objects and has issues:

* It does not test all possible program headers.
* It does not test target-specific headers (arm, mips).
* It does not use --strict-whitespace --match-full-line to check the format of the output.
* It is possible to check things better/nicer.
* It also tests --section-mapping.

This patch makes gnu-phdrs.test to stop using binaries and addresses issues above.
It splits --section-mapping testing to gnu-section-mapping.test

I am going to use it as a base for a follow-up patch that should also test
section to segment mapping conditions that we currently have
(see the discussion in D78709)

Differential revision: https://reviews.llvm.org/D78805
2020-05-01 18:31:24 +03:00

77 lines
2.4 KiB
Plaintext

## Check how llvm-readelf prints sections to segments mapping.
## Check that --section-mapping produces a sections to segments
## mapping and not anything else.
# RUN: yaml2obj %s -o %t64.elf
# RUN: llvm-readelf --section-mapping %t64.elf \
# RUN: | FileCheck %s --check-prefix=MAPPING --strict-whitespace --match-full-lines --implicit-check-not={{.}}
# MAPPING: Section to Segment mapping:
# MAPPING-NEXT: Segment Sections...
# MAPPING-NEXT: 00 .foo.begin .foo.end {{$}}
# MAPPING-NEXT: 01 .bar.begin .bar.end {{$}}
# MAPPING-NEXT: None .strtab .shstrtab {{$}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Entry: 0x12345678
Sections:
- Name: .foo.begin
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1000
Size: 0x1
- Name: .foo.end
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Size: 0x2
- Name: .bar.begin
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x2000
Size: 0x3
- Name: .bar.end
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Size: 0x4
ProgramHeaders:
## Case 1: an arbitrary segment with sections.
- Type: PT_PHDR
Flags: [ PF_W ]
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
## Case 2: another segment with different sections.
- Type: PT_PHDR
Flags: [ PF_X ]
VAddr: 0x2000
Sections:
- Section: .bar.begin
- Section: .bar.end
## Check that --section-mapping=false --program-headers produces just program headers.
# RUN: llvm-readelf --section-mapping=false --program-headers %t64.elf \
# RUN: | FileCheck %s --check-prefix=SEC-MAPPING-FALSE --implicit-check-not="Section to Segment mapping:"
# SEC-MAPPING-FALSE: Program Headers:
## Check that only one copy of the section/segment mapping table is produced
## when both --section-mapping and --program-headers are used.
# RUN: llvm-readelf --section-mapping --program-headers %t64.elf \
# RUN: | FileCheck %s --check-prefix=MAPPING --implicit-check-not="Section to Segment mapping:"
## Check the output when an object has no section headers.
## RUN: llvm-objcopy --strip-sections %t64.elf %tno-shdrs.o
## RUN: llvm-readelf --section-mapping %tno-shdrs.o | FileCheck %s --check-prefix=NO-SECHDRS
# NO-SECHDRS: Section to Segment mapping:
# NO-SECHDRS-NEXT: Segment Sections...
# NO-SECHDRS-NEXT: 00 {{$}}
# NO-SECHDRS-NEXT: 01 {{$}}
# NO-SECHDRS-NOT: {{.}}