brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.0 KiB · 3780fba Raw
192 lines · yaml
1## Check that yaml2obj is able to produce output2## when a symbol with section index SHN_XINDEX is used,3## but no SHT_SYMTAB_SHNDX section is defined.4 5# RUN: yaml2obj --docnum=1 %s -o %t16# RUN: llvm-readobj --symbols 2>&1 %t1 | FileCheck -DFILE=%t1 %s --check-prefix=CASE17 8# CASE1: warning: '[[FILE]]': found an extended symbol index (1), but unable to locate the extended symbol index table9 10--- !ELF11FileHeader:12  Class: ELFCLASS6413  Data:  ELFDATA2LSB14  Type:  ET_REL15Sections:16  - Name: bar17    Type: SHT_PROGBITS18Symbols:19  - Type:  STT_SECTION20    Index: SHN_XINDEX21 22## Check that yaml2obj keeps the SHT_SYMTAB_SHNDX section in the output23## even when symbol's section index value is low enough to not require the extended symtab.24## Also, check that symbols in .symtab still have the SHN_XINDEX index.25 26# RUN: yaml2obj --docnum=2 %s -o %t227# RUN: llvm-readobj --sections --symbols --section-data 2>&1 %t2 | FileCheck %s --check-prefix=CASE228 29# CASE2:      Section {30# CASE2:       Name: .symtab_shndx (1)31# CASE2-NEXT:  Type: SHT_SYMTAB_SHNDX (0x12)32 33# CASE2:      Name: .symtab34# CASE2:      SectionData (35# CASE2-NEXT:   0000: 00000000 00000000 00000000 0000000036# CASE2-NEXT:   0010: 00000000 00000000 00000000 0300FFFF37##                                                   ^-- 0xFFFF here is a SHN_XINDEX.38# CASE2-NEXT:   0020: 00000000 00000000 00000000 0000000039# CASE2-NEXT: )40 41# CASE2:      Symbol {42# CASE2:        Name: bar (0)43# CASE2-NEXT:   Value: 0x044# CASE2-NEXT:   Size: 045# CASE2-NEXT:   Binding: Local (0x0)46# CASE2-NEXT:   Type: Section (0x3)47# CASE2-NEXT:   Other: 048# CASE2-NEXT:   Section: bar (0x1)49# CASE2-NEXT: }50 51--- !ELF52FileHeader:53  Class: ELFCLASS6454  Data:  ELFDATA2LSB55  Type:  ET_REL56Sections:57  - Name: bar58    Type: SHT_PROGBITS59  - Name:    .symtab_shndx60    Type:    SHT_SYMTAB_SHNDX61    Entries: [ 0, 1 ]62    Link:    .symtab63Symbols:64  - Type:  STT_SECTION65    Index: SHN_XINDEX66 67## Check that yaml2obj allows producing broken SHT_SYMTAB_SHNDX section68## content (in the case below it contains 0xff as an index of a section,69## which is larger than the total number of sections in the file).70 71# RUN: yaml2obj --docnum=3 %s -o %t372# RUN: llvm-readobj --symbols 2>&1 %t3 | FileCheck %s -DFILE=%t3 --check-prefix=CASE373 74# CASE3: warning: '[[FILE]]': invalid section index: 25575 76--- !ELF77FileHeader:78  Class: ELFCLASS6479  Data:  ELFDATA2LSB80  Type:  ET_REL81Sections:82  - Name: bar83    Type: SHT_PROGBITS84  - Name:    .symtab_shndx85    Type:    SHT_SYMTAB_SHNDX86    Entries: [ 0, 255 ]87    Link:    .symtab88Symbols:89  - Type:  STT_SECTION90    Index: SHN_XINDEX91 92## Check that yaml2obj reports an error if a symbol index does not fit into 2 bytes.93 94# RUN: not yaml2obj --docnum=4 %s -o %t4 2>&1 | FileCheck %s --check-prefix=CASE495 96# CASE4: error: out of range hex16 number97 98--- !ELF99FileHeader:100  Class: ELFCLASS64101  Data:  ELFDATA2LSB102  Type:  ET_REL103Symbols:104  - Type:  STT_SECTION105    Index: 65536106 107## Check we can set a custom sh_entsize for SHT_SYMTAB_SHNDX section.108 109# RUN: yaml2obj --docnum=5 %s -o %t5110# RUN: llvm-readelf -S 2>&1 %t5 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5111 112# CASE5: warning: '[[FILE]]': section [index 1] has invalid sh_entsize: expected 4, but got 2113 114--- !ELF115FileHeader:116  Class: ELFCLASS64117  Data:  ELFDATA2LSB118  Type:  ET_REL119Sections:120  - Name:    .symtab_shndx121    Type:    SHT_SYMTAB_SHNDX122    Entries: [ 0 ]123    EntSize: 2124 125## Check we can use the "Content" key with the "Size" key when the size is greater126## than or equal to the content size.127 128# RUN: not yaml2obj --docnum=6 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \129# RUN:   FileCheck %s --check-prefix=CONTENT-SIZE-ERR130 131# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size132 133--- !ELF134FileHeader:135  Class: ELFCLASS64136  Data:  ELFDATA2LSB137  Type:  ET_DYN138Sections:139  - Name:    .symtab_shndx140    Type:    SHT_SYMTAB_SHNDX141    Link:    .symtab142    Size:    [[SIZE=<none>]]143    Content: [[CONTENT=<none>]]144    Entries: [[ENTRIES=<none>]]145  - Name: .symtab146    Type: SHT_SYMTAB147## llvm-readobj validates that SHT_SYMTAB_SHNDX section has the same number148## of entries that the symbol table associated has.149    Size: [[SYMTAB=0x24]]150 151# RUN: yaml2obj --docnum=6 -DSIZE=4 -DCONTENT="'00112233'" %s -o %t.cont.size.eq.o152# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \153# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00112233"154 155# RUN: yaml2obj --docnum=6 -DSIZE=8 -DSYMTAB=0x36 -DCONTENT="'00112233'" %s -o %t.cont.size.gr.o156# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \157# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00112233 00000000"158 159# CHECK-CONTENT:      Name: .symtab_shndx160# CHECK-CONTENT:      SectionData (161# CHECK-CONTENT-NEXT:   0000: [[DATA]] |162# CHECK-CONTENT-NEXT: )163 164## Check we can use the "Size" key alone to create the section.165 166# RUN: yaml2obj --docnum=6 -DSIZE=4 %s -o %t.size.o167# RUN: llvm-readobj --sections --section-data %t.size.o | \168# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00000000"169 170## Check we can use the "Content" key alone to create the section.171 172# RUN: yaml2obj --docnum=6 -DCONTENT="'11223344'" %s -o %t.content.o173# RUN: llvm-readobj --sections --section-data %t.content.o | \174# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="11223344"175 176## Check we can't use the "Entries" key together with the "Content" or "Size" keys.177 178# RUN: not yaml2obj --docnum=6 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \179# RUN:   FileCheck %s --check-prefix=ENTRIES-ERR180# RUN: not yaml2obj --docnum=6 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \181# RUN:   FileCheck %s --check-prefix=ENTRIES-ERR182 183# ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"184 185## Check we create an empty section when none of "Size", "Entries" or "Content" are specified.186 187# RUN: yaml2obj --docnum=6 -DSYMTAB=0x0 %s -o %t.empty188# RUN: llvm-readelf --sections %t.empty | FileCheck %s --check-prefix=EMPTY189 190# EMPTY: [Nr] Name          Type                   Address          Off    Size191# EMPTY: [ 1] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 000040 000000192