1 ## Check that obj2yaml is able to dump a normal object which
2 ## contains the SHT_SYMTAB_SHNDX section and symbols with
3 ## section index == SHN_XINDEX.
5 # RUN: yaml2obj --docnum=1 %s -o %t1
6 # RUN: obj2yaml %t1 | FileCheck %s --check-prefix=CASE1
9 # CASE1-NEXT: FileHeader:
10 # CASE1-NEXT: Class: ELFCLASS64
11 # CASE1-NEXT: Data: ELFDATA2LSB
12 # CASE1-NEXT: Type: ET_REL
13 # CASE1-NEXT: Sections:
14 # CASE1-NEXT: - Name: bar
15 # CASE1-NEXT: Type: SHT_PROGBITS
16 # CASE1-NEXT: - Name: .symtab_shndx
17 # CASE1-NEXT: Type: SHT_SYMTAB_SHNDX
18 # CASE1-NEXT: Link: .symtab
19 # CASE1-NEXT: Entries: [ 0, 1, 2 ]
20 # CASE1-NEXT: Symbols:
21 # CASE1-NEXT: - Name: bar
22 # CASE1-NEXT: Type: STT_SECTION
23 # CASE1-NEXT: Index: SHN_XINDEX
24 # CASE1-NEXT: - Name: .symtab_shndx
25 # CASE1-NEXT: Type: STT_SECTION
26 # CASE1-NEXT: Index: SHN_XINDEX
38 Type: SHT_SYMTAB_SHNDX
47 ## Check that yaml2obj is unable to dump an object, which has
48 ## symbols with section index == SHN_XINDEX, but no SHT_SYMTAB_SHNDX section.
50 # RUN: yaml2obj --docnum=2 %s -o %t2
51 # RUN: not obj2yaml %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=CASE2
53 # CASE2: Error reading file: [[FILE]]: found an extended symbol index (1), but unable to locate the extended symbol index table
64 ## Check that yaml2obj is unable to dump an object, which has symbols with
65 ## section index == SHN_XINDEX, but SHT_SYMTAB_SHNDX table contains invalid indices
66 ## that are larger than total number of the sections.
68 # RUN: yaml2obj --docnum=3 %s -o %t3
69 # RUN: not obj2yaml %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=CASE3
71 # CASE3: Error reading file: [[FILE]]: invalid section index: 254
82 Type: SHT_SYMTAB_SHNDX
89 ## Check that yaml2obj is unable to dump an object, which has symbols with
90 ## section index == SHN_XINDEX, but SHT_SYMTAB_SHNDX table contains more
91 ## entries than the number of symbols in .symtab.
93 # RUN: yaml2obj --docnum=4 %s -o %t4
94 # RUN: not obj2yaml %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE4
96 ## CASE4: Error reading file: [[FILE]]: unable to read extended section indexes: SHT_SYMTAB_SHNDX has 3 entries, but the symbol table associated has 2
106 - Name: .symtab_shndx
107 Type: SHT_SYMTAB_SHNDX
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 linked
117 ## to the same symbol table.
119 # RUN: yaml2obj --docnum=5 %s -o %t5
120 # RUN: not obj2yaml %t5 2>&1 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5
122 # CASE5: Error reading file: [[FILE]]: multiple SHT_SYMTAB_SHNDX sections are linked to the same symbol table with index 5
130 - Name: .symtab_shndx1
131 Type: SHT_SYMTAB_SHNDX
135 - Name: .symtab_shndx2
136 Type: SHT_SYMTAB_SHNDX
138 Link: [[LINK=.symtab]]
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 when
148 ## the SHT_SYMTAB_SHNDX section is associated with a SHT_DYNSYM section.
150 # RUN: yaml2obj --docnum=5 -DLINK=.dynsym %s -o %t5.multiple
151 # RUN: obj2yaml %t5.multiple | FileCheck %s --check-prefix=MULTIPLE-SYMTAB
153 # MULTIPLE-SYMTAB: - Name: .symtab_shndx1
154 # MULTIPLE-SYMTAB-NEXT: Type: SHT_SYMTAB_SHNDX
155 # MULTIPLE-SYMTAB-NEXT: Link: .symtab
156 # MULTIPLE-SYMTAB: - Name: .symtab_shndx2
157 # MULTIPLE-SYMTAB-NEXT: Type: SHT_SYMTAB_SHNDX
158 # MULTIPLE-SYMTAB-NEXT: Link: .dynsym
159 # MULTIPLE-SYMTAB: Symbols:
160 # MULTIPLE-SYMTAB-NEXT: - Name: .symtab_shndx1
161 # MULTIPLE-SYMTAB-NEXT: Type: STT_SECTION
162 # MULTIPLE-SYMTAB-NEXT: Index: SHN_XINDEX
163 # MULTIPLE-SYMTAB-NEXT: DynamicSymbols:
164 # MULTIPLE-SYMTAB-NEXT: - Name: .symtab_shndx2
165 # MULTIPLE-SYMTAB-NEXT: Type: STT_SECTION
166 # MULTIPLE-SYMTAB-NEXT: Index: SHN_XINDEX
168 ## Check that yaml2obj can't dump the object if SHT_SYMTAB_SHNDX is
169 ## not associated with a SHT_SYMTAB section (this case is illegal).
171 # RUN: yaml2obj --docnum=6 %s -o %t6
172 # RUN: not obj2yaml %t6 2>&1 | FileCheck %s -DFILE=%t6 --check-prefix=CASE6
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)
182 - Name: .symtab_shndx
183 Type: SHT_SYMTAB_SHNDX
189 ## Check that we are unable to dump the SHT_SYMTAB_SHNDX section when its
190 ## sh_entsize has an unexpected value (not equal to 4).
192 # RUN: yaml2obj -DENTSIZE=0xff --docnum=7 %s -o %t7.entsize.bad
193 # RUN: not obj2yaml %t7.entsize.bad 2>&1 | \
194 # RUN: FileCheck %s -DFILE=%t7.entsize.bad --check-prefix=CASE7-BAD
196 # CASE7-BAD: Error reading file: [[FILE]]: unable to read extended section indexes: section [index 1] has invalid sh_entsize: expected 4, but got 255
198 ## Check we don't print the "EntSize" field when the "sh_entsize" field has the default value.
200 # RUN: yaml2obj -DENTSIZE=4 --docnum=7 %s -o %t7.entsize.ok
201 # RUN: obj2yaml %t7.entsize.ok | FileCheck %s -DFILE=%t7.entsize.ok --check-prefix=CASE7
203 # CASE7: - Name: .symtab_shndx
204 # CASE7-NEXT: Type: SHT_SYMTAB_SHNDX
205 # CASE7-NEXT: Link: .symtab
206 # CASE7-NEXT: Entries: [ 0 ]
207 # CASE7-NEXT: Symbols:
215 - Name: .symtab_shndx
216 Type: SHT_SYMTAB_SHNDX