llvm-project/llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test
Georgii Rymar a6436b0b3a [yaml2obj] - Make the 'Machine' key optional.
Currently we have to set 'Machine' to something in our
YAML descriptions. Usually we use 'EM_X86_64' for 64-bit targets
and 'EM_386' for 32-bit targets. At the same time, in fact, in most
cases our tests do not need a machine type and we can use
'EM_NONE'.

This is cleaner, because avoids the need of using a particular machine.

In this patch I've made the 'Machine' key optional (the default value,
when it is not specified is `EM_NONE`) and removed it (where possible)
from yaml2obj, obj2yaml and llvm-readobj tests.

There are few tests left where I decided not to remove it, because
I didn't want to touch CHECK lines or doing anything more complex
than a removing a "Machine: *" line and formatting lines around.

Differential revision: https://reviews.llvm.org/D86202
2020-08-20 11:40:51 +03:00

85 lines
2.9 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
EPhEntSize: [[PHENTSIZE=<none>]]
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: {{.}}
## Check we report a warning when we are unable to read program headers.
# RUN: yaml2obj %s -DPHENTSIZE=1 -o %t64-err1.elf
# RUN: llvm-readelf --section-mapping %t64-err1.elf 2>&1 | \
# RUN: FileCheck %s -DFILE=%t64-err1.elf --check-prefix=PHENTSIZE
# PHENTSIZE: Section to Segment mapping:
# PHENTSIZE-NEXT: Segment Sections...
# PHENTSIZE-NEXT: warning: '[[FILE]]': can't read program headers to build section to segment mapping: invalid e_phentsize: 1