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 Sections: 46 - Section: .foo.begin 47 - Section: .foo.end 48## Case 2: another segment with different sections. 49 - Type: PT_PHDR 50 Flags: [ PF_X ] 51 VAddr: 0x2000 52 Sections: 53 - Section: .bar.begin 54 - Section: .bar.end 55 56## Check that --section-mapping=false --program-headers produces just program headers. 57# RUN: llvm-readelf --section-mapping=false --program-headers %t64.elf \ 58# RUN: | FileCheck %s --check-prefix=SEC-MAPPING-FALSE --implicit-check-not="Section to Segment mapping:" 59 60# SEC-MAPPING-FALSE: Program Headers: 61 62## Check that only one copy of the section/segment mapping table is produced 63## when both --section-mapping and --program-headers are used. 64# RUN: llvm-readelf --section-mapping --program-headers %t64.elf \ 65# RUN: | FileCheck %s --check-prefix=MAPPING --implicit-check-not="Section to Segment mapping:" 66 67## Check the output when an object has no section headers. 68## RUN: llvm-objcopy --strip-sections %t64.elf %tno-shdrs.o 69## RUN: llvm-readelf --section-mapping %tno-shdrs.o | FileCheck %s --check-prefix=NO-SECHDRS 70 71# NO-SECHDRS: Section to Segment mapping: 72# NO-SECHDRS-NEXT: Segment Sections... 73# NO-SECHDRS-NEXT: 00 {{$}} 74# NO-SECHDRS-NEXT: 01 {{$}} 75# NO-SECHDRS-NOT: {{.}} 76 77## Check we report a warning when we are unable to read program headers. 78# RUN: yaml2obj %s -DPHENTSIZE=1 -o %t64-err1.elf 79# RUN: llvm-readelf --section-mapping %t64-err1.elf 2>&1 | \ 80# RUN: FileCheck %s -DFILE=%t64-err1.elf --check-prefix=PHENTSIZE 81 82# PHENTSIZE: Section to Segment mapping: 83# PHENTSIZE-NEXT: Segment Sections... 84# PHENTSIZE-NEXT: warning: '[[FILE]]': can't read program headers to build section to segment mapping: invalid e_phentsize: 1 85