brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.7 KiB · 6e995cc Raw
221 lines · yaml
1## Check that obj2yaml is able to dump a normal object which2## contains the SHT_SYMTAB_SHNDX section and symbols with3## section index == SHN_XINDEX.4 5# RUN: yaml2obj --docnum=1 %s -o %t16# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=CASE17 8# CASE1:      --- !ELF9# CASE1-NEXT: FileHeader:10# CASE1-NEXT:   Class: ELFCLASS6411# CASE1-NEXT:   Data:  ELFDATA2LSB12# CASE1-NEXT:   Type:  ET_REL13# CASE1-NEXT: Sections:14# CASE1-NEXT:   - Name: bar15# CASE1-NEXT:     Type: SHT_PROGBITS16# CASE1-NEXT:   - Name: .symtab_shndx17# CASE1-NEXT:     Type: SHT_SYMTAB_SHNDX18# CASE1-NEXT:     Link: .symtab19# CASE1-NEXT:     Entries: [ 0, 1, 2 ]20# CASE1-NEXT: Symbols:21# CASE1-NEXT:   - Name:  bar22# CASE1-NEXT:     Type:  STT_SECTION23# CASE1-NEXT:     Index: SHN_XINDEX24# CASE1-NEXT:   - Name:  .symtab_shndx25# CASE1-NEXT:     Type:  STT_SECTION26# CASE1-NEXT:     Index: SHN_XINDEX27# CASE1-NEXT: ...28 29--- !ELF30FileHeader:31  Class: ELFCLASS6432  Data:  ELFDATA2LSB33  Type:  ET_REL34Sections:35  - Name: bar36    Type: SHT_PROGBITS37  - Name:    .symtab_shndx38    Type:    SHT_SYMTAB_SHNDX39    Entries: [ 0, 1, 2 ]40    Link:    .symtab41Symbols:42  - Type:  STT_SECTION43    Index: SHN_XINDEX44  - Type:  STT_SECTION45    Index: SHN_XINDEX46 47## Check that yaml2obj is unable to dump an object, which has48## symbols with section index == SHN_XINDEX, but no SHT_SYMTAB_SHNDX section.49 50# RUN: yaml2obj --docnum=2 %s -o %t251# RUN: not obj2yaml %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=CASE252 53# CASE2: Error reading file: [[FILE]]: found an extended symbol index (1), but unable to locate the extended symbol index table54 55--- !ELF56FileHeader:57  Class: ELFCLASS6458  Data:  ELFDATA2LSB59  Type:  ET_REL60Symbols:61  - Type:  STT_SECTION62    Index: SHN_XINDEX63 64## Check that yaml2obj is unable to dump an object, which has symbols with65## section index == SHN_XINDEX, but SHT_SYMTAB_SHNDX table contains invalid indices66## that are larger than total number of the sections.67 68# RUN: yaml2obj --docnum=3 %s -o %t369# RUN: not obj2yaml %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=CASE370 71# CASE3: Error reading file: [[FILE]]: invalid section index: 25472 73--- !ELF74FileHeader:75  Class: ELFCLASS6476  Data:  ELFDATA2LSB77  Type:  ET_REL78Sections:79  - Name: bar80    Type: SHT_PROGBITS81  - Name:    .symtab_shndx82    Type:    SHT_SYMTAB_SHNDX83    Entries: [ 0, 254 ]84    Link:    .symtab85Symbols:86  - Type:  STT_SECTION87    Index: SHN_XINDEX88 89## Check that yaml2obj is unable to dump an object, which has symbols with90## section index == SHN_XINDEX, but SHT_SYMTAB_SHNDX table contains more91## entries than the number of symbols in .symtab.92 93# RUN: yaml2obj --docnum=4 %s -o %t494# RUN: not obj2yaml %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE495 96## CASE4: Error reading file: [[FILE]]: unable to read extended section indexes: SHT_SYMTAB_SHNDX has 3 entries, but the symbol table associated has 297 98--- !ELF99FileHeader:100  Class: ELFCLASS64101  Data:  ELFDATA2LSB102  Type:  ET_REL103Sections:104  - Name: bar105    Type: SHT_PROGBITS106  - Name:    .symtab_shndx107    Type:    SHT_SYMTAB_SHNDX108    Entries: [ 0, 1, 2 ]109    Link:    .symtab110Symbols:111  - Type:  STT_SECTION112    Index: SHN_XINDEX113 114## ELF gABI allows having multiple SHT_SYMTAB_SHNDX sections.115## Only one is allowed to be linked with a corresponding symbol table section though.116## Check we report an error when multiple SHT_SYMTAB_SHNDX sections are linked117## to the same symbol table.118 119# RUN: yaml2obj --docnum=5 %s -o %t5120# RUN: not obj2yaml %t5 2>&1 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5121 122# CASE5: Error reading file: [[FILE]]: multiple SHT_SYMTAB_SHNDX sections are linked to the same symbol table with index 5123 124--- !ELF125FileHeader:126  Class: ELFCLASS64127  Data:  ELFDATA2LSB128  Type:  ET_REL129Sections:130  - Name:    .symtab_shndx1131    Type:    SHT_SYMTAB_SHNDX132    Entries: [ 0, 1 ]133    EntSize: 4134    Link:    .symtab135  - Name:    .symtab_shndx2136    Type:    SHT_SYMTAB_SHNDX137    Entries: [ 0, 2 ]138    Link:    [[LINK=.symtab]]139Symbols:140  - Type:  STT_SECTION141    Index: SHN_XINDEX142DynamicSymbols:143  - Type:  STT_SECTION144    Index: SHN_XINDEX145 146## Check it is possible to dump an object that has multiple SHT_SYMTAB_SHNDX sections.147## Check that yaml2obj can dump the object and dynamic symbols properly when148## the SHT_SYMTAB_SHNDX section is associated with a SHT_DYNSYM section.149 150# RUN: yaml2obj --docnum=5 -DLINK=.dynsym %s -o %t5.multiple151# RUN: obj2yaml %t5.multiple | FileCheck %s --check-prefix=MULTIPLE-SYMTAB152 153# MULTIPLE-SYMTAB:      - Name: .symtab_shndx1154# MULTIPLE-SYMTAB-NEXT:   Type: SHT_SYMTAB_SHNDX155# MULTIPLE-SYMTAB-NEXT:   Link: .symtab156# MULTIPLE-SYMTAB:      - Name: .symtab_shndx2157# MULTIPLE-SYMTAB-NEXT:   Type: SHT_SYMTAB_SHNDX158# MULTIPLE-SYMTAB-NEXT:   Link: .dynsym159# MULTIPLE-SYMTAB:      Symbols:160# MULTIPLE-SYMTAB-NEXT:   - Name:  .symtab_shndx1161# MULTIPLE-SYMTAB-NEXT:     Type:  STT_SECTION162# MULTIPLE-SYMTAB-NEXT:     Index: SHN_XINDEX163# MULTIPLE-SYMTAB-NEXT: DynamicSymbols:164# MULTIPLE-SYMTAB-NEXT:   - Name:   .symtab_shndx2165# MULTIPLE-SYMTAB-NEXT:     Type:   STT_SECTION166# MULTIPLE-SYMTAB-NEXT:     Index:  SHN_XINDEX167 168## Check that yaml2obj can't dump the object if SHT_SYMTAB_SHNDX is169## not associated with a SHT_SYMTAB section (this case is illegal).170 171# RUN: yaml2obj --docnum=6 %s -o %t6172# RUN: not obj2yaml %t6 2>&1 | FileCheck %s -DFILE=%t6 --check-prefix=CASE6173 174# CASE6: Error reading file: [[FILE]]: unable to read extended section indexes: SHT_SYMTAB_SHNDX section is linked with SHT_PROGBITS section (expected SHT_SYMTAB/SHT_DYNSYM)175 176--- !ELF177FileHeader:178  Class: ELFCLASS64179  Data:  ELFDATA2LSB180  Type:  ET_REL181Sections:182  - Name:    .symtab_shndx183    Type:    SHT_SYMTAB_SHNDX184    Entries: [ 0 ]185    Link:    .foo186  - Name:    .foo187    Type:    SHT_PROGBITS188 189## Check that we are unable to dump the SHT_SYMTAB_SHNDX section when its190## sh_entsize has an unexpected value (not equal to 4).191 192# RUN: yaml2obj -DENTSIZE=0xff --docnum=7 %s -o %t7.entsize.bad193# RUN: not obj2yaml %t7.entsize.bad 2>&1 | \194# RUN:   FileCheck %s -DFILE=%t7.entsize.bad --check-prefix=CASE7-BAD195 196# CASE7-BAD: Error reading file: [[FILE]]: unable to read extended section indexes: section [index 1] has invalid sh_entsize: expected 4, but got 255197 198## Check we don't print the "EntSize" field when the "sh_entsize" field has the default value.199 200# RUN: yaml2obj -DENTSIZE=4 --docnum=7 %s -o %t7.entsize.ok201# RUN: obj2yaml %t7.entsize.ok | FileCheck %s -DFILE=%t7.entsize.ok --check-prefix=CASE7202 203# CASE7:      - Name:    .symtab_shndx204# CASE7-NEXT:   Type:    SHT_SYMTAB_SHNDX205# CASE7-NEXT:   Link:    .symtab206# CASE7-NEXT:   Entries: [ 0 ]207# CASE7-NEXT: Symbols:208 209--- !ELF210FileHeader:211  Class: ELFCLASS64212  Data:  ELFDATA2LSB213  Type:  ET_REL214Sections:215  - Name:    .symtab_shndx216    Type:    SHT_SYMTAB_SHNDX217    EntSize: [[ENTSIZE]]218    Entries: [ 0 ]219    Link:    .symtab220Symbols: []221