summaryrefslogtreecommitdiffstats
path: root/llvm/test/Object
Commit message (Collapse)AuthorAgeFilesLines
...
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-10-183-0/+6
| | | | | | | | | | | load commands that use the MachO::routines_command and and MachO::routines_command_64 types but are not used in llvm libObject code but used in llvm tool code. This includes the LC_ROUTINES and LC_ROUTINES_64 load commands. llvm-svn: 284504
* [llvm-readobj] - Teach readobj to print ↵George Rimar2016-10-181-0/+0
| | | | | | | | | | | | | | | | | | | | PT_OPENBSD_RANDOMIZE/PT_OPENBSD_WXNEEDED headers. These are OpenBSD specific program headers and currently we support them in LLD. Description of headers (just in case) available here: http://man.openbsd.org/OpenBSD-current/man5/elf.5 OpenBSD commits were: For PT_OPENBSD_RANDOMIZE: https://github.com/openbsd/src/commit/c494713c450d98da3f2e1451ee8c7fb675a7c461 For PT_OPENBSD_WXNEEDED: https://github.com/openbsd/src/commit/2a5a8fc7e30928c2cff57cfe5fb491c90d8478ad Differential revision: https://reviews.llvm.org/D25616 llvm-svn: 284471
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-10-175-0/+12
| | | | | | | | | | | | load commands that use the MachO::sub_framework_command, MachO::sub_umbrella_command, MachO::sub_library_command and MachO::sub_client_command types but are not used in llvm libObject code but used in llvm tool code. This includes the LC_SUB_FRAMEWORK, LC_SUB_UMBRELLA, LC_SUB_LIBRARY and LC_SUB_CLIENT load commands. llvm-svn: 284431
* [Object/ELF] - Check Header->e_shoff value earlier and do not crash.George Rimar2016-10-172-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-174-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-172-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-172-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-172-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
* [Support/ELF/AMDGPU] Add 32-bit lo/hi got and pc relative relocationsKonstantin Zhuravlyov2016-10-141-20/+40
| | | | | | | | | | | | | | Added relocation names: - R_AMDGPU_GOTPCREL32_LO - R_AMDGPU_GOTPCREL32_HI - R_AMDGPU_REL32_LO - R_AMDGPU_REL32_HI AMDGPU isa only supports 32-bit immediates. In order to access 64-bit address we need to generate 32-bit lo/hi relocations, and do the right math (separate patch). Currently we only generate one 32 bit relocation for lower bits for each access, losing higher bits. Hence we need relocations listed above. Differential Revision: https://reviews.llvm.org/D25546 llvm-svn: 284191
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-10-113-0/+6
| | | | | | | | | load commands that uses the MachO::linker_option_command type but not used in llvm libObject code but used in llvm tool code. This includes just LC_LINKER_OPTION load command. llvm-svn: 283939
* Reverted r283740 [Object/ELF] - Do not crash on invalid Header->e_shoff value.George Rimar2016-10-112-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-102-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
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-10-046-0/+15
| | | | | | | | | | | load commands that uses the MachO::encryption_info_command and MachO::encryption_info_command types but not used in llvm libObject code but used in llvm tool code. This includes just LC_ENCRYPTION_INFO and LC_ENCRYPTION_INFO_64 load commands. llvm-svn: 283250
* [Object/ELF] - Do not crash on invalid sh_offset value of REL[A] section.George Rimar2016-10-043-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-042-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
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-09-293-0/+6
| | | | | | | | | load command that uses the MachO::entry_point_command type but not used in llvm libObject code but used in llvm tool code. This includes just the LC_MAIN load command. llvm-svn: 282766
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-09-293-0/+6
| | | | | | | | | load command that uses the Mach::source_version_command type but not used in llvm libObject code but used in llvm tool code. This includes just the LC_SOURCE_VERSION load command. llvm-svn: 282736
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-09-284-0/+9
| | | | | | | | | load command that uses the Mach::rpath_command type but not used in llvm libObject code but used in llvm tool code. This includes just the LC_RPATH load command. llvm-svn: 282649
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-09-283-0/+6
| | | | | | | | | | other load commands that use the Mach::version_min_command type but not used in llvm libObject code but used in llvm tool code. This includes LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, LC_VERSION_MIN_TVOS and LC_VERSION_MIN_WATCHOS load commands. llvm-svn: 282635
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-09-274-0/+9
| | | | | | | | | | other load commands that use the MachO::dylinker_command type but not used in llvm libObject code but used in llvm tool code. This includes LC_ID_DYLINKER, LC_LOAD_DYLINKER and LC_DYLD_ENVIRONMENT load commands. llvm-svn: 282553
* Next set of additional error checks for invalid Mach-O files for theKevin Enderby2016-09-264-0/+9
| | | | | | | | | | other load commands that use the Mach::linkedit_data_command type but not used in llvm libObject code but used in llvm tool code. This includes LC_FUNCTION_STARTS, LC_SEGMENT_SPLIT_INFO and LC_DYLIB_CODE_SIGN_DRS load commands. llvm-svn: 282441
* Next set of additional error checks for invalid Mach-O files for bad LC_UUIDKevin Enderby2016-09-213-0/+6
| | | | | | | load commands. Added a missing check and made the check for more than one like other other “more than one” checks. And of course added test cases. llvm-svn: 282104
* Next set of additional error checks for invalid Mach-O files for bad load ↵Kevin Enderby2016-09-208-0/+21
| | | | | | | | | | | | | | | | commands that use the Mach::dylib_command type for the load commands that are currently used in the MachOObjectFile constructor. This contains the missing checks for LC_ID_DYLIB, LC_ID_DYLIB, etc. load commands and the fields for the Mach::dylib_command type. Also checks that only an MH_DYLIB or MH_STUB_DYLIB has an LC_ID_DYLIB load command (and others filetype don’t) and there is not more than one of these load commands. llvm-svn: 282008
* [IRObjectFile] Handle undefined weak symbols in RecordStreamer.Davide Italiano2016-09-152-0/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D24594 llvm-svn: 281629
* [Stackmap] Added callsite counts to emitted function information.Sanjoy Das2016-09-142-12/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It was previously not possible for tools to use solely the stackmap information emitted to reconstruct the return addresses of callsites in the map, which is necessary to use the information to walk a stack. This patch adds per-function callsite counts when emitting the stackmap section in order to resolve the problem. Note that this slightly alters the stackmap format, so external tools parsing these maps will need to be updated. **Problem Details:** Records only store their offset from the beginning of the function they belong to. While these records and the functions are output in program order, it is not possible to determine where the end of one function's records are without the callsite count when processing the records to compute return addresses. Patch by Kavon Farvardin! Reviewers: atrick, ributzka, sanjoy Subscribers: nemanjai Differential Revision: https://reviews.llvm.org/D23487 llvm-svn: 281532
* Next set of additional error checks for invalid Mach-O files for bad load ↵Kevin Enderby2016-09-1314-0/+38
| | | | | | | | | | | | | commands that use the Mach::dyld_info_command type for the load commands that are currently use in the MachOObjectFile constructor. This contains the missing checks for LC_DYLD_INFO and LC_DYLD_INFO_ONLY load commands and the fields for the Mach::dyld_info_command type. llvm-svn: 281400
* Next set of additional error checks for invalid Mach-O files for bad load ↵Kevin Enderby2016-08-316-0/+16
| | | | | | | | | | | | | | | | | commands that use the Mach::linkedit_data_command type for the load commands that are currently used in the MachOObjectFile constructor. This contains the missing checks for LC_DATA_IN_CODE and LC_LINKER_OPTIMIZATION_HINT load commands and the fields for the Mach::linkedit_data_command type. Checking for other load commands that use this type will be added later. Also fixed a couple of places that was using sizeof(MachOObjectFile::LoadCommandInfo) that should have been using sizeof(MachO::load_command). llvm-svn: 280267
* Add a test file, macho-invalid-dysymtab-extreloff-nextrel,Kevin Enderby2016-08-301-0/+0
| | | | | | I forgot to do an svn add on. llvm-svn: 280167
* Next set of additional error checks for invalid Mach-O files for bad ↵Kevin Enderby2016-08-3015-0/+45
| | | | | | | | LC_DYSYMTAB’s. This contains the missing checks for LC_DYSYMTAB load command fields. llvm-svn: 280161
* Next set of additional error checks for invalid Mach-O files for bad ↵Kevin Enderby2016-08-268-0/+21
| | | | | | | | LC_SYMTAB’s. This contains the missing checks for LC_SYMTAB load command fields. llvm-svn: 279854
* [AMDGPU] llvm-objdump: Skip amd_kernel_code_t only at the begining of kernel ↵Sam Kolton2016-08-171-0/+8
| | | | | | | | | | | | | | symbol. Summary: This change fix bug in AMDGPU disassembly. Previously, presence of symbols other than kernel symbols caused objdump to skip begining of those symbols. Reviewers: tstellarAMD, vpykhtin, Bigcheese, ruiu Subscribers: kzhuravl, arsenm Differential Revision: http://reviews.llvm.org/D21966 llvm-svn: 278921
* Next set of additional error checks for invalid Mach-O files.Kevin Enderby2016-08-1211-0/+30
| | | | | | | | | | This contains the two missing checks for LC_SEGMENT load command fields. And checks for the Mach-O sections fields that would make them invalid. With the new checks, some of the existing malformed file checks now trips one of these instead of the issue it was having before so those tests were adjusted. llvm-svn: 278557
* Add the first of what will be a long line of additional error checks for ↵Kevin Enderby2016-08-052-0/+9
| | | | | | | | | | | | | invalid Mach-O files. This is where an LC_SEGMENT load command has a fileoff field that extends past the end of the file. Also fix llvm-nm and llvm-size to remove the errorToErrorCode() call so error messages are printed. And needed to update a few test cases now that they do print the error messages just a bit differently. llvm-svn: 277845
* RecordStreamer: handle inline asm "lazy_reference" and mark symbols as "used"Mehdi Amini2016-08-031-0/+15
| | | | llvm-svn: 277564
* Add checks to the MachOObjectFile() constructor to make sure load commands sizesKevin Enderby2016-07-071-3/+6
| | | | | | are the correct multiple. llvm-svn: 274798
* Finish cleaning up most of the error handling in libObject’s ↵Kevin Enderby2016-06-282-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MachOUniversalBinary and its clients to use the new llvm::Error model for error handling. Changed getAsArchive() from ErrorOr<...> to Expected<...> so now all interfaces there use the new llvm::Error model for return values. In the two places it had if (!Parent) this is actually a program error so changed from returning errorCodeToError(object_error::parse_failed) to calling report_fatal_error() with a message. In getObjectForArch() added error messages to its two llvm::Error return values instead of returning errorCodeToError(object_error::arch_not_found) with no error message. For the llvm-obdump, llvm-nm and llvm-size clients since the only binary files in Mach-O Universal Binaries that are supported are Mach-O files or archives with Mach-O objects, updated their logic to generate an error when a slice contains something like an ELF binary instead of ignoring it. And added a test case for that. The last error stuff to be cleaned up for libObject’s MachOUniversalBinary is the use of errorOrToExpected(Archive::create(ObjBuffer)) which needs Archive::create() to be changed from ErrorOr<...> to Expected<...> first, which I’ll work on next. llvm-svn: 274079
* Change all but the last ErrorOr<...> use for MachOUniversalBinary to ↵Kevin Enderby2016-06-272-0/+3
| | | | | | | | | | | | | | | Expected<...> to allow a good error message to be produced. I added the one test case that the object file tools could produce an error message. The other two errors can’t be triggered if the input file is passed through sys::fs::identify_magic(). But the malformedError("bad magic number") does get triggered by the logic in llvm-dsymutil when dealing with a normal Mach-O file. The other "File too small ..." error would take a logic error currently to produce and is not tested for. llvm-svn: 273946
* [yaml2obj] Missed updating a few test cases in r273915Chris Bieneman2016-06-272-4/+4
| | | | | | This should fix the broken bots. llvm-svn: 273918
* [yaml2obj] Remove --format option in favor of YAML tagsChris Bieneman2016-06-2734-53/+60
| | | | | | | | | | | | | | | | | | | | | | Summary: Our YAML library's handling of tags isn't perfect, but it is good enough to get rid of the need for the --format argument to yaml2obj. This patch does exactly that. Instead of requiring --format, it infers the format based on the tags found in the object file. The supported tags are: !ELF !COFF !mach-o !fat-mach-o I have a corresponding patch that is quite large that fixes up all the in-tree test cases. Reviewers: rafael, Bigcheese, compnerd, silvas Subscribers: compnerd, llvm-commits Differential Revision: http://reviews.llvm.org/D21711 llvm-svn: 273915
* [IRObjectFile] Propagate .weak attribute correctly for ASM symbols.Davide Italiano2016-06-221-1/+1
| | | | | | | PR: 28256 Differential Revision: http://reviews.llvm.org/D21616 llvm-svn: 273474
* Forgot to svn add one of my test files for the change in r273207.Kevin Enderby2016-06-201-0/+0
| | | | llvm-svn: 273208
* Add support for Darwin’s 64-bit universal files with 64-bit offsets and ↵Kevin Enderby2016-06-202-0/+19
| | | | | | | | | | | | | | | | sizes for the objects. Darwin added support in its Xcode 8.0 tools (released in the beta) for universal files where offsets and sizes for the objects are 64-bits to allow support for objects contained in universal files to be larger then 4gb. The change is very straight forward. There is a new magic number that differs by one bit, much like the 64-bit Mach-O files. Then there is a new structure that follow the fat_header that has the same layout but with the offset and size fields using 64-bit values instead of 32-bit values. rdar://26899493 llvm-svn: 273207
* Support/ELF: Add AMDGPU relocation definitions to match documentationTom Stellard2016-06-171-0/+65
| | | | | | | | | | Reviewers: arsenm, kzhuravl, rafael Subscribers: llvm-commits, kzhuravl Differential Revision: http://reviews.llvm.org/D21443 llvm-svn: 273066
* Add support for Darwin’s static library table of contents with 64-bit ↵Kevin Enderby2016-06-172-0/+6
| | | | | | | | | | | | | | offsets to the archive members. Darwin added support in its Xcode 8.0 tools (released in the beta) for static library table of contents with 64-bit offsets to the archive members. The change is very straight forward. The table of contents member is named ___.SYMDEF_64 or "___.SYMDEF_64 SORTED" and same layout is used but with fields using 64 bit values instead of 32 bit values. rdar://26869808 llvm-svn: 273058
* [IRObjectFile] Handle .weak in RecordStreamer.Davide Italiano2016-06-171-0/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D21476 llvm-svn: 273027
* Remove redundant -mattr options from llvm-objdump commands.Daniel Sanders2016-06-162-4/+0
| | | | | | | | The -mattr options in these four tests have no effect on the output of llvm-objdump. In the case of the two Mips tests, removing the -mattr option left duplicate RUN lines so the duplicates have been removed. llvm-svn: 272906
* [llvm-objdump] Support detection of feature bits from the object and ↵Daniel Sanders2016-06-162-0/+2
| | | | | | | | | | | | | | | | | | | | implement this for Mips. Summary: The Mips implementation only covers the feature bits described by the ELF e_flags so far. Mips stores additional feature bits such as MSA in the .MIPS.abiflags section. Also fixed a small bug this revealed where microMIPS wouldn't add the EF_MIPS_MICROMIPS flag when using -filetype=obj. Reviewers: echristo, rafael Subscribers: rafael, mehdi_amini, dsanders, sdardis, llvm-commits Differential Revision: http://reviews.llvm.org/D21125 llvm-svn: 272880
* [mips] Remove CPU-only triples from llvm-objdump commands.Daniel Sanders2016-06-031-2/+2
| | | | | | | | | | | | Summary: They aren't necessary since llvm-objdump can auto-detect the architecture. Reviewers: sdardis Subscribers: jfb, dsanders, llvm-commits, sdardis Differential Revision: http://reviews.llvm.org/D20904 llvm-svn: 271653
OpenPOWER on IntegriCloud