1## Check how llvm-readelf prints sections to segments mapping. 2 3## Check that --section-mapping produces a sections to segments 4## mapping and not anything else. 5# RUN: yaml2obj %s -o %t64.elf 6# RUN: llvm-readelf --section-mapping %t64.elf \ 7# RUN: | FileCheck %s --check-prefix=MAPPING --strict-whitespace --match-full-lines --implicit-check-not={{.}} 8 9# MAPPING: Section to Segment mapping: 10# MAPPING-NEXT: Segment Sections... 11# MAPPING-NEXT: 00 .foo.begin .foo.end {{$}} 12# MAPPING-NEXT: 01 .bar.begin .bar.end {{$}} 13# MAPPING-NEXT: None .strtab .shstrtab {{$}} 14 15--- !ELF 16FileHeader: 17 Class: ELFCLASS64 18 Data: ELFDATA2LSB 19 Type: ET_EXEC 20 EPhEntSize: [[PHENTSIZE=<none>]] 21Sections: 22 - Name: .foo.begin 23 Type: SHT_PROGBITS 24 Flags: [ SHF_ALLOC ] 25 Address: 0x1000 26 Size: 0x1 27 - Name: .foo.end 28 Type: SHT_PROGBITS 29 Flags: [ SHF_ALLOC ] 30 Size: 0x2 31 - Name: .bar.begin 32 Type: SHT_PROGBITS 33 Flags: [ SHF_ALLOC ] 34 Address: 0x2000 35 Size: 0x3 36 - Name: .bar.end 37 Type: SHT_PROGBITS 38 Flags: [ SHF_ALLOC ] 39 Size: 0x4 40ProgramHeaders: 41## Case 1: an arbitrary segment with sections. 42 - Type: PT_PHDR 43 Flags: [ PF_W ] 44 VAddr: 0x1000 45 FirstSec: .foo.begin 46 LastSec: .foo.end 47## Case 2: another segment with different sections. 48 - Type: PT_PHDR 49 Flags: [ PF_X ] 50 VAddr: 0x2000 51 FirstSec: .bar.begin 52 LastSec: .bar.end 53 54## Check that --section-mapping=false --program-headers produces just program headers. 55# RUN: llvm-readelf --section-mapping=false --program-headers %t64.elf \ 56# RUN: | FileCheck %s --check-prefix=SEC-MAPPING-FALSE --implicit-check-not="Section to Segment mapping:" 57 58# SEC-MAPPING-FALSE: Program Headers: 59 60## Check that only one copy of the section/segment mapping table is produced 61## when both --section-mapping and --program-headers are used. 62# RUN: llvm-readelf --section-mapping --program-headers %t64.elf \ 63# RUN: | FileCheck %s --check-prefix=MAPPING --implicit-check-not="Section to Segment mapping:" 64 65## Check the output when an object has no section headers. 66## RUN: llvm-objcopy --strip-sections %t64.elf %tno-shdrs.o 67## RUN: llvm-readelf --section-mapping %tno-shdrs.o | FileCheck %s --check-prefix=NO-SECHDRS 68 69# NO-SECHDRS: Section to Segment mapping: 70# NO-SECHDRS-NEXT: Segment Sections... 71# NO-SECHDRS-NEXT: 00 {{$}} 72# NO-SECHDRS-NEXT: 01 {{$}} 73# NO-SECHDRS-NOT: {{.}} 74 75## Check we report a warning when we are unable to read program headers. 76# RUN: yaml2obj %s -DPHENTSIZE=1 -o %t64-err1.elf 77# RUN: llvm-readelf --section-mapping %t64-err1.elf 2>&1 | \ 78# RUN: FileCheck %s -DFILE=%t64-err1.elf --check-prefix=PHENTSIZE 79 80# PHENTSIZE: Section to Segment mapping: 81# PHENTSIZE-NEXT: Segment Sections... 82# PHENTSIZE-NEXT: warning: '[[FILE]]': can't read program headers to build section to segment mapping: invalid e_phentsize: 1 83