llvm.org GIT mirror llvm / 102f3cb
[Object/ELF.h] - Improve error reporting. The errors coming from ELF.h are usually not very useful because they are uninformative. This patch is a first step to improve the situation. I tested this patch with a run of check-llvm and found that few messages are untested. In this patch, I did not add more tests but marked all such cases with a "TODO" comment. For all tested messages I extended the error text to provide more details (see test cases changed). Differential revision: https://reviews.llvm.org/D64014 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365183 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar a month ago
9 changed file(s) with 131 addition(s) and 55 deletion(s). Raw diff Collapse all Expand all
4343 (uint8_t)Object[ELF::EI_DATA]);
4444 }
4545
46 static inline Error createError(StringRef Err) {
46 static inline Error createError(const Twine &Err) {
4747 return make_error(Err, object_error::parse_failed);
48 }
49
50 template class ELFFile;
51
52 template
53 std::string getSecIndexForError(const ELFFile *Obj,
54 const typename ELFT::Shdr *Sec) {
55 auto TableOrErr = Obj->sections();
56 if (TableOrErr)
57 return "[index " + std::to_string(Sec - &TableOrErr->front()) + "]";
58 // To make this helper be more convenient for error reporting purposes we
59 // drop the error. But really it should never be triggered. Before this point,
60 // our code should have called 'sections()' and reported a proper error on
61 // failure.
62 llvm::consumeError(TableOrErr.takeError());
63 return "[unknown index]";
4864 }
4965
5066 template
161177 /// Iterate over program header table.
162178 Expected program_headers() const {
163179 if (getHeader()->e_phnum && getHeader()->e_phentsize != sizeof(Elf_Phdr))
164 return createError("invalid e_phentsize");
180 return createError("invalid e_phentsize: " +
181 Twine(getHeader()->e_phentsize));
165182 if (getHeader()->e_phoff +
166183 (getHeader()->e_phnum * getHeader()->e_phentsize) >
167184 getBufSize())
168 return createError("program headers longer than binary");
185 return createError("program headers are longer than binary of size " +
186 Twine(getBufSize()) + ": e_phoff = 0x" +
187 Twine::utohexstr(getHeader()->e_phoff) +
188 ", e_phnum = " + Twine(getHeader()->e_phnum) +
189 ", e_phentsize = " + Twine(getHeader()->e_phentsize));
169190 auto *Begin =
170191 reinterpret_cast(base() + getHeader()->e_phoff);
171192 return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
180201 /// be checked after iteration ends.
181202 Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const {
182203 if (Phdr.p_type != ELF::PT_NOTE) {
204 // TODO: this error is untested.
183205 Err = createError("attempt to iterate notes of non-note program header");
184206 return Elf_Note_Iterator(Err);
185207 }
186208 if (Phdr.p_offset + Phdr.p_filesz > getBufSize()) {
209 // TODO: this error is untested.
187210 Err = createError("invalid program header offset/size");
188211 return Elf_Note_Iterator(Err);
189212 }
199222 /// be checked after iteration ends.
200223 Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
201224 if (Shdr.sh_type != ELF::SHT_NOTE) {
225 // TODO: this error is untested.
202226 Err = createError("attempt to iterate notes of non-note section");
203227 return Elf_Note_Iterator(Err);
204228 }
205229 if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
230 // TODO: this error is untested.
206231 Err = createError("invalid section offset/size");
207232 return Elf_Note_Iterator(Err);
208233 }
270295 inline Expected
271296 getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
272297 if (Index >= Sections.size())
273 return createError("invalid section index");
298 return createError("invalid section index: " + Twine(Index));
274299 return &Sections[Index];
275300 }
276301
282307 assert(Sym->st_shndx == ELF::SHN_XINDEX);
283308 unsigned Index = Sym - FirstSym;
284309 if (Index >= ShndxTable.size())
285 return createError("index past the end of the symbol table");
310 return createError(
311 "extended symbol index (" + Twine(Index) +
312 ") is past the end of the SHT_SYMTAB_SHNDX section of size " +
313 Twine(ShndxTable.size()));
286314
287315 // The size of the table was checked in getSHNDXTable.
288316 return ShndxTable[Index];
332360 inline Expected
333361 getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
334362 if (Index >= Symbols.size())
363 // TODO: this error is untested.
335364 return createError("invalid symbol index");
336365 return &Symbols[Index];
337366 }
350379 Expected>
351380 ELFFile::getSectionContentsAsArray(const Elf_Shdr *Sec) const {
352381 if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
353 return createError("invalid sh_entsize");
382 return createError("section " + getSecIndexForError(this, Sec) +
383 " has an invalid sh_entsize: " + Twine(Sec->sh_entsize));
354384
355385 uintX_t Offset = Sec->sh_offset;
356386 uintX_t Size = Sec->sh_size;
357387
358388 if (Size % sizeof(T))
359 return createError("size is not a multiple of sh_entsize");
389 return createError("section " + getSecIndexForError(this, Sec) +
390 " has an invalid sh_size (" + Twine(Size) +
391 ") which is not a multiple of its sh_entsize (" +
392 Twine(Sec->sh_entsize) + ")");
360393 if ((std::numeric_limits::max() - Offset < Size) ||
361394 Offset + Size > Buf.size())
362 return createError("invalid section offset");
395 return createError("section " + getSecIndexForError(this, Sec) +
396 " has a sh_offset (0x" + Twine::utohexstr(Offset) +
397 ") + sh_size (0x" + Twine(Size) +
398 ") that cannot be represented");
363399
364400 if (Offset % alignof(T))
401 // TODO: this error is untested.
365402 return createError("unaligned data");
366403
367404 const T *Start = reinterpret_cast(base() + Offset);
435472 if (!Index) // no section string table.
436473 return "";
437474 if (Index >= Sections.size())
475 // TODO: this error is untested.
438476 return createError("invalid section index");
439477 return getStringTable(&Sections[Index]);
440478 }
444482 template
445483 Expected> ELFFile::create(StringRef Object) {
446484 if (sizeof(Elf_Ehdr) > Object.size())
447 return createError("Invalid buffer");
485 return createError("invalid buffer: the size (" + Twine(Object.size()) +
486 ") is smaller than an ELF header (" +
487 Twine(sizeof(Elf_Ehdr)) + ")");
448488 return ELFFile(Object);
449489 }
450490
455495 return ArrayRef();
456496
457497 if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
498 return createError("invalid e_shentsize in ELF header: " +
499 Twine(getHeader()->e_shentsize));
500
501 const uint64_t FileSize = Buf.size();
502 if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
458503 return createError(
459 "invalid section header entry size (e_shentsize) in ELF header");
460
461 const uint64_t FileSize = Buf.size();
462
463 if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
464 return createError("section header table goes past the end of the file");
504 "section header table goes past the end of the file: e_shoff = 0x" +
505 Twine::utohexstr(SectionTableOffset));
465506
466507 // Invalid address alignment of section headers
467508 if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
509 // TODO: this error is untested.
468510 return createError("invalid alignment of section headers");
469511
470512 const Elf_Shdr *First =
475517 NumSections = First->sh_size;
476518
477519 if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
520 // TODO: this error is untested.
478521 return createError("section table goes past the end of file");
479522
480523 const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
501544 Expected ELFFile::getEntry(const Elf_Shdr *Section,
502545 uint32_t Entry) const {
503546 if (sizeof(T) != Section->sh_entsize)
547 // TODO: this error is untested.
504548 return createError("invalid sh_entsize");
505549 size_t Pos = Section->sh_offset + Entry * sizeof(T);
506550 if (Pos + sizeof(T) > Buf.size())
507 return createError("invalid section offset");
551 return createError("unable to access section " +
552 getSecIndexForError(this, Section) + " data at 0x" +
553 Twine::utohexstr(Pos) +
554 ": offset goes past the end of file");
508555 return reinterpret_cast(base() + Pos);
509556 }
510557
530577 if (*SecNameOrErr == SectionName)
531578 return &Sec;
532579 }
580 // TODO: this error is untested.
533581 return createError("invalid section name");
534582 }
535583
537585 Expected
538586 ELFFile::getStringTable(const Elf_Shdr *Section) const {
539587 if (Section->sh_type != ELF::SHT_STRTAB)
540 return createError("invalid sh_type for string table, expected SHT_STRTAB");
588 return createError("invalid sh_type for string table section " +
589 getSecIndexForError(this, Section) +
590 ": expected SHT_STRTAB, but got " +
591 object::getELFSectionTypeName(getHeader()->e_machine,
592 Section->sh_type));
541593 auto V = getSectionContentsAsArray(Section);
542594 if (!V)
543595 return V.takeError();
544596 ArrayRef Data = *V;
545597 if (Data.empty())
598 // TODO: this error is untested.
546599 return createError("empty string table");
547600 if (Data.back() != '\0')
548 return createError("string table non-null terminated");
601 return createError(object::getELFSectionTypeName(getHeader()->e_machine,
602 Section->sh_type) +
603 " string table section " +
604 getSecIndexForError(this, Section) +
605 " is non-null terminated");
549606 return StringRef(Data.begin(), Data.size());
550607 }
551608
573630 const Elf_Shdr &SymTable = **SymTableOrErr;
574631 if (SymTable.sh_type != ELF::SHT_SYMTAB &&
575632 SymTable.sh_type != ELF::SHT_DYNSYM)
633 // TODO: this error is untested.
576634 return createError("invalid sh_type");
577635 if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
578 return createError("invalid section contents size");
636 return createError("SHT_SYMTAB_SHNDX section has sh_size (" +
637 Twine(SymTable.sh_size) +
638 ") which is not equal to the number of symbols (" +
639 Twine(V.size()) + ")");
579640 return V;
580641 }
581642
594655 Elf_Shdr_Range Sections) const {
595656
596657 if (Sec.sh_type != ELF::SHT_SYMTAB && Sec.sh_type != ELF::SHT_DYNSYM)
658 // TODO: this error is untested.
597659 return createError(
598660 "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
599661 auto SectionOrErr = object::getSection(Sections, Sec.sh_link);
621683 if (Offset == 0)
622684 return StringRef();
623685 if (Offset >= DotShstrtab.size())
624 return createError("invalid string offset");
686 return createError("a section " + getSecIndexForError(this, Section) +
687 " has an invalid sh_name (0x" +
688 Twine::utohexstr(Offset) +
689 ") offset which goes past the end of the "
690 "section name string table");
625691 return StringRef(DotShstrtab.data() + Offset);
626692 }
627693
536536 }
537537
538538 if (Dyn.empty())
539 // TODO: this error is untested.
539540 return createError("invalid empty dynamic section");
540541
541542 if (DynSecSize % sizeof(Elf_Dyn) != 0)
543 // TODO: this error is untested.
542544 return createError("malformed dynamic section");
543545
544546 if (Dyn.back().d_tag != ELF::DT_NULL)
547 // TODO: this error is untested.
545548 return createError("dynamic sections must be DT_NULL terminated");
546549
547550 return Dyn;
566569 });
567570
568571 if (I == LoadSegments.begin())
569 return createError("Virtual address is not in any segment");
572 return createError("virtual address is not in any segment: 0x" +
573 Twine::utohexstr(VAddr));
570574 --I;
571575 const Elf_Phdr &Phdr = **I;
572576 uint64_t Delta = VAddr - Phdr.p_vaddr;
573577 if (Delta >= Phdr.p_filesz)
574 return createError("Virtual address is not in any segment");
578 return createError("virtual address is not in any segment: 0x" +
579 Twine::utohexstr(VAddr));
575580 return base() + Phdr.p_offset + Delta;
576581 }
577582
2222 RUN: not llvm-objdump -private-headers %p/Inputs/invalid-phdr.elf 2>&1 \
2323 RUN: | FileCheck %s
2424
25 CHECK: LLVM ERROR: program headers longer than binary
25 CHECK: LLVM ERROR: program headers are longer than binary of size 4162: e_phoff = 0xffffff, e_phnum = 1, e_phentsize = 56
33 # RUN: yaml2obj %s --docnum=1 -o %t1
44 # RUN: not llvm-objdump -s %t1 2>&1 | FileCheck %s --check-prefix=INVALIDERR
55
6 # INVALIDERR: Invalid data was encountered while parsing the file
6 # INVALIDERR: error: reading file: Invalid data was encountered while parsing the file
77
88 --- !ELF
99 FileHeader:
4444 # RUN: yaml2obj %s --docnum=3 -o %t3
4545 # RUN: not llvm-dwarfdump -debug-line %t3 2>&1 | FileCheck --check-prefix=RELA %s
4646
47 # RELA: Section is not SHT_RELA
47 # RELA: LLVM ERROR: Section is not SHT_RELA
4848
4949 --- !ELF
5050 FileHeader:
9090 # RUN: yaml2obj %s --docnum=5 -o %t5
9191 # RUN: not llvm-objdump -syms %t5 2>&1 | FileCheck --check-prefix=NONULL %s
9292
93 # NONULL: string table non-null terminated
93 # NONULL: error: {{.*}}: SHT_STRTAB string table section [index 1] is non-null terminated
9494
9595 --- !ELF
9696 FileHeader:
110110 # RUN: yaml2obj %s --docnum=6 -o %t6
111111 # RUN: not llvm-readobj --symbols %t6 2>&1 | FileCheck --check-prefix=INVALID-SYM-SIZE %s
112112
113 # INVALID-SYM-SIZE: invalid sh_entsize
113 # INVALID-SYM-SIZE: error: section [index 1] has an invalid sh_entsize: 32
114114
115115 --- !ELF
116116 FileHeader:
151151 # RUN: yaml2obj %s --docnum=8 -o %t8
152152 # RUN: not llvm-readobj --symbols %t8 2>&1 | FileCheck --check-prefix=INVALID-SYMTAB-LINK %s
153153
154 # INVALID-SYMTAB-LINK: invalid section index
154 # INVALID-SYMTAB-LINK: error: invalid section index: 255
155155
156156 --- !ELF
157157 FileHeader:
170170 # RUN: yaml2obj %s --docnum=9 -o %t9
171171 # RUN: not llvm-readobj -S %t9 2>&1 | FileCheck --check-prefix=INVALID-SH-ENTSIZE %s
172172
173 # INVALID-SH-ENTSIZE: invalid section header entry size (e_shentsize) in ELF header
173 # INVALID-SH-ENTSIZE: error: {{.*}}: invalid e_shentsize in ELF header: 1
174174
175175 --- !ELF
176176 FileHeader:
186186 # RUN: yaml2obj %s --docnum=10 -o %t10
187187 # RUN: not llvm-readobj --symbols %t10 2>&1 | FileCheck --check-prefix=INVALID-SYMTAB-SIZE %s
188188
189 # INVALID-SYMTAB-SIZE: size is not a multiple of sh_entsize
189 # INVALID-SYMTAB-SIZE: error: section [index 1] has an invalid sh_size (1) which is not a multiple of its sh_entsize (24)
190190
191191 --- !ELF
192192 FileHeader:
206206 # RUN: yaml2obj %s --docnum=11 -o %t11
207207 # RUN: not llvm-readobj --symbols %t11 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
208208
209 # INVALID-XINDEX-SIZE: invalid section contents size
209 # INVALID-XINDEX-SIZE: error: {{.*}}: SHT_SYMTAB_SHNDX section has sh_size (24) which is not equal to the number of symbols (6)
210210
211211 --- !ELF
212212 FileHeader:
226226 # RUN: not llvm-readobj --program-headers %p/Inputs/invalid-e_shnum.elf 2>&1 | \
227227 # RUN: FileCheck --check-prefix=INVALID-PH-ENTSIZE %s
228228
229 # INVALID-PH-ENTSIZE: invalid e_phentsize
229 # INVALID-PH-ENTSIZE: error: invalid e_phentsize: 12336
230230
231231 ## Check that llvm-readobj reports an error when we have no SHT_SYMTAB_SHNDX section,
232232 ## but have a symbol referencing it.
234234 # RUN: not llvm-readobj --symbols %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \
235235 # RUN: FileCheck --check-prefix=INVALID-EXT-SYMTAB-INDEX %s
236236
237 # INVALID-EXT-SYMTAB-INDEX: index past the end of the symbol table
237 # INVALID-EXT-SYMTAB-INDEX: error: extended symbol index (0) is past the end of the SHT_SYMTAB_SHNDX section of size 0
238238
239239 ## Check that llvm-readobj reports an error if a relocation section
240240 ## has a broken sh_offset (past the end of the file).
244244 # RUN: not llvm-readobj -r %t12 2>&1 | FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
245245 # RUN: not llvm-readobj -r %t13 2>&1 | FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
246246
247 # INVALID-RELOC-SH-OFFSET: invalid section offset
247 # INVALID-RELOC-SH-OFFSET: error: section [index 1] has a sh_offset (0x10000) + sh_size (0x0) that cannot be represented
248248
249249 --- !ELF
250250 FileHeader:
274274 # RUN: yaml2obj %s --docnum=14 -o %t14
275275 # RUN: not llvm-readobj --symbols %t14 2>&1 | FileCheck --check-prefix=INVALID-SECTION-SIZE2 %s
276276
277 # INVALID-SECTION-SIZE2: invalid section offset
277 # INVALID-SECTION-SIZE2: error: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x27) that cannot be represented
278278
279279 --- !ELF
280280 FileHeader:
293293 # RUN: yaml2obj %s --docnum=15 -o %t15
294294 # RUN: not llvm-readobj -S %t15 2>&1 | FileCheck --check-prefix=INVALID-SECTION-NUM %s
295295
296 # INVALID-SECTION-NUM: section table goes past the end of file
297
296 # INVALID-SECTION-NUM: error: {{.*}}: section table goes past the end of file
297
298298 --- !ELF
299299 FileHeader:
300300 Class: ELFCLASS64
309309 # RUN: yaml2obj %s --docnum=16 -o %t16
310310 # RUN: not llvm-readobj -r %t16 2>&1 | FileCheck --check-prefix=INVALID-REL-SYM %s
311311
312 # INVALID-REL-SYM: invalid section offset
312 # INVALID-REL-SYM: error: unable to access section [index 2] data at 0x18000180: offset goes past the end of file
313313
314314 --- !ELF
315315 FileHeader:
334334 # RUN: echo -e -n "\x7f\x45\x4c\x46\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" > %t11
335335 # RUN: not llvm-readobj -r %t11 2>&1 | FileCheck --check-prefix=INVALID-BUFFER %s
336336
337 # INVALID-BUFFER: Invalid buffer
337 # INVALID-BUFFER: error: {{.*}}': invalid buffer: the size (18) is smaller than an ELF header (64)
338338
339339 # RUN: not llvm-readobj %p/Inputs/invalid-coff-header-too-small 2>&1 | FileCheck --check-prefix=COFF-HEADER %s
340340 # COFF-HEADER: The file was not recognized as a valid object file
345345 # RUN: yaml2obj %s --docnum=17 -o %t17
346346 # RUN: not llvm-readobj --sections %t17 2>&1 | FileCheck --check-prefix=BROKEN-SECNAME %s
347347
348 ## BROKEN-SECNAME: invalid string offset
348 ## 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
349349
350350 --- !ELF
351351 FileHeader:
365365 # RUN: not llvm-readobj --sections --section-data %t18 2>&1 \
366366 # RUN: | FileCheck --check-prefix=BROKEN-SECSHOFFSET %s
367367
368 # BROKEN-SECSHOFFSET: invalid section offset
368 # BROKEN-SECSHOFFSET: error: section [index 1] has a sh_offset (0xffff0000) + sh_size (0x0) that cannot be represented
369369
370370 --- !ELF
371371 FileHeader:
426426 # RUN: not llvm-readobj -l %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 \
427427 # RUN: | FileCheck --check-prefix=PHENTSIZE %s
428428
429 # PHENTSIZE: invalid e_phentsize
429 # PHENTSIZE: error: invalid e_phentsize: 57
430430
431431 ## The dynamic table contains DT_STRTAB with a value that is not in any loadable segment.
432432 ## Check llvm-readobj reports it.
434434 # RUN: yaml2obj %s --docnum=21 -o %t21
435435 # RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck --check-prefix=INVALID-DTSTRTAB %s
436436
437 # INVALID-DTSTRTAB: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment
437 # INVALID-DTSTRTAB: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0xffff0000
438438
439439 --- !ELF
440440 FileHeader:
464464 # RUN: %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 \
465465 # RUN: | FileCheck --check-prefix=RELOC-BROKEN-ENTSIZE %s
466466
467 # RELOC-BROKEN-ENTSIZE: Invalid entity size
467 # RELOC-BROKEN-ENTSIZE: error: Invalid entity size
468468
469469 ## Check that llvm-readobj reports an error when .dynamic section has an invalid
470470 ## size, which isn't a multiple of the dynamic entry size.
472472 # RUN: yaml2obj %s --docnum=22 -o %t22
473473 # RUN: not llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck --check-prefix=DYN-TABLE-SIZE %s
474474
475 # DYN-TABLE-SIZE: Invalid entity size
475 # DYN-TABLE-SIZE: error: Invalid entity size
476476
477477 --- !ELF
478478 FileHeader:
4646 Sections:
4747 - Section: .dynamic
4848
49 # CHECK: Virtual address is not in any segment when locating .dynstr section contents
49 # CHECK: virtual address is not in any segment: 0x260 when locating .dynstr section contents
1212
1313 ## Truncate the file to end before the program header table ends.
1414 # RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)"
15 # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s
15 # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s --check-prefix=CASE1
16
17 # CASE1: error: program headers are longer than binary of size 65: e_phoff = 0x40, e_phnum = 1, e_phentsize = 56
1618
1719 ## Set the e_phoff field to a value much larger than the object file size.
1820 # RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('
19 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s
21 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s --check-prefix=CASE2
2022
2123 --- !ELF
2224 FileHeader:
2729 ProgramHeaders:
2830 - Type: PT_LOAD
2931
30 # CHECK: error: program headers longer than binary
32 # CASE2: error: program headers are longer than binary of size 120: e_phoff = 0x40000000, e_phnum = 1, e_phentsize = 56
1010
1111 ## Truncate the file to end before the section header table ends.
1212 # RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)"
13 # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s -DINPUT=%t.o
13 # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s -DINPUT=%t.o --check-prefix=CASE1
14
15 # CASE1: error: '[[INPUT]]': section header table goes past the end of the file: e_shoff = 0x40
1416
1517 ## Set the e_shoff field to a value much larger than the object file size.
1618 # RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('
17 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s -DINPUT=%t2.o
19 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s -DINPUT=%t2.o --check-prefix=CASE2
1820
1921 --- !ELF
2022 FileHeader:
2628 - Name: .foo
2729 Type: SHT_PROGBITS
2830
29 # CHECK: error: '[[INPUT]]': section header table goes past the end of the file
31 # CASE2: error: '[[INPUT]]': section header table goes past the end of the file: e_shoff = 0x40000000
55 # RUN: llvm-readobj -S %t1 2>&1 | FileCheck %s --check-prefixes=LLVM,ERR
66 # RUN: llvm-readelf -S %t1 2>&1 | FileCheck %s --check-prefixes=GNU,ERR
77
8 # ERR: warning: invalid sh_type for string table, expected SHT_STRTAB
8 # ERR: warning: invalid sh_type for string table section [index 0]: expected SHT_STRTAB, but got SHT_NULL
99
1010 # LLVM: Name: .dynsym
1111 # LLVM-NEXT: Type: SHT_DYNSYM
140140
141141 # RUN: llvm-readobj --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR
142142 # RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR
143 # BAD-STRTAB-ERR: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment
143 # BAD-STRTAB-ERR: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0x2000000
144144
145145 # RUN: llvm-readobj --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-LLVM
146146 # RUN: llvm-readelf --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-GNU
185185 # RUN: llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefixes=CHECK,BAD-RELA
186186 # RUN: llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefixes=CHECK,BAD-RELA-GNU
187187
188 # CHECK: warning: Unable to parse DT_RELA: Virtual address is not in any segment
188 # CHECK: warning: Unable to parse DT_RELA: virtual address is not in any segment: 0x1000000
189
189190 # BAD-RELA: DynamicSection [ (2 entries)
190191 # BAD-RELA-NEXT: Tag Type Name/Value
191192 # BAD-RELA-NEXT: 0x0000000000000007 RELA 0x1000000