brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 00861c0 Raw
147 lines · yaml
1## Check how obj2yaml produces SHT_GNU_HASH section descriptions.2 3## Check that obj2yaml uses "Header", "BloomFilter", "HashBuckets" and "HashValues"4## tags to describe a SHT_GNU_HASH section when it has content of a correct size.5 6# RUN: yaml2obj --docnum=1 %s -o %t17# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=FIELDS8 9# FIELDS:      - Name:   .gnu.hash10# FIELDS-NEXT:     Type:   SHT_GNU_HASH11# FIELDS-NEXT:     Flags:  [ SHF_ALLOC ]12# FIELDS-NEXT:     Header:13# FIELDS-NEXT:       SymNdx: 0x114# FIELDS-NEXT:       Shift2: 0x215# FIELDS-NEXT:     BloomFilter: [ 0x3, 0x4 ]16# FIELDS-NEXT:     HashBuckets: [ 0x5, 0x6, 0x7 ]17# FIELDS-NEXT:     HashValues:  [ 0x8, 0x9, 0xA, 0xB ]18 19--- !ELF20FileHeader:21  Class: ELFCLASS3222  Data:  ELFDATA2LSB23  Type:  ET_DYN24Sections:25  - Name:  .gnu.hash26    Type:  SHT_GNU_HASH27    Flags: [ SHF_ALLOC ]28    Header:29      SymNdx: 0x130      Shift2: 0x231    BloomFilter: [0x3, 0x4]32    HashBuckets: [0x5, 0x6, 0x7]33    HashValues:  [0x8, 0x9, 0xA, 0xB]34 35## Check how we handle broken cases.36 37# RUN: yaml2obj --docnum=2 %s -o %t238# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID39 40# INVALID:      - Name:        .gnu.hash.tooshort41# INVALID-NEXT:   Type:        SHT_GNU_HASH42# INVALID-NEXT:   Flags:       [ SHF_ALLOC ]43# INVALID-NEXT:   Content:     112233445566778899AABBCCDDEEFF44# INVALID-NEXT: - Name:        .gnu.hash.empty45# INVALID-NEXT:   Type:        SHT_GNU_HASH46# INVALID-NEXT:   Flags:       [ SHF_ALLOC ]47# INVALID-NEXT:   Address:     0xF48# INVALID-NEXT:   Header:49# INVALID-NEXT:     SymNdx:      0x050# INVALID-NEXT:     Shift2:      0x051# INVALID-NEXT:   BloomFilter: [ ]52# INVALID-NEXT:   HashBuckets: [ ]53# INVALID-NEXT:   HashValues:  [ ]54# INVALID-NEXT: - Name:        .gnu.hash.broken.maskwords55# INVALID-NEXT:   Type:        SHT_GNU_HASH56# INVALID-NEXT:   Content:     '00000000000000000100000000000000'57# INVALID-NEXT: - Name:        .gnu.hash.broken.nbuckets.a58# INVALID-NEXT:   Type:        SHT_GNU_HASH59# INVALID-NEXT:   Content:     '01000000000000000000000000000000'60# INVALID-NEXT: - Name:        .gnu.hash.broken.nbuckets.b61# INVALID-NEXT:   Type:        SHT_GNU_HASH62# INVALID-NEXT:   Content:     FFFFFFFF000000000100000000000000{{$}}63# INVALID-NEXT: - Name:        .gnu.hash.hashvalues.ok64# INVALID-NEXT:   Type:        SHT_GNU_HASH65# INVALID-NEXT:   Header:66# INVALID-NEXT:     SymNdx:      0x067# INVALID-NEXT:     Shift2:      0x068# INVALID-NEXT:   BloomFilter: [ ]69# INVALID-NEXT:   HashBuckets: [ ]70# INVALID-NEXT:   HashValues:  [ 0x0 ]71# INVALID-NEXT: - Name:        .gnu.hash.hashvalues.fail72# INVALID-NEXT:   Type:        SHT_GNU_HASH73# INVALID-NEXT:   Content:     '000000000000000000000000000000000000000000'74 75--- !ELF76FileHeader:77  Class: ELFCLASS3278  Data:  ELFDATA2LSB79  Type:  ET_DYN80Sections:81## Case 1: Content is less than 16 bytes.82  - Name:   .gnu.hash.tooshort83    Type:   SHT_GNU_HASH84    Flags:  [ SHF_ALLOC ]85    Content: "112233445566778899AABBCCDDEEFF"86## Case2: Check how we handle a fully empty hash section.87## It is almost technically valid, but uncommon. Modern linkers88## create at least one entry in Bloom filter if they want to disable it.89## Also, the dynamic symbol table has a null entry and having SymNdx = 090## here is at least strange.91  - Name:  .gnu.hash.empty92    Type:  SHT_GNU_HASH93    Flags: [ SHF_ALLOC ]94    Header:95      SymNdx: 0x096      Shift2: 0x097      MaskWords: 0x098      NBuckets:  0x099    BloomFilter: []100    HashBuckets: []101    HashValues:  []102## Case 3: MaskWords field is broken: it says that the number of entries103## in the Bloom filter is 1, but the Bloom filter is empty.104  - Name:  .gnu.hash.broken.maskwords105    Type:  SHT_GNU_HASH106    Header:107      SymNdx: 0x0108      Shift2: 0x0109      MaskWords: 0x1110      NBuckets:  0x0111    BloomFilter: []112    HashBuckets: []113    HashValues:  []114## Case 4(a): NBuckets field is broken, it says that the number of entries115## in the hash buckets is 1, but it is empty.116  - Name:  .gnu.hash.broken.nbuckets.a117    Type:  SHT_GNU_HASH118    Header:119      SymNdx: 0x0120      Shift2: 0x0121      MaskWords: 0x0122      NBuckets:  0x1123    BloomFilter: []124    HashBuckets: []125    HashValues:  []126## Case 4(b): NBuckets = 0xFFFFFFFF is incorrect. The result will cause 32-bit127## unsigned overflows if we keep intermediate expressions uint32_t.128  - Name:  .gnu.hash.broken.nbuckets.b129    Type:  SHT_GNU_HASH130    Header:131      SymNdx: 0x0132      Shift2: 0x0133      MaskWords: 0x1134      NBuckets:  0xFFFFFFFF135    BloomFilter: []136    HashBuckets: []137    HashValues:  []138## Case 5: Check that we use the various properties to dump the data when it139## has a size that is a multiple of 4, but fallback to dumping the whole section140## using the "Content" property otherwise.141  - Name:  .gnu.hash.hashvalues.ok142    Type:  SHT_GNU_HASH143    Content: "0000000000000000000000000000000000000000"144  - Name:  .gnu.hash.hashvalues.fail145    Type:  SHT_GNU_HASH146    Content: "000000000000000000000000000000000000000000"147