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 -DFILE=%t6 --check-prefix=INVALID-SYM-SIZE %s 113 114# INVALID-SYM-SIZE: error: '[[FILE]]': 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 -DFILE=%t8 --check-prefix=INVALID-SYMTAB-LINK %s 154 155# INVALID-SYMTAB-LINK: error: '[[FILE]]': 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 -DFILE=%t10 --check-prefix=INVALID-SYMTAB-SIZE %s 189 190# INVALID-SYMTAB-SIZE: error: '[[FILE]]': 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 (2) 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 Entries: [ 0, 1 ] 222 Link: .symtab 223 224## Check that llvm-readobj reports an error if the e_phentsize field is broken. 225 226# RUN: not llvm-readobj --program-headers %p/Inputs/invalid-e_shnum.elf 2>&1 | \ 227# RUN: FileCheck -DFILE=%p/Inputs/invalid-e_shnum.elf --check-prefix=INVALID-PH-ENTSIZE %s 228 229# INVALID-PH-ENTSIZE: error: '[[FILE]]': invalid e_phentsize: 12336 230 231## Check that llvm-readobj reports an error when we have no SHT_SYMTAB_SHNDX section, 232## but have a symbol referencing it. 233 234# RUN: not llvm-readobj --symbols %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \ 235# RUN: FileCheck -DFILE=%p/Inputs/invalid-ext-symtab-index.elf-x86-64 --check-prefix=INVALID-EXT-SYMTAB-INDEX %s 236 237# INVALID-EXT-SYMTAB-INDEX: error: '[[FILE]]': extended symbol index (0) is past the end of the SHT_SYMTAB_SHNDX section of size 0 238 239## Check that llvm-readobj reports an error if a relocation section 240## has a broken sh_offset (past the end of the file). 241 242# RUN: yaml2obj %s --docnum=12 -o %t12 243# RUN: yaml2obj %s --docnum=13 -o %t13 244# RUN: not llvm-readobj -r %t12 2>&1 | FileCheck -DFILE=%t12 --check-prefix=INVALID-RELOC-SH-OFFSET %s 245# RUN: not llvm-readobj -r %t13 2>&1 | FileCheck -DFILE=%t13 --check-prefix=INVALID-RELOC-SH-OFFSET %s 246 247# INVALID-RELOC-SH-OFFSET: error: '[[FILE]]': section [index 1] has a sh_offset (0x10000) + sh_size (0x0) that cannot be represented 248 249--- !ELF 250FileHeader: 251 Class: ELFCLASS64 252 Data: ELFDATA2LSB 253 Type: ET_REL 254 Machine: EM_386 255Sections: 256 - Name: .rel 257 Type: SHT_REL 258 ShOffset: 0x10000 259 260--- !ELF 261FileHeader: 262 Class: ELFCLASS64 263 Data: ELFDATA2LSB 264 Type: ET_REL 265 Machine: EM_X86_64 266Sections: 267 - Name: .rela 268 Type: SHT_RELA 269 ShOffset: 0x10000 270 271## Check that llvm-objdump reports an error when .shstrtab has a broken sh_offset 272## so large that sh_offset + sh_size overflows the platform address size type. 273 274# RUN: yaml2obj %s --docnum=14 -o %t14 275# RUN: not llvm-readobj --symbols %t14 2>&1 | FileCheck -DFILE=%t14 --check-prefix=INVALID-SECTION-SIZE2 %s 276 277# INVALID-SECTION-SIZE2: error: '[[FILE]]': section [index 1] has a sh_offset (0xffffffff) + sh_size (0x27) that cannot be represented 278 279--- !ELF 280FileHeader: 281 Class: ELFCLASS64 282 Data: ELFDATA2LSB 283 Type: ET_REL 284 Machine: EM_386 285Sections: 286 - Name: .shstrtab 287 Type: SHT_STRTAB 288 ShOffset: 0xFFFFFFFF 289 290## Check that llvm-readobj reports an error when trying to dump sections 291## when the e_shnum field is broken (is greater than the actual number of sections). 292 293# RUN: yaml2obj %s --docnum=15 -o %t15 294# RUN: not llvm-readobj -S %t15 2>&1 | FileCheck --check-prefix=INVALID-SECTION-NUM %s 295 296# INVALID-SECTION-NUM: error: {{.*}}: section table goes past the end of file 297 298--- !ELF 299FileHeader: 300 Class: ELFCLASS64 301 Data: ELFDATA2LSB 302 Type: ET_REL 303 Machine: EM_X86_64 304 SHNum: 0xFF 305 306## Check that llvm-readobj reports an error if a relocation contains an 307## incorrect (too large) symbol index. 308 309# RUN: yaml2obj %s --docnum=16 -o %t16 310# RUN: not llvm-readobj -r %t16 2>&1 | FileCheck -DFILE=%t16 --check-prefix=INVALID-REL-SYM %s 311 312# INVALID-REL-SYM: error: '[[FILE]]': unable to access section [index 2] data at 0x18000180: offset goes past the end of file 313 314--- !ELF 315FileHeader: 316 Class: ELFCLASS64 317 Data: ELFDATA2LSB 318 Type: ET_REL 319 Machine: EM_X86_64 320Sections: 321 - Name: .rela.text 322 Type: SHT_RELA 323 Info: 0 324 Relocations: 325 - Offset: 0x0 326 Type: R_X86_64_64 327 Symbol: 0xFFFFFF 328 329## Check llvm-readobj does not crash on a truncated ELF. 330 331## Create a truncated ELF object with ELFCLASSNONE class using echo. 332## 0x7f, 'E', 'L', 'F', ELFCLASS64(2), ELFDATA2LSB(1), 333## EV_CURRENT(1), ELFOSABI_LINUX(3), <padding zero bytes>, ET_REL(1), EM_NONE(0) 334# RUN: echo -e -n "\x7f\x45\x4c\x46\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" > %t11 335# RUN: not llvm-readobj -r %t11 2>&1 | FileCheck --check-prefix=INVALID-BUFFER %s 336 337# INVALID-BUFFER: error: {{.*}}': invalid buffer: the size (18) is smaller than an ELF header (64) 338 339# RUN: not llvm-readobj %p/Inputs/invalid-coff-header-too-small 2>&1 | FileCheck --check-prefix=COFF-HEADER %s 340# COFF-HEADER: The file was not recognized as a valid object file 341 342## Check that llvm-readobj reports an error if section name offset 343## overflows the section name string table. 344 345# RUN: yaml2obj %s --docnum=17 -o %t17 346# RUN: not llvm-readobj --sections %t17 2>&1 | FileCheck -DFILE=%t17 --check-prefix=BROKEN-SECNAME %s 347 348## BROKEN-SECNAME: error: '[[FILE]]': a section [index 1] has an invalid sh_name (0x1) offset which goes past the end of the section name string table 349 350--- !ELF 351FileHeader: 352 Class: ELFCLASS64 353 Data: ELFDATA2LSB 354 Type: ET_REL 355 Machine: EM_X86_64 356Sections: 357 - Name: .shstrtab 358 Type: SHT_STRTAB 359 Size: 1 360 361## Check that llvm-readobj reports an error if a section has a broken offset 362## that goes past the end of the file. 363 364# RUN: yaml2obj %s --docnum=18 -o %t18 365# RUN: not llvm-readobj --sections --section-data %t18 2>&1 \ 366# RUN: | FileCheck -DFILE=%t18 --check-prefix=BROKEN-SECSHOFFSET %s 367 368# BROKEN-SECSHOFFSET: error: '[[FILE]]': section [index 1] has a sh_offset (0xffff0000) + sh_size (0x0) that cannot be represented 369 370--- !ELF 371FileHeader: 372 Class: ELFCLASS64 373 Data: ELFDATA2LSB 374 Type: ET_REL 375 Machine: EM_X86_64 376Sections: 377 - Name: .foo 378 Type: SHT_PROGBITS 379 ShOffset: 0xFFFF0000 380 381## Check that llvm-readobj reports an error if symbol name 382## offset goes past the end of the symbol string table. 383 384# RUN: yaml2obj %s --docnum=19 -o %t19 385# RUN: not llvm-readobj --symbols %t19 2>&1 | FileCheck -DFILE=%t19 --check-prefix=INVALID-SYM-NAME %s 386 387# INVALID-SYM-NAME: error: '[[FILE]]': Invalid data was encountered while parsing the file 388 389--- !ELF 390FileHeader: 391 Class: ELFCLASS64 392 Data: ELFDATA2LSB 393 Type: ET_REL 394 Machine: EM_X86_64 395Sections: 396 - Name: .strtab 397 Type: SHT_STRTAB 398 Size: 1 399Symbols: 400 - Name: foo 401 402## Version index in .gnu.version overflows the version map. 403## Check llvm-readobj reports it. 404 405# RUN: yaml2obj %s --docnum=20 -o %t20 406# RUN: not llvm-readobj -dt %t20 2>&1 | FileCheck --check-prefix=INVALID-VERSION %s 407 408# INVALID-VERSION: error: Invalid version entry 409 410--- !ELF 411FileHeader: 412 Class: ELFCLASS64 413 Data: ELFDATA2LSB 414 Type: ET_DYN 415 Machine: EM_X86_64 416Sections: 417 - Name: .gnu.version 418 Type: SHT_GNU_versym 419 Entries: [ 0xFF ] 420DynamicSymbols: 421 - Name: foo 422 423## ELF header contains e_phentsize field with a value != sizeof(Elf_Phdr). 424## Check llvm-readobj reports it. 425 426# RUN: not llvm-readobj -l %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 \ 427# RUN: | FileCheck -DFILE=%p/Inputs/corrupt-invalid-phentsize.elf.x86-64 --check-prefix=PHENTSIZE %s 428 429# PHENTSIZE: error: '[[FILE]]': invalid e_phentsize: 57 430 431## The dynamic table contains DT_STRTAB with a value that is not in any loadable segment. 432## Check llvm-readobj reports it. 433 434# RUN: yaml2obj %s --docnum=21 -o %t21 435# RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck --check-prefix=INVALID-DTSTRTAB %s 436 437# INVALID-DTSTRTAB: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0xffff0000 438 439--- !ELF 440FileHeader: 441 Class: ELFCLASS64 442 Data: ELFDATA2LSB 443 Type: ET_EXEC 444 Machine: EM_X86_64 445Sections: 446 - Name: .dynamic 447 Type: SHT_DYNAMIC 448 Address: 0x1000 449 Entries: 450 - Tag: DT_STRTAB 451 Value: 0xFFFF0000 452 - Tag: DT_NULL 453 Value: 0x0 454ProgramHeaders: 455 - Type: PT_LOAD 456 VAddr: 0x1000 457 Sections: 458 - Section: .dynamic 459 460## Check that llvm-readobj reports a warning when a dynamic relocation section 461## has sh_entsize field with size != sizeof(Elf_Rela). 462 463# RUN: llvm-readobj --dyn-relocations \ 464# RUN: %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 \ 465# RUN: | FileCheck --check-prefix=RELOC-BROKEN-ENTSIZE %s 466 467# RELOC-BROKEN-ENTSIZE: warning: invalid section size (24) or entity size (25) 468 469## Check that llvm-readobj reports a warning when .dynamic section has an invalid 470## size, which isn't a multiple of the dynamic entry size. 471 472# RUN: yaml2obj %s --docnum=22 -o %t22 473# RUN: llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck --check-prefix=DYN-TABLE-SIZE %s 474 475# DYN-TABLE-SIZE: warning: invalid section size (1) or entity size (16) 476 477--- !ELF 478FileHeader: 479 Class: ELFCLASS64 480 Data: ELFDATA2LSB 481 Type: ET_EXEC 482 Machine: EM_X86_64 483Sections: 484 - Name: .dynamic 485 Type: SHT_DYNAMIC 486 Content: "00" 487 488## PT_DYNAMIC's p_offset field is so large that p_offset + p_filesz is larger 489## than the object size. Check llvm-readobj reports it. 490 491# RUN: yaml2obj %s --docnum=23 -o %t23 492# RUN: llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck --check-prefix=DYN-TABLE-PHDR %s 493 494# DYN-TABLE-PHDR: warning: PT_DYNAMIC segment offset + size exceeds the size of the file 495 496--- !ELF 497FileHeader: 498 Class: ELFCLASS64 499 Data: ELFDATA2LSB 500 Type: ET_EXEC 501 Machine: EM_X86_64 502Sections: 503 - Name: .dynamic 504 Type: SHT_DYNAMIC 505 Entries: 506 - Tag: DT_NULL 507 Value: 0 508ProgramHeaders: 509 - Type: PT_DYNAMIC 510 Offset: 0xffff0000 511 Sections: 512 - Section: .dynamic 513 514## PT_DYNAMIC's p_filesz field is so large that p_offset + p_filesz is larger 515## than the object size. Check llvm-readobj reports it. 516 517# RUN: yaml2obj %s --docnum=24 -o %t24 518# RUN: llvm-readobj --dyn-relocations %t24 2>&1 \ 519# RUN: | FileCheck --check-prefix=DYN-TABLE-PHDR %s 520 521--- !ELF 522FileHeader: 523 Class: ELFCLASS64 524 Data: ELFDATA2LSB 525 Type: ET_EXEC 526 Machine: EM_X86_64 527Sections: 528 - Name: .dynamic 529 Type: SHT_DYNAMIC 530 Entries: 531 - Tag: DT_NULL 532 Value: 0 533ProgramHeaders: 534 - Type: PT_DYNAMIC 535 FileSize: 0xffff0000 536 Sections: 537 - Section: .dynamic 538 539# RUN: yaml2obj --docnum=25 %s -o %t25 540# RUN: not obj2yaml 2>&1 %t25 | FileCheck %s -DFILE=%t25 --check-prefix=INVALID-SHSTRNDX 541 542# INVALID-SHSTRNDX: Error reading file: [[FILE]]: section header string table index 255 does not exist 543 544--- !ELF 545FileHeader: 546 Class: ELFCLASS64 547 Data: ELFDATA2LSB 548 Type: ET_REL 549 Machine: EM_X86_64 550 SHStrNdx: 0xFF 551Sections: 552 - Name: .foo 553 Type: SHT_PROGBITS 554 555## We report an error if the number of sections stored in sh_size 556## is greater than UINT64_MAX / sizeof(Elf_Shdr) == 288230376151711743. 557## Here we check that do not crash on a border value. 558 559# RUN: yaml2obj --docnum=26 %s -o %t26 560# RUN: not llvm-readobj -h %t26 2>&1 | FileCheck -DFILE=%t26 --check-prefix=INVALID-SEC-NUM1 %s 561 562# 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) 563 564--- !ELF 565FileHeader: 566 Class: ELFCLASS64 567 Data: ELFDATA2LSB 568 Type: ET_REL 569 Machine: EM_X86_64 570 SHNum: 0x0 571Sections: 572 - Type: SHT_NULL 573 Size: 288230376151711743 574 575## See above, but now we test the UINT64_MAX / sizeof(Elf_Shdr) value. 576## The error is slightly different in this case. 577 578# RUN: yaml2obj --docnum=27 %s -o %t27 579# RUN: not llvm-readobj -h %t27 2>&1 | FileCheck -DFILE=%t27 --check-prefix=INVALID-SEC-NUM2 %s 580 581# INVALID-SEC-NUM2: error: '[[FILE]]': invalid number of sections specified in the NULL section's sh_size field (288230376151711744) 582 583--- !ELF 584FileHeader: 585 Class: ELFCLASS64 586 Data: ELFDATA2LSB 587 Type: ET_REL 588 Machine: EM_X86_64 589 SHNum: 0x0 590Sections: 591 - Type: SHT_NULL 592 Size: 288230376151711744 593 594## Check the case when SHOffset is too large. SHOffset + sizeof(Elf_Shdr) overflows the uint64 type. 595 596# RUN: yaml2obj --docnum=28 %s -o %t28 597# RUN: not llvm-readobj -h %t28 2>&1 | FileCheck -DFILE=%t28 --check-prefix=INVALID-SEC-NUM3 %s 598 599# INVALID-SEC-NUM3: error: '[[FILE]]': section header table goes past the end of the file: e_shoff = 0xffffffffffffffff 600 601--- !ELF 602FileHeader: 603 Class: ELFCLASS64 604 Data: ELFDATA2LSB 605 Type: ET_REL 606 Machine: EM_X86_64 607 SHOffset: 0xffffffffffffffff 608 609## Check that llvm-objdump reports an error when it tries to dump a 610## symbol name and .strtab is empty. 611 612# RUN: yaml2obj %s --docnum=29 -o %t29 613# RUN: not llvm-objdump -syms %t29 2>&1 | FileCheck -DFILE=%t29 --check-prefix=STRTAB-EMPTY2 %s 614 615# STRTAB-EMPTY2: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is empty 616 617--- !ELF 618FileHeader: 619 Class: ELFCLASS64 620 Data: ELFDATA2LSB 621 Type: ET_DYN 622 Machine: EM_X86_64 623Sections: 624 - Name: .strtab 625 Type: SHT_STRTAB 626 Content: "" 627Symbols: 628 - Name: foo 629 630## Check that we report an error if SHT_GNU_versym has invalid 631## sh_entsize value (3 instead of 2) when trying to access the entries. 632 633# RUN: yaml2obj %s --docnum=30 -o %t30 634# RUN: not llvm-readobj -V %t30 2>&1 | FileCheck -DFILE=%t30 --check-prefix=INVALID-VER-SHENTSIZE %s 635 636# INVALID-VER-SHENTSIZE: error: '[[FILE]]': section [index 1] has invalid sh_entsize: expected 2, but got 3 637 638--- !ELF 639FileHeader: 640 Class: ELFCLASS64 641 Data: ELFDATA2LSB 642 OSABI: ELFOSABI_FREEBSD 643 Type: ET_DYN 644 Machine: EM_X86_64 645Sections: 646 - Name: .gnu.version 647 Type: SHT_GNU_versym 648 EntSize: 0x0000000000000003 649 Entries: [ ] 650## Needed to trigger creation of .dynsym. 651DynamicSymbols: 652 - Name: foo 653 Binding: STB_GLOBAL 654 655## Check the case when e_shstrndx == SHN_XINDEX, but null section's sh_link contains 656## the index of a section header string table that is larger than the number of the sections. 657 658# RUN: yaml2obj --docnum=31 %s -o %t31 659# RUN: not llvm-objcopy %t31 2>&1 | FileCheck %s -DFILE=%t31 --check-prefix=INVALID-SHSTRTAB-INDEX 660 661# INVALID-SHSTRTAB-INDEX: error: section header string table index 255 does not exist 662 663--- !ELF 664FileHeader: 665 Class: ELFCLASS64 666 Data: ELFDATA2LSB 667 Type: ET_REL 668 Machine: EM_X86_64 669## SHN_XINDEX == 0xffff. 670 SHStrNdx: 0xffff 671Sections: 672 - Type: SHT_NULL 673 Link: 0xff 674