summaryrefslogtreecommitdiffstats
path: root/llvm/test/Object/invalid.test
Commit message (Collapse)AuthorAgeFilesLines
...
* Recommit r285285 - [Object/ELF] - Fixed behavior when ↵George Rimar2016-10-311-0/+3
| | | | | | | | | | | | | | | | | | SectionHeaderTable->sh_size is too large. with fix: edited invalid-section-index2.elf input to pass the new check and fail on the same place it was intended to fail. Original commit message: Elf.h already has code checking that section table does not go past end of file. Problem is that this check may not work on values greater than UINT64_MAX / Header->e_shentsize because of calculation overflow. Parch fixes the issue. Differential revision: https://reviews.llvm.org/D25432 llvm-svn: 285586
* Revert r285285 "[Object/ELF] - Fixed behavior when ↵George Rimar2016-10-271-3/+0
| | | | | | | | SectionHeaderTable->sh_size is too large." It broke BB. llvm-svn: 285288
* [Object/ELF] - Fixed behavior when SectionHeaderTable->sh_size is too large.George Rimar2016-10-271-0/+3
| | | | | | | | | | | | Elf.h already has code checking that section table does not go past end of file. Problem is that this check may not work on values greater than UINT64_MAX / Header->e_shentsize because of calculation overflow. Parch fixes the issue. Differential revision: https://reviews.llvm.org/D25432 llvm-svn: 285285
* [Object/ELF] - Do not allow overflow when checking section size/offset.George Rimar2016-10-271-0/+4
| | | | | | | | | Overflow was the reason of incorrect passing the check, patch fixes the case. Differentail revision: https://reviews.llvm.org/D25514 llvm-svn: 285284
* [Object/ELF] - Do not crash if string table sh_size is equal to zero.George Rimar2016-10-271-0/+1
| | | | | | | | | Revealed using "id_000038,sig_11,src_000015,op_havoc,rep_16" from PR30540, when sh_size was 0, crash happened. Differential revision: https://reviews.llvm.org/D25091 llvm-svn: 285282
* [Object/ELF] - Check Header->e_shoff value earlier and do not crash.George Rimar2016-10-171-0/+4
| | | | | | | | | Patch checks that section pointer is aligned properly. This should be done before getStringTable() call. Differential revision: https://reviews.llvm.org/D25462 llvm-svn: 284387
* Recommit r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."George Rimar2016-10-171-0/+3
| | | | | | | | | | | | | | | | | | | | | With fix: hex edited the precompiled inputs from another testcases to pass new checks. Original commit message: [Object/ELF] - Check that e_shnum is null when e_shoff is. Spec says (http://www.sco.com/developers/gabi/1998-04-29/ch4.eheader.html) : e_shnum This member holds the number of entries in the section header table. Thus the product of e_shentsize and e_shnum gives the section header table's size in bytes. If a file has no section header table, e_shnum holds the value zero. Revealed using "id_000037,sig_11,src_000015,op_havoc,rep_8" from PR30540 That was the reason of crash in lld on incorrect input file. Binary reduced using afl-min. Differential revision: https://reviews.llvm.org/D25090 llvm-svn: 284374
* Revert r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."George Rimar2016-10-171-3/+0
| | | | | | | It broke build bot: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/908/steps/test-stage1-compiler/logs/stdio llvm-svn: 284373
* [Object/ELF] - Check that e_shnum is null when e_shoff is.George Rimar2016-10-171-0/+3
| | | | | | | | | | | | | | | Spec says (http://www.sco.com/developers/gabi/1998-04-29/ch4.eheader.html) : e_shnum This member holds the number of entries in the section header table. Thus the product of e_shentsize and e_shnum gives the section header table's size in bytes. If a file has no section header table, e_shnum holds the value zero. Revealed using "id_000037,sig_11,src_000015,op_havoc,rep_8" from PR30540 That was the reason of crash in lld on incorrect input file. Binary reduced using afl-min. Differential revision: https://reviews.llvm.org/D25090 llvm-svn: 284371
* [Object/ELF] - Do not crash on invalid section index.George Rimar2016-10-171-1/+1
| | | | | | | | | | | | | | | | If object has wrong (large) string table index and also incorrect large value for amount of sections in total, then section index passes the check: if (Index >= getNumSections()) return object_error::invalid_section_index; But result pointer then is far after end of file data, what result in a crash. Differential revision: https://reviews.llvm.org/D25081 llvm-svn: 284369
* Reverted r283740 [Object/ELF] - Do not crash on invalid Header->e_shoff value.George Rimar2016-10-111-4/+0
| | | | | | | | | | | | | | | | Bot does not like it: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/17075 /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/Object/invalid.test:70:32: error: expected string not found in input INVALID-SEC-ADDRESS-ALIGNMENT: Invalid address alignment of section headers ^ <stdin>:1:1: note: scanning from here /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELF.h:412:7: runtime error: upcast of misaligned address 0x000002d8b899 for type 'llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::support::endianness::little, true> >', which requires 2 byte alignment ^ <stdin>:1:125: note: possible intended match here /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELF.h:412:7: runtime error: upcast of misaligned address 0x000002d8b899 for type 'llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::support::endianness::little, true> >', which requires 2 byte alignment llvm-svn: 283858
* [Object/ELF] - Do not crash on invalid Header->e_shoff value.George Rimar2016-10-101-0/+4
| | | | | | | | | | | | | | | sections_begin() may return unalignment pointer when Header->e_shoff isinvalid. That may result in a crash in clients, for example we have one in LLD: assert((PtrWord & ~PointerBitMask) == 0 && "Pointer is not sufficiently aligned"); fails when trying to push_back Elf_Shdr* (unaligned) into TinyPtrVector. Patch forces check for alignment of Header->e_shoff. Differential revision: https://reviews.llvm.org/D25368 llvm-svn: 283740
* Centralize sh_entsize checking.Rafael Espindola2016-10-061-1/+1
| | | | llvm-svn: 283455
* Refactor to use getSectionContentsAsArray.Rafael Espindola2016-10-061-2/+2
| | | | | | This centralizes quite a bit of error checking. llvm-svn: 283454
* [Object/ELF] - Do not crash on invalid sh_offset value of REL[A] section.George Rimar2016-10-041-0/+6
| | | | | | | | | Previously code would access invalid memory and may crash, patch fixes the issue. Differential revision: https://reviews.llvm.org/D25187 llvm-svn: 283204
* [Object/ELF] - Avoid possible crash in getExtendedSymbolTableIndex().George Rimar2016-10-041-0/+4
| | | | | | | | | | When using broken input object found using AFL, getExtendedSymbolTableIndex() crashed because ShndxTable was empty as object does not contain SHT_SYMTAB_SHNDX section. Differential revision: https://reviews.llvm.org/D25189 llvm-svn: 283196
* Change how readobj stores info about dynamic symbols.Rafael Espindola2016-02-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to keep both a section and a pointer to the first symbol. The oddity of keeping a section for dynamic symbols is because there is a DT_SYMTAB but no DT_SYMTABZ, so to print the table we have to find the size via a section table. The reason for still keeping a pointer to the first symbol is because we want to be able to print relocation tables even if the section table is missing (it is mandatory only for files used in linking). With this patch we keep just a DynRegionInfo. This then requires changing a few places that were asking for a Elf_Shdr but actually just needed the first symbol. The test change is to delete the program header pointer. Now that we use the information of both DT_SYMTAB and .dynsym, we don't depend on the sh_entsize of .dynsym if we see DT_SYMTAB. Note: It is questionable if it is worth it putting the effort to report broken sh_entsize given that in files with no section table we have to assume it is sizeof(Elf_Sym), but that is for another change. Extracted from r260488. llvm-svn: 261099
* This reverts commit r260488 and r260489.Rafael Espindola2016-02-161-3/+1
| | | | | | | | | | | Original messages: Revert "[readobj] Handle ELF files with no section table or with no program headers." Revert "[readobj] Dump DT_JMPREL relocations when outputting dynamic relocations." r260489 depends on r260488 and among other issues r260488 deleted error handling code. llvm-svn: 260962
* [readobj] Handle ELF files with no section table or with no program headers.Michael J. Spencer2016-02-111-1/+3
| | | | | | | | This adds support for finding the dynamic table and dynamic symbol table via the section table or the program header table. If there's no section table an attempt is made to figure out the length of the dynamic symbol table. llvm-svn: 260488
* Report an error if a SHT_SYMTAB_SHNDX section has the wrong size.Rafael Espindola2015-08-241-0/+4
| | | | llvm-svn: 245873
* Refactor duplicated code and check for invalid symbol table size.Rafael Espindola2015-07-231-0/+4
| | | | llvm-svn: 242981
* Improve error message.Rafael Espindola2015-07-021-1/+1
| | | | | | Thanks to Sean Silva for the suggestion. llvm-svn: 241255
* Return ErrorOr from getSection.Rafael Espindola2015-07-011-1/+1
| | | | | | | | | | | | | | This also improves the logic of what is an error: * getSection(uint_32): only return an error if the index is out of bounds. The index 0 corresponds to a perfectly valid entry. * getSection(Elf_Sym): Returns null for symbols that normally don't have sections and error for out of bound indexes. In many places this just moves the report_fatal_error up the stack, but those can then be fixed in smaller patches. llvm-svn: 241156
* Remove Elf_Shdr_Iter. Diagnose files with invalid section header sizes.Rafael Espindola2015-06-301-0/+3
| | | | llvm-svn: 241109
* Add a test of an elf file with an invalid section index.Rafael Espindola2015-06-301-0/+4
| | | | | | We were already checking, but were missing a test. llvm-svn: 241094
* Report an error on invalid sh_entsize.Rafael Espindola2015-06-301-0/+32
| | | | llvm-svn: 241070
* Factor out the checking of string tables.Rafael Espindola2015-06-291-0/+1
| | | | | | | | | | This moves the error checking for string tables to getStringTable which returns an ErrorOr<StringRef>. This improves error checking, makes it uniform across all string tables and makes it possible to check them once instead of once per name. llvm-svn: 240950
* Add a testcase for an invalid file.Rafael Espindola2015-06-291-0/+3
| | | | | | We were already checking this, but had no tests. llvm-svn: 240945
* Convert an assert that can fail into error checking.Rafael Espindola2015-06-291-0/+1
| | | | llvm-svn: 240944
* Improve error handling of getRelocationAddend.Rafael Espindola2015-06-191-0/+2
This patch changes getRelocationAddend to use ErrorOr and considers it an error to try to get the addend of a REL section. If, for example, a x86_64 file has a REL section, that file is corrupted and we should reject it. Using ErrorOr is not ideal since we check the section type once per relocation instead of once per section. Checking once per section would involve getRelocationAddend just asserting and callers checking the section before iterating over the relocations. In any case, this is an improvement and includes a test. llvm-svn: 240176
OpenPOWER on IntegriCloud