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