1 ## Check that yaml2obj is able to produce output
2 ## when a symbol with section index SHN_XINDEX is used,
3 ## but no SHT_SYMTAB_SHNDX section is defined.
5 # RUN: yaml2obj --docnum=1 %s -o %t1
6 # RUN: llvm-readobj --symbols 2>&1 %t1 | FileCheck -DFILE=%t1 %s --check-prefix=CASE1
8 # CASE1: warning: '[[FILE]]': found an extended symbol index (1), but unable to locate the extended symbol index table
22 ## Check that yaml2obj keeps the SHT_SYMTAB_SHNDX section in the output
23 ## 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.
26 # RUN: yaml2obj --docnum=2 %s -o %t2
27 # RUN: llvm-readobj --sections --symbols --section-data 2>&1 %t2 | FileCheck %s --check-prefix=CASE2
30 # CASE2: Name: .symtab_shndx (1)
31 # CASE2-NEXT: Type: SHT_SYMTAB_SHNDX (0x12)
33 # CASE2: Name: .symtab
34 # CASE2: SectionData (
35 # CASE2-NEXT: 0000: 00000000 00000000 00000000 00000000
36 # CASE2-NEXT: 0010: 00000000 00000000 00000000 0300FFFF
37 ## ^-- 0xFFFF here is a SHN_XINDEX.
38 # CASE2-NEXT: 0020: 00000000 00000000 00000000 00000000
42 # CASE2: Name: bar (0)
43 # CASE2-NEXT: Value: 0x0
45 # CASE2-NEXT: Binding: Local (0x0)
46 # CASE2-NEXT: Type: Section (0x3)
47 # CASE2-NEXT: Other: 0
48 # CASE2-NEXT: Section: bar (0x1)
60 Type: SHT_SYMTAB_SHNDX
67 ## Check that yaml2obj allows producing broken SHT_SYMTAB_SHNDX section
68 ## 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).
71 # RUN: yaml2obj --docnum=3 %s -o %t3
72 # RUN: llvm-readobj --symbols 2>&1 %t3 | FileCheck %s -DFILE=%t3 --check-prefix=CASE3
74 # CASE3: warning: '[[FILE]]': invalid section index: 255
85 Type: SHT_SYMTAB_SHNDX
92 ## Check that yaml2obj reports an error if a symbol index does not fit into 2 bytes.
94 # RUN: not yaml2obj --docnum=4 %s -o %t4 2>&1 | FileCheck %s --check-prefix=CASE4
96 # CASE4: error: out of range hex16 number
107 ## Check we can set a custom sh_entsize for SHT_SYMTAB_SHNDX section.
109 # RUN: yaml2obj --docnum=5 %s -o %t5
110 # RUN: llvm-readelf -S 2>&1 %t5 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5
112 # CASE5: warning: '[[FILE]]': section [index 1] has invalid sh_entsize: expected 4, but got 2
120 - Name: .symtab_shndx
121 Type: SHT_SYMTAB_SHNDX
125 ## Check we can use the "Content" key with the "Size" key when the size is greater
126 ## than or equal to the content size.
128 # RUN: not yaml2obj --docnum=6 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
129 # RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
131 # CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
139 - Name: .symtab_shndx
140 Type: SHT_SYMTAB_SHNDX
142 Size: [[SIZE=<none>]]
143 Content: [[CONTENT=<none>]]
144 Entries: [[ENTRIES=<none>]]
147 ## llvm-readobj validates that SHT_SYMTAB_SHNDX section has the same number
148 ## of entries that the symbol table associated has.
149 Size: [[SYMTAB=0x24]]
151 # RUN: yaml2obj --docnum=6 -DSIZE=4 -DCONTENT="'00112233'" %s -o %t.cont.size.eq.o
152 # RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
153 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00112233"
155 # RUN: yaml2obj --docnum=6 -DSIZE=8 -DSYMTAB=0x36 -DCONTENT="'00112233'" %s -o %t.cont.size.gr.o
156 # RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
157 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00112233 00000000"
159 # CHECK-CONTENT: Name: .symtab_shndx
160 # CHECK-CONTENT: SectionData (
161 # CHECK-CONTENT-NEXT: 0000: [[DATA]] |
162 # CHECK-CONTENT-NEXT: )
164 ## Check we can use the "Size" key alone to create the section.
166 # RUN: yaml2obj --docnum=6 -DSIZE=4 %s -o %t.size.o
167 # RUN: llvm-readobj --sections --section-data %t.size.o | \
168 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00000000"
170 ## Check we can use the "Content" key alone to create the section.
172 # RUN: yaml2obj --docnum=6 -DCONTENT="'11223344'" %s -o %t.content.o
173 # RUN: llvm-readobj --sections --section-data %t.content.o | \
174 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="11223344"
176 ## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
178 # RUN: not yaml2obj --docnum=6 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \
179 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
180 # RUN: not yaml2obj --docnum=6 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \
181 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
183 # ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"
185 ## Check we create an empty section when none of "Size", "Entries" or "Content" are specified.
187 # RUN: yaml2obj --docnum=6 -DSYMTAB=0x0 %s -o %t.empty
188 # RUN: llvm-readelf --sections %t.empty | FileCheck %s --check-prefix=EMPTY
190 # EMPTY: [Nr] Name Type Address Off Size
191 # EMPTY: [ 1] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 000040 000000