116 lines · plain
1## Test reading ELF with .dynsym under the following conditions:2## * Section headers are available.3## * Section headers are stripped but there is a DT_GNU_HASH dynamic tag.4## * Section headers are stripped but there is a DT_HASH dynamic tag.5 6## Test if llvm-ifs reads DT_SYMTAB size through section headers by puting the wrong terminator in DT_GNU_HASH.7# RUN: yaml2obj %s -o %tfull -DGNUHASHVALUE="[0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00"8# RUN: llvm-ifs --input-format=ELF --output-ifs=- %tfull | FileCheck %s9 10## Test if llvm-ifs fails to read DT_SYMTAB size through section headers when the value of sh_entsize is invalid.11# RUN: yaml2obj %s -o %tfull -DGNUHASHVALUE="[0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DENTSIZE="0x19"12# RUN: not llvm-ifs --input-format=ELF --output-ifs=- %tfull 2>&1 | FileCheck %s --check-prefix=BADENTSIZE13 14## Test if llvm-ifs reads DT_SYMTAB size through DT_GNU_HASH.15# RUN: yaml2obj %s -o %tw.gnu.hash -DGNUHASHVALUE="[0x8, 0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DNOHEADER="true"16# RUN: llvm-ifs --input-format=ELF --output-ifs=- %tw.gnu.hash | FileCheck %s17 18## Test if llvm-ifs fails to read DT_SYMTAB size through DT_GNU_HASH when there is no terminator.19# RUN: yaml2obj %s -o %tw.gnu.hash -DGNUHASHVALUE="[0x8, 0xA]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DNOHEADER="true"20# RUN: not llvm-ifs --input-format=ELF --output-ifs=- %tw.gnu.hash 2>&1 | FileCheck %s --check-prefix=NOTERMINATOR21 22# CHECK: --- !ifs-v123# CHECK-NEXT: IfsVersion: 3.024# CHECK-NEXT: Target: { ObjectFormat: ELF, Arch: AArch64, Endianness: little, BitWidth: 64 }25# CHECK-NEXT: Symbols:26# CHECK-NEXT: - { Name: bar, Type: Object, Size: 0, Undefined: true }27# CHECK-NEXT: - { Name: foo, Type: Func, Undefined: true }28# CHECK-NEXT: ...29 30# BADENTSIZE: SHT_DYNSYM section has sh_size (72) % sh_entsize (25) that is not 031 32# NOTERMINATOR: error: no terminator found for GNU hash section before buffer end33 34--- !ELF35FileHeader:36 Class: ELFCLASS6437 Data: ELFDATA2LSB38 Type: ET_DYN39 Machine: EM_AARCH6440Sections:41 - Name: .text42 Type: SHT_PROGBITS43 - Name: .data44 Type: SHT_PROGBITS45 - Name: .strtab46 Type: SHT_STRTAB47 - Name: .shstrtab48 Type: SHT_STRTAB49 - Name: .dynsym50 Type: SHT_DYNSYM51 Flags: [ SHF_ALLOC ]52 EntSize: [[ENTSIZE=0x18]]53 Address: 0x40054 AddressAlign: 0x40055 - Name: .dynstr56 Type: SHT_STRTAB57 Flags: [ SHF_ALLOC ]58 Address: 0x60059 AddressAlign: 0x20060 - Name: .dynamic61 Type: SHT_DYNAMIC62 Flags: [ SHF_ALLOC ]63 Address: 0x80064 AddressAlign: 0x20065 Entries:66 - Tag: DT_STRTAB67 Value: 0x60068 - Tag: DT_STRSZ69 Value: 970 - Tag: DT_SYMTAB71 Value: 0x40072 - Tag: [[TAG1]]73 Value: [[VAL1]]74 - Tag: DT_NULL75 Value: 076 - Name: .hash77 Type: SHT_HASH78 Flags: [ SHF_ALLOC ]79 Address: 0xA0080 AddressAlign: 0x20081 Bucket: [ 1 ]82 Chain: [ 1, 2, 3 ]83 - Name: .gnu.hash84 Type: SHT_GNU_HASH85 Flags: [ SHF_ALLOC ]86 Address: 0xC0087 AddressAlign: 0x20088 Header:89 SymNdx: 0x190 Shift2: 0x291 MaskWords: 292 NBuckets: 293 BloomFilter: [0x3, 0x4]94 HashBuckets: [0x0, 0x1]95 HashValues: [[GNUHASHVALUE]]96 - Type: SectionHeaderTable97 NoHeaders: [[NOHEADER=false]]98DynamicSymbols:99 - Name: foo100 Type: STT_FUNC101 Value: 0x100102 Binding: 1103 - Name: bar104 Type: STT_OBJECT105 Value: 0x200106 Binding: 1107ProgramHeaders:108 - Type: PT_LOAD109 VAddr: 0x400110 FirstSec: .dynsym111 LastSec: .gnu.hash112 - Type: PT_DYNAMIC113 VAddr: 0x800114 FirstSec: .dynamic115 LastSec: .dynamic116