83 lines · plain
1## Check how llvm-readelf prints sections to segments mapping.2 3## Check that --section-mapping produces a sections to segments4## mapping and not anything else.5# RUN: yaml2obj %s -o %t64.elf6# 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--- !ELF16FileHeader:17 Class: ELFCLASS6418 Data: ELFDATA2LSB19 Type: ET_EXEC20 EPhEntSize: [[PHENTSIZE=<none>]]21Sections:22 - Name: .foo.begin23 Type: SHT_PROGBITS24 Flags: [ SHF_ALLOC ]25 Address: 0x100026 Size: 0x127 - Name: .foo.end28 Type: SHT_PROGBITS29 Flags: [ SHF_ALLOC ]30 Size: 0x231 - Name: .bar.begin32 Type: SHT_PROGBITS33 Flags: [ SHF_ALLOC ]34 Address: 0x200035 Size: 0x336 - Name: .bar.end37 Type: SHT_PROGBITS38 Flags: [ SHF_ALLOC ]39 Size: 0x440ProgramHeaders:41## Case 1: an arbitrary segment with sections.42 - Type: PT_PHDR43 Flags: [ PF_W ]44 VAddr: 0x100045 FirstSec: .foo.begin46 LastSec: .foo.end47## Case 2: another segment with different sections.48 - Type: PT_PHDR49 Flags: [ PF_X ]50 VAddr: 0x200051 FirstSec: .bar.begin52 LastSec: .bar.end53 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 produced61## 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.o67## RUN: llvm-readelf --section-mapping %tno-shdrs.o | FileCheck %s --check-prefix=NO-SECHDRS68 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.elf77# RUN: llvm-readelf --section-mapping %t64-err1.elf 2>&1 | \78# RUN: FileCheck %s -DFILE=%t64-err1.elf --check-prefix=PHENTSIZE79 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: 183