1## Check that llvm-objdump reports an error when
2## .shstrtab has an invalid type.
3
4# RUN: yaml2obj %s --docnum=1 -o %t1
5# RUN: not llvm-objdump -s %t1 2>&1 | FileCheck %s --check-prefix=INVALIDERR
6
7# INVALIDERR: error: reading file: Invalid data was encountered while parsing the file
8
9--- !ELF
10FileHeader:
11  Class:   ELFCLASS64
12  Data:    ELFDATA2LSB
13  Type:    ET_DYN
14  Machine: EM_X86_64
15Sections:
16  - Name: .shstrtab
17    Type: SHT_PROGBITS
18
19## Check that llvm-objdump reports an error when
20## .shstrtab has an invalid zero-size.
21
22# RUN: yaml2obj %s --docnum=2 -o %t2
23# RUN: not llvm-objdump -s %t2 2>&1 | FileCheck %s --check-prefix=INVALIDERR
24
25--- !ELF
26FileHeader:
27  Class:   ELFCLASS64
28  Data:    ELFDATA2LSB
29  Type:    ET_DYN
30  Machine: EM_X86_64
31Sections:
32  - Name: .shstrtab
33    Type: SHT_STRTAB
34    Size: 0
35
36## Check that llvm-objdump reports an error when .shstrtab has an invalid
37## size that goes past the end of the file.
38
39# RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-size.elf 2>&1 \
40# RUN:   | FileCheck %s --check-prefix=INVALIDERR
41
42## Check that llvm-dwarfdump reports an error during relocation resolution
43## when instead of expected SHT_RELA section it locates a section of a different type.
44
45# RUN: yaml2obj %s --docnum=3 -o %t3
46# RUN: not llvm-dwarfdump -debug-line %t3 2>&1 | FileCheck --check-prefix=RELA %s
47
48# RELA: LLVM ERROR: Section is not SHT_RELA
49
50--- !ELF
51FileHeader:
52  Class:   ELFCLASS64
53  Data:    ELFDATA2LSB
54  Type:    ET_REL
55  Machine: EM_X86_64
56Sections:
57  - Name: .debug_line
58    Type: SHT_PROGBITS
59## The exact content does not matter here. We can use any minimal valid debug section
60## which is a target for relocation. The idea is to trigger the code that reads the
61## relocation's addend during relocation resolution. It should fail if called on
62## a non-SHT_RELA section.
63    Content: 380000000200210000000101FB0E0D00010101010000000100000100676C6F62616C2E63707000000000000009020000000000000000130237000101
64  - Name: .rela.debug_line
65    Type: SHT_REL
66    Info: .debug_line
67    Relocations:
68      - Offset: 0x000000000000002E
69        Type:   R_X86_64_64
70
71## Check that llvm-objdump reports an error when it tries to dump section names
72## and .shstrtab is not null-terminated.
73
74# RUN: yaml2obj %s --docnum=4 -o %t4
75# RUN: not llvm-objdump -s %t4 2>&1 | FileCheck --check-prefix=INVALIDERR %s
76
77--- !ELF
78FileHeader:
79  Class:   ELFCLASS64
80  Data:    ELFDATA2LSB
81  Type:    ET_DYN
82  Machine: EM_X86_64
83Sections:
84  - Name: .shstrtab
85    Type: SHT_STRTAB
86    Content: "11"
87
88## Check that llvm-objdump reports an error when it tries to dump a symbol name and
89## .strtab is not null-terminated.
90
91# RUN: yaml2obj %s --docnum=5 -o %t5
92# RUN: not llvm-objdump -syms %t5 2>&1 | FileCheck --check-prefix=NONULL %s
93
94# NONULL: error: {{.*}}: SHT_STRTAB string table section [index 1] is non-null terminated
95
96--- !ELF
97FileHeader:
98  Class:   ELFCLASS64
99  Data:    ELFDATA2LSB
100  Type:    ET_DYN
101  Machine: EM_X86_64
102Sections:
103  - Name: .strtab
104    Type: SHT_STRTAB
105    Content: "11"
106Symbols:
107  - Name: foo
108
109## Check that llvm-readobj reports an error if .symtab has an invalid sh_entsize.
110
111# RUN: yaml2obj %s --docnum=6 -o %t6
112# RUN: not llvm-readobj --symbols %t6 2>&1 | FileCheck --check-prefix=INVALID-SYM-SIZE %s
113
114# INVALID-SYM-SIZE: error: section [index 1] has an invalid sh_entsize: 32
115
116--- !ELF
117FileHeader:
118  Class:   ELFCLASS64
119  Data:    ELFDATA2LSB
120  Type:    ET_DYN
121  Machine: EM_X86_64
122Sections:
123  - Name: .symtab
124    Type: SHT_SYMTAB
125    EntSize: 32
126Symbols:
127  - Name: foo
128
129## Check that llvm-readobj reports a warning if .dynsym has an invalid sh_entsize.
130
131# RUN: yaml2obj %s --docnum=7 -o %t7
132# RUN: llvm-readobj --dyn-symbols %t7 2>&1 | FileCheck --check-prefix=INVALID-DYNSYM-SIZE %s
133
134# INVALID-DYNSYM-SIZE: warning: invalid section size (48) or entity size (32)
135
136--- !ELF
137FileHeader:
138  Class:   ELFCLASS64
139  Data:    ELFDATA2LSB
140  Type:    ET_DYN
141  Machine: EM_X86_64
142Sections:
143  - Name: .dynsym
144    Type: SHT_DYNSYM
145    EntSize: 32
146DynamicSymbols:
147  - Name: foo
148
149## Check that llvm-readobj reports an error if .symtab has an invalid sh_link value,
150## which is greater than number of sections.
151
152# RUN: yaml2obj %s --docnum=8 -o %t8
153# RUN: not llvm-readobj --symbols %t8 2>&1 | FileCheck --check-prefix=INVALID-SYMTAB-LINK %s
154
155# INVALID-SYMTAB-LINK: error: invalid section index: 255
156
157--- !ELF
158FileHeader:
159  Class:   ELFCLASS64
160  Data:    ELFDATA2LSB
161  Type:    ET_REL
162  Machine: EM_X86_64
163Sections:
164  - Name: .symtab
165    Type: SHT_SYMTAB
166    Link: 0xFF
167
168## Check that llvm-readobj reports an error when trying to dump sections
169## when the e_shentsize field is broken.
170
171# RUN: yaml2obj %s --docnum=9 -o %t9
172# RUN: not llvm-readobj -S %t9 2>&1 | FileCheck --check-prefix=INVALID-SH-ENTSIZE %s
173
174# INVALID-SH-ENTSIZE: error: {{.*}}: invalid  e_shentsize in ELF header: 1
175
176--- !ELF
177FileHeader:
178  Class:     ELFCLASS64
179  Data:      ELFDATA2LSB
180  Type:      ET_REL
181  Machine:   EM_X86_64
182  SHEntSize: 1
183
184## Check that llvm-readobj reports an error if .symtab has sh_size
185## that is not a multiple of sh_entsize.
186
187# RUN: yaml2obj %s --docnum=10 -o %t10
188# RUN: not llvm-readobj --symbols %t10 2>&1 | FileCheck --check-prefix=INVALID-SYMTAB-SIZE %s
189
190# INVALID-SYMTAB-SIZE: error: section [index 1] has an invalid sh_size (1) which is not a multiple of its sh_entsize (24)
191
192--- !ELF
193FileHeader:
194  Class:   ELFCLASS64
195  Data:    ELFDATA2LSB
196  Type:    ET_DYN
197  Machine: EM_X86_64
198Sections:
199  - Name: .symtab
200    Type: SHT_SYMTAB
201    Size: 1
202
203## Test that llvm-readobj reports an error if SHT_SYMTAB_SHNDX section has
204## invalid sh_size which should be:
205## sizeof(.symtab_shndx) = (sizeof(.symtab) / entsize(.symtab)) * entsize(.symtab_shndx)
206
207# RUN: yaml2obj %s --docnum=11 -o %t11
208# RUN: not llvm-readobj --symbols %t11 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
209
210# INVALID-XINDEX-SIZE: error: {{.*}}: SHT_SYMTAB_SHNDX section has sh_size (24) which is not equal to the number of symbols (6)
211
212--- !ELF
213FileHeader:
214  Class:   ELFCLASS64
215  Data:    ELFDATA2LSB
216  Type:    ET_DYN
217  Machine: EM_X86_64
218Sections:
219  - Name: .symtab_shndx
220    Type: SHT_SYMTAB_SHNDX
221    Size: 0x18
222    EntSize: 4
223    Link: .symtab
224
225## Check that llvm-readobj reports an error if the e_phentsize field is broken.
226
227# RUN: not llvm-readobj --program-headers %p/Inputs/invalid-e_shnum.elf 2>&1 | \
228# RUN:  FileCheck --check-prefix=INVALID-PH-ENTSIZE %s
229
230# INVALID-PH-ENTSIZE: error: invalid e_phentsize: 12336
231
232## Check that llvm-readobj reports an error when we have no SHT_SYMTAB_SHNDX section,
233## but have a symbol referencing it.
234
235# RUN: not llvm-readobj --symbols %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \
236# RUN:   FileCheck --check-prefix=INVALID-EXT-SYMTAB-INDEX %s
237
238# INVALID-EXT-SYMTAB-INDEX: error: extended symbol index (0) is past the end of the SHT_SYMTAB_SHNDX section of size 0
239
240## Check that llvm-readobj reports an error if a relocation section
241## has a broken sh_offset (past the end of the file).
242
243# RUN: yaml2obj %s --docnum=12 -o %t12
244# RUN: yaml2obj %s --docnum=13 -o %t13
245# RUN: not llvm-readobj -r %t12 2>&1 | FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
246# RUN: not llvm-readobj -r %t13 2>&1 | FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
247
248# INVALID-RELOC-SH-OFFSET: error: section [index 1] has a sh_offset (0x10000) + sh_size (0x0) that cannot be represented
249
250--- !ELF
251FileHeader:
252  Class:   ELFCLASS64
253  Data:    ELFDATA2LSB
254  Type:    ET_REL
255  Machine: EM_386
256Sections:
257  - Name:     .rel
258    Type:     SHT_REL
259    ShOffset: 0x10000
260
261--- !ELF
262FileHeader:
263  Class:   ELFCLASS64
264  Data:    ELFDATA2LSB
265  Type:    ET_REL
266  Machine: EM_X86_64
267Sections:
268  - Name:     .rela
269    Type:     SHT_RELA
270    ShOffset: 0x10000
271
272## Check that llvm-objdump reports an error when .shstrtab has a broken sh_offset
273## so large that sh_offset + sh_size overflows the platform address size type.
274
275# RUN: yaml2obj %s --docnum=14 -o %t14
276# RUN: not llvm-readobj --symbols %t14 2>&1 | FileCheck --check-prefix=INVALID-SECTION-SIZE2 %s
277
278# INVALID-SECTION-SIZE2: error: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x27) that cannot be represented
279
280--- !ELF
281FileHeader:
282  Class:   ELFCLASS64
283  Data:    ELFDATA2LSB
284  Type:    ET_REL
285  Machine: EM_386
286Sections:
287  - Name:     .shstrtab
288    Type:     SHT_STRTAB
289    ShOffset: 0xFFFFFFFF
290
291## Check that llvm-readobj reports an error when trying to dump sections
292## when the e_shnum field is broken (is greater than the actual number of sections).
293
294# RUN: yaml2obj %s --docnum=15 -o %t15
295# RUN: not llvm-readobj -S %t15 2>&1 | FileCheck --check-prefix=INVALID-SECTION-NUM %s
296
297# INVALID-SECTION-NUM: error: {{.*}}: section table goes past the end of file
298
299--- !ELF
300FileHeader:
301  Class:   ELFCLASS64
302  Data:    ELFDATA2LSB
303  Type:    ET_REL
304  Machine: EM_X86_64
305  SHNum:   0xFF
306
307## Check that llvm-readobj reports an error if a relocation contains an
308## incorrect (too large) symbol index.
309
310# RUN: yaml2obj %s --docnum=16 -o %t16
311# RUN: not llvm-readobj -r %t16 2>&1 | FileCheck --check-prefix=INVALID-REL-SYM %s
312
313# INVALID-REL-SYM: error: unable to access section [index 2] data at 0x18000180: offset goes past the end of file
314
315--- !ELF
316FileHeader:
317  Class:   ELFCLASS64
318  Data:    ELFDATA2LSB
319  Type:    ET_REL
320  Machine: EM_X86_64
321Sections:
322  - Name: .rela.text
323    Type: SHT_RELA
324    Info: 0
325    Relocations:
326      - Offset: 0x0
327        Type:   R_X86_64_64
328        Symbol: 0xFFFFFF
329
330## Check llvm-readobj does not crash on a truncated ELF.
331
332## Create a truncated ELF object with ELFCLASSNONE class using echo.
333## 0x7f, 'E', 'L', 'F', ELFCLASS64(2), ELFDATA2LSB(1),
334## EV_CURRENT(1), ELFOSABI_LINUX(3), <padding zero bytes>, ET_REL(1), EM_NONE(0)
335# RUN: echo -e -n "\x7f\x45\x4c\x46\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" > %t11
336# RUN: not llvm-readobj -r %t11 2>&1 | FileCheck --check-prefix=INVALID-BUFFER %s
337
338# INVALID-BUFFER: error: {{.*}}': invalid buffer: the size (18) is smaller than an ELF header (64)
339
340# RUN: not llvm-readobj %p/Inputs/invalid-coff-header-too-small 2>&1 | FileCheck --check-prefix=COFF-HEADER %s
341# COFF-HEADER: The file was not recognized as a valid object file
342
343## Check that llvm-readobj reports an error if section name offset
344## overflows the section name string table.
345
346# RUN: yaml2obj %s --docnum=17 -o %t17
347# RUN: not llvm-readobj --sections %t17 2>&1 | FileCheck --check-prefix=BROKEN-SECNAME %s
348
349## BROKEN-SECNAME: error: a section [index 1] has an invalid sh_name (0x1) offset which goes past the end of the section name string table
350
351--- !ELF
352FileHeader:
353  Class:   ELFCLASS64
354  Data:    ELFDATA2LSB
355  Type:    ET_REL
356  Machine: EM_X86_64
357Sections:
358  - Name: .shstrtab
359    Type: SHT_STRTAB
360    Size: 1
361
362## Check that llvm-readobj reports an error if a section has a broken offset
363## that goes past the end of the file.
364
365# RUN: yaml2obj %s --docnum=18 -o %t18
366# RUN: not llvm-readobj --sections --section-data %t18 2>&1 \
367# RUN:  | FileCheck --check-prefix=BROKEN-SECSHOFFSET %s
368
369# BROKEN-SECSHOFFSET: error: section [index 1] has a sh_offset (0xffff0000) + sh_size (0x0) that cannot be represented
370
371--- !ELF
372FileHeader:
373  Class:   ELFCLASS64
374  Data:    ELFDATA2LSB
375  Type:    ET_REL
376  Machine: EM_X86_64
377Sections:
378  - Name:     .foo
379    Type:     SHT_PROGBITS
380    ShOffset: 0xFFFF0000
381
382## Check that llvm-readobj reports an error if symbol name
383## offset goes past the end of the symbol string table.
384
385# RUN: yaml2obj %s --docnum=19 -o %t19
386# RUN: not llvm-readobj --symbols %t19 2>&1 | FileCheck --check-prefix=INVALID-SYM-NAME %s
387
388# INVALID-SYM-NAME: error: Invalid data was encountered while parsing the file
389
390--- !ELF
391FileHeader:
392  Class:   ELFCLASS64
393  Data:    ELFDATA2LSB
394  Type:    ET_REL
395  Machine: EM_X86_64
396Sections:
397  - Name: .strtab
398    Type: SHT_STRTAB
399    Size: 1
400Symbols:
401  - Name: foo
402
403## Version index in .gnu.version overflows the version map.
404## Check llvm-readobj reports it.
405
406# RUN: yaml2obj %s --docnum=20 -o %t20
407# RUN: not llvm-readobj -dt %t20 2>&1 | FileCheck --check-prefix=INVALID-VERSION %s
408
409# INVALID-VERSION: error: Invalid version entry
410
411--- !ELF
412FileHeader:
413  Class:   ELFCLASS64
414  Data:    ELFDATA2LSB
415  Type:    ET_DYN
416  Machine: EM_X86_64
417Sections:
418  - Name:    .gnu.version
419    Type:    SHT_GNU_versym
420    Entries: [ 0xFF ]
421DynamicSymbols:
422  - Name: foo
423
424## ELF header contains e_phentsize field with a value != sizeof(Elf_Phdr).
425## Check llvm-readobj reports it.
426
427# RUN: not llvm-readobj -l %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 \
428# RUN:   | FileCheck --check-prefix=PHENTSIZE %s
429
430# PHENTSIZE: error: invalid e_phentsize: 57
431
432## The dynamic table contains DT_STRTAB with a value that is not in any loadable segment.
433## Check llvm-readobj reports it.
434
435# RUN: yaml2obj %s --docnum=21 -o %t21
436# RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck --check-prefix=INVALID-DTSTRTAB %s
437
438# INVALID-DTSTRTAB: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0xffff0000
439
440--- !ELF
441FileHeader:
442  Class:   ELFCLASS64
443  Data:    ELFDATA2LSB
444  Type:    ET_EXEC
445  Machine: EM_X86_64
446Sections:
447  - Name:    .dynamic
448    Type:    SHT_DYNAMIC
449    Address: 0x1000
450    Entries:
451      - Tag:   DT_STRTAB
452        Value: 0xFFFF0000
453      - Tag:   DT_NULL
454        Value: 0x0
455ProgramHeaders:
456  - Type: PT_LOAD
457    VAddr: 0x1000
458    Sections:
459      - Section: .dynamic
460
461## Check that llvm-readobj reports a warning when a dynamic relocation section
462## has sh_entsize field with size != sizeof(Elf_Rela).
463
464# RUN: llvm-readobj --dyn-relocations \
465# RUN:   %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 \
466# RUN:    | FileCheck --check-prefix=RELOC-BROKEN-ENTSIZE %s
467
468# RELOC-BROKEN-ENTSIZE: warning: invalid section size (24) or entity size (25)
469
470## Check that llvm-readobj reports a warning when .dynamic section has an invalid
471## size, which isn't a multiple of the dynamic entry size.
472
473# RUN: yaml2obj %s --docnum=22 -o %t22
474# RUN: llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck --check-prefix=DYN-TABLE-SIZE %s
475
476# DYN-TABLE-SIZE: warning: invalid section size (1) or entity size (16)
477
478--- !ELF
479FileHeader:
480  Class:   ELFCLASS64
481  Data:    ELFDATA2LSB
482  Type:    ET_EXEC
483  Machine: EM_X86_64
484Sections:
485  - Name:    .dynamic
486    Type:    SHT_DYNAMIC
487    Content: "00"
488
489## PT_DYNAMIC's p_offset field is so large that p_offset + p_filesz is larger
490## than the object size. Check llvm-readobj reports it.
491
492# RUN: yaml2obj %s --docnum=23 -o %t23
493# RUN: not llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck --check-prefix=DYN-TABLE-PHDR %s
494
495# DYN-TABLE-PHDR: error: PT_DYNAMIC segment offset + size exceeds the size of the file
496
497--- !ELF
498FileHeader:
499  Class:   ELFCLASS64
500  Data:    ELFDATA2LSB
501  Type:    ET_EXEC
502  Machine: EM_X86_64
503Sections:
504  - Name: .dynamic
505    Type: SHT_DYNAMIC
506    Entries:
507      - Tag:   DT_NULL
508        Value: 0
509ProgramHeaders:
510  - Type:   PT_DYNAMIC
511    Offset: 0xffff0000
512    Sections:
513      - Section: .dynamic
514
515## PT_DYNAMIC's p_filesz field is so large that p_offset + p_filesz is larger
516## than the object size. Check llvm-readobj reports it.
517
518# RUN: yaml2obj %s --docnum=24 -o %t24
519# RUN: not llvm-readobj --dyn-relocations %t24 2>&1 \
520# RUN:  | FileCheck --check-prefix=DYN-TABLE-PHDR %s
521
522--- !ELF
523FileHeader:
524  Class:   ELFCLASS64
525  Data:    ELFDATA2LSB
526  Type:    ET_EXEC
527  Machine: EM_X86_64
528Sections:
529  - Name: .dynamic
530    Type: SHT_DYNAMIC
531    Entries:
532      - Tag:   DT_NULL
533        Value: 0
534ProgramHeaders:
535  - Type:     PT_DYNAMIC
536    FileSize: 0xffff0000
537    Sections:
538      - Section: .dynamic
539
540# RUN: yaml2obj --docnum=25 %s -o %t25
541# RUN: not obj2yaml 2>&1 %t25 | FileCheck %s -DFILE=%t25 --check-prefix=INVALID-SHSTRNDX
542
543# INVALID-SHSTRNDX: Error reading file: [[FILE]]: section header string table index 255 does not exist
544
545--- !ELF
546FileHeader:
547  Class:    ELFCLASS64
548  Data:     ELFDATA2LSB
549  Type:     ET_REL
550  Machine:  EM_X86_64
551  SHStrNdx: 0xFF
552Sections:
553  - Name: .foo
554    Type: SHT_PROGBITS
555
556## We report an error if the number of sections stored in sh_size
557## is greater than UINT64_MAX / sizeof(Elf_Shdr) == 288230376151711743.
558## Here we check that do not crash on a border value.
559
560# RUN: yaml2obj --docnum=26 %s -o %t26
561# RUN: not llvm-readobj -h %t26 2>&1 | FileCheck -DFILE=%t26 --check-prefix=INVALID-SEC-NUM1 %s
562
563# INVALID-SEC-NUM1: error: '[[FILE]]': invalid section header table offset (e_shoff = 0x40) or invalid number of sections specified in the first section header's sh_size field (0x3ffffffffffffff)
564
565--- !ELF
566FileHeader:
567  Class:   ELFCLASS64
568  Data:    ELFDATA2LSB
569  Type:    ET_REL
570  Machine: EM_X86_64
571  SHNum:   0x0
572Sections:
573  - Type: SHT_NULL
574    Size: 288230376151711743
575
576## See above, but now we test the UINT64_MAX / sizeof(Elf_Shdr) value.
577## The error is slightly different in this case.
578
579# RUN: yaml2obj --docnum=27 %s -o %t27
580# RUN: not llvm-readobj -h %t27 2>&1 | FileCheck -DFILE=%t27 --check-prefix=INVALID-SEC-NUM2 %s
581
582# INVALID-SEC-NUM2: error: '[[FILE]]': invalid number of sections specified in the NULL section's sh_size field (288230376151711744)
583
584--- !ELF
585FileHeader:
586  Class:   ELFCLASS64
587  Data:    ELFDATA2LSB
588  Type:    ET_REL
589  Machine: EM_X86_64
590  SHNum:   0x0
591Sections:
592  - Type: SHT_NULL
593    Size: 288230376151711744
594
595## Check the case when SHOffset is too large. SHOffset + sizeof(Elf_Shdr) overflows the uint64 type.
596
597# RUN: yaml2obj --docnum=28 %s -o %t28
598# RUN: not llvm-readobj -h %t28 2>&1 | FileCheck -DFILE=%t28 --check-prefix=INVALID-SEC-NUM3 %s
599
600# INVALID-SEC-NUM3: error: '[[FILE]]': section header table goes past the end of the file: e_shoff = 0xffffffffffffffff
601
602--- !ELF
603FileHeader:
604  Class:    ELFCLASS64
605  Data:     ELFDATA2LSB
606  Type:     ET_REL
607  Machine:  EM_X86_64
608  SHOffset: 0xffffffffffffffff
609
610## Check that llvm-objdump reports an error when it tries to dump a
611## symbol name and .strtab is empty.
612
613# RUN: yaml2obj %s --docnum=29 -o %t29
614# RUN: not llvm-objdump -syms %t29 2>&1 | FileCheck -DFILE=%t29 --check-prefix=STRTAB-EMPTY2 %s
615
616# STRTAB-EMPTY2: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is empty
617
618--- !ELF
619FileHeader:
620  Class:   ELFCLASS64
621  Data:    ELFDATA2LSB
622  Type:    ET_DYN
623  Machine: EM_X86_64
624Sections:
625  - Name: .strtab
626    Type: SHT_STRTAB
627    Content: ""
628Symbols:
629  - Name: foo
630
631## Check that we report an error if SHT_GNU_versym has invalid
632## sh_entsize value (3 instead of 2) when trying to access the entries.
633
634# RUN: yaml2obj %s --docnum=30 -o %t30
635# RUN: not llvm-readobj -V %t30 2>&1 | FileCheck --check-prefix=INVALID-VER-SHENTSIZE %s
636
637# INVALID-VER-SHENTSIZE: error: section [index 1] has invalid sh_entsize: expected 2, but got 3
638
639--- !ELF
640FileHeader:
641  Class:   ELFCLASS64
642  Data:    ELFDATA2LSB
643  OSABI:   ELFOSABI_FREEBSD
644  Type:    ET_DYN
645  Machine: EM_X86_64
646Sections:
647  - Name:    .gnu.version
648    Type:    SHT_GNU_versym
649    EntSize: 0x0000000000000003
650    Entries: [ ]
651## Needed to trigger creation of .dynsym.
652DynamicSymbols:
653  - Name:    foo
654    Binding: STB_GLOBAL
655