summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
Commit message (Collapse)AuthorAgeFilesLines
* Reapply r250906 with many suggested updates from Rafael Espindola.Kevin Enderby2015-11-052-48/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The needed lld matching changes to be submitted immediately next, but this revision will cause lld failures with this alone which is expected. This removes the eating of the error in Archive::Child::getSize() when the characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. These changes will require corresponding changes to the lld project. That will be committed immediately after this change. But this revision will cause lld failures with this alone which is expected. llvm-svn: 252192
* [ELF] elfiamcu triple should imply e_machine == EM_IAMCUMichael Kuperstein2015-11-042-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D14109 llvm-svn: 252043
* This never returns end(), simplify to use Child instead of iterator. NFC.Rafael Espindola2015-11-031-3/+2
| | | | llvm-svn: 251876
* Restore "Support for ThinLTO function importing and symbol linking."Teresa Johnson2015-11-031-5/+4
| | | | | | | This restores commit r251837, with the new library dependence added to llvm-link/Makefile to address bot failures. llvm-svn: 251866
* Revert "Support for ThinLTO function importing and symbol linking."Teresa Johnson2015-11-021-4/+5
| | | | | | | | | | | | | | | | | | | | This reverts commit r251837, due to a number of bot failures of the form: /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.obj/tools/llvm-link/Release+Asserts/llvm-link.o:llvm-link.cpp:function loadIndex(llvm::LLVMContext&, llvm::Module const*): error: undefined reference to 'llvm::object::FunctionIndexObjectFile::create(llvm::MemoryBufferRef, llvm::LLVMContext&, llvm::Module const*, bool)' /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.obj/tools/llvm-link/Release+Asserts/llvm-link.o:llvm-link.cpp:function loadIndex(llvm::LLVMContext&, llvm::Module const*): error: undefined reference to 'llvm::object::FunctionIndexObjectFile::takeIndex()' I'm not sure why these are happening - I added Object to the requred libraries in tools/llvm-link/LLVMBuild.txt and the LLVM_LINK_COMPONENTS in tools/llvm-link/CMakeLists.txt. Confirmed for my build that these symbols come out of libLLVMObject.a. What am I missing? llvm-svn: 251841
* Support for ThinLTO function importing and symbol linking.Teresa Johnson2015-11-021-5/+4
| | | | | | | | | | | | | | | | | | | | | Summary: Support for necessary linkage changes and symbol renaming during ThinLTO function importing. Also includes llvm-link support for manually importing functions and associated llvm-link based tests. Note that this does not include support for intelligently importing metadata, which is currently imported duplicate times. That support will be in the follow-on patch, and currently is ignored by the tests. Reviewers: dexonsmith, joker.eph, davidxl Subscribers: tobiasvk, tejohnson, llvm-commits Differential Revision: http://reviews.llvm.org/D13515 llvm-svn: 251837
* Clang format a few prior patches (NFC)Teresa Johnson2015-11-021-28/+35
| | | | | | | I had clang formatted my earlier patches using the wrong style. Reformatted with the LLVM style. llvm-svn: 251812
* Avoid implicitly constructing a Archive::child_iterator.Rafael Espindola2015-11-021-10/+10
| | | | llvm-svn: 251794
* Use Child instead of child_iterator in the archive writer.Rafael Espindola2015-11-011-5/+5
| | | | | | | We never need to pass end(). This will also remove some complication once we start adding error checking. llvm-svn: 251758
* Don't store a Child to the first regular member.Rafael Espindola2015-10-311-8/+17
| | | | | | | | | | This is a bit ugly, but has a few advantages: * Archive is now easy to copy since there is no Archive -> Child -> Archive loop. * It makes it clear that we already checked for errors when finding the Child data. llvm-svn: 251750
* Simplify handling of archive Symbol tables.Rafael Espindola2015-10-311-9/+14
| | | | | | We only need to store a StringRef. llvm-svn: 251748
* Simplify the handling of the archive string table.Rafael Espindola2015-10-311-12/+10
| | | | | | We only need to store a StringRef llvm-svn: 251746
* [AVR] Add ELF constants to headersDylan McKay2015-10-231-0/+19
| | | | | | | | Also adds a 'trivial' ELF file. This was generated by assembling and linking a file with the symbol main which contains a single return instruction. llvm-svn: 251096
* Backing out commit r250906 as it broke lld.Kevin Enderby2015-10-212-117/+44
| | | | llvm-svn: 250908
* This removes the eating of the error in Archive::Child::getSize() when the ↵Kevin Enderby2015-10-212-44/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. Also corrected the code where the size gets us to the “at the end of the archive” which is OK but past the end of the archive will return object_error::parse_failed now. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. llvm-svn: 250906
* Tweak to r250117 and change to use ErrorOr and drop isSizeValid forKevin Enderby2015-10-131-17/+12
| | | | | | | | | | ArchiveMemberHeader, suggestion by Rafael Espíndola. Also The clang-x86-win2008-selfhost bot still does not like the malformed-machos 00000031.a test, so removing it for now. All the other bots are fine with it however. llvm-svn: 250222
* Fixed bugs in llvm-obdump while parsing Mach-O files from malformed archivesKevin Enderby2015-10-121-0/+12
| | | | | | | | | that caused aborts. This was because of the characters of the ‘Size’ field in the archive header did not contain decimal characters. rdar://22983603 llvm-svn: 250117
* Address review comments, remove error case and return 0 instead as required ↵Reid Kleckner2015-10-091-7/+8
| | | | | | by tests llvm-svn: 249785
* [llvm-symbolizer] Make --relative-address work with DWARF contextsReid Kleckner2015-10-091-10/+11
| | | | | | | | | | | | | | | | Summary: Previously the relative address flag only affected PDB debug info. Now both DIContext implementations always expect to be passed virtual addresses. llvm-symbolizer is now responsible for adding ImageBase to module offsets when --relative-offset is passed. Reviewers: zturner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12883 llvm-svn: 249784
* Fix a bug in llvm-objdump’s printing of Objective-C meta dataKevin Enderby2015-10-081-3/+26
| | | | | | | | | from malformed Mach-O files that caused a crash because of a section header had a size that extended past the end of the file. rdar://22983603 llvm-svn: 249768
* Handle Archive::getNumberOfSymbols being called in an archive with no symbols.Rafael Espindola2015-10-081-2/+2
| | | | | | No change in llvm, but will be tested from lld. llvm-svn: 249709
* Support for function summary index bitcode sections and files.Teresa Johnson2015-10-042-0/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The bitcode format is described in this document: https://drive.google.com/file/d/0B036uwnWM6RWdnBLakxmeDdOeXc/view For more info on ThinLTO see: https://sites.google.com/site/llvmthinlto The first customer is ThinLTO, however the data structures are designed and named more generally based on prior feedback. There are a few comments regarding how certain interfaces are used by ThinLTO, and the options added here to gold currently have ThinLTO-specific names as the behavior they provoke is currently ThinLTO-specific. This patch includes support for generating per-module function indexes, the combined index file via the gold plugin, and several tests (more are included with the associated clang patch D11908). Reviewers: dexonsmith, davidxl, joker.eph Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13107 llvm-svn: 249270
* Prune trailing whitespaces.NAKAMURA Takumi2015-09-221-10/+10
| | | | llvm-svn: 248265
* Untabify.NAKAMURA Takumi2015-09-222-3/+2
| | | | llvm-svn: 248264
* Reformat blank lines.NAKAMURA Takumi2015-09-221-3/+0
| | | | llvm-svn: 248263
* Reformat comment lines.NAKAMURA Takumi2015-09-221-2/+2
| | | | llvm-svn: 248262
* Reformat.NAKAMURA Takumi2015-09-221-30/+27
| | | | llvm-svn: 248261
* Use makeArrayRef or None to avoid unnecessarily mentioning the ArrayRef type ↵Craig Topper2015-09-211-12/+12
| | | | | | extra times. NFC llvm-svn: 248140
* Re-apply r246276 - Object: Teach llvm-ar to create symbol table for COFF ↵Rui Ueyama2015-08-281-1/+4
| | | | | | | | | | | short import files This patch includes a fix for a llvm-readobj test. With this patch, the tool does no longer print out COFF headers for the short import file, but that's probably desirable because the header for the short import file is dummy. llvm-svn: 246283
* Rollback r246276 - Object: Teach llvm-ar to create symbol table for COFF ↵Rui Ueyama2015-08-281-46/+1
| | | | | | | | short import files This change caused a test for llvm-readobj to fail. llvm-svn: 246277
* Object: Teach llvm-ar to create symbol table for COFF short import files.Rui Ueyama2015-08-281-1/+46
| | | | | | | | | | | | | COFF short import files are special kind of files that contains only DLL-exported symbol names. That's different from object files because it has no data except symbol names. This change implements a SymbolicFile interface for the short import files so that symbol names can be accessed through that interface. llvm-ar is now able to read the file and create symbol table entries for short import files. llvm-svn: 246276
* [MachO] Move trivial accessors to header.Davide Italiano2015-08-251-18/+0
| | | | | | Requested by: Jim Grosbach. llvm-svn: 245963
* [MachO] Introduce MinVersion API.Davide Italiano2015-08-251-0/+18
| | | | | | | | | | | | | While introducing support for MinVersionLoadCommand in llvm-readobj I noticed there's no API to extract Major/Minor/Update components conveniently. Currently consumers do the bit twiddling on their own, but this will change from now on. I'll convert llvm-objdump (and llvm-readobj) in a later commit. Differential Revision: http://reviews.llvm.org/D12282 Reviewed by: rafael llvm-svn: 245938
* Convert getSymbolSection to return an ErrorOr.Rafael Espindola2015-08-074-31/+25
| | | | | | | This function can actually fail since the symbol contains an index to the section and that can be invalid. llvm-svn: 244375
* Add dynamic_table iterators back to ELF.h.Rafael Espindola2015-08-071-0/+2
| | | | | | | | | In tree they are only used by llvm-readobj, but it is also used by https://github.com/mono/CppSharp. While at it, add some missing error checking. llvm-svn: 244320
* COFF: Assign the correct symbol type to internal functions.Peter Collingbourne2015-08-061-2/+2
| | | | | | | | | | | The COFFSymbolRef::isFunctionDefinition() function tests for several conditions that are not related to whether a symbol is a function, but rather whether the symbol meets the requirements for a function definition auxiliary record, which excludes certain symbols such as internal functions and undefined references. The test we need to determine the symbol type is much simpler: we only need to compare the complex type against IMAGE_SYM_DTYPE_FUNCTION. llvm-svn: 244195
* Use early return NFC.Frederic Riss2015-08-031-8/+8
| | | | llvm-svn: 243863
* [COFF] Consider the ImageBase when reporting section addressesDavid Majnemer2015-07-311-2/+10
| | | | | | This lets us reenable the lld test disabled in r243758. llvm-svn: 243761
* [COFF] Return symbol VAs instead of RVAs for PE filesReid Kleckner2015-07-311-0/+8
| | | | | | | | This makes llvm-nm consistent with binutils nm on executables and DLLs. For a vanilla hello world executable, the address of main should include the default image base of 0x400000. llvm-svn: 243755
* ELFYAML: Enable parsing of EM_AMDGPUTom Stellard2015-07-311-0/+1
| | | | | | | | Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11263 llvm-svn: 243724
* [COFF] Add IMAGE_SCN_TYPE_NOLOAD to SectionCharacteristicsDavid Majnemer2015-07-301-0/+1
| | | | llvm-svn: 243658
* Summary:Martell Malone2015-07-282-0/+5
| | | | | | | | | | | | | | | | Object: add IMAGE_FILE_MACHINE_ARM64 The official specifications state that the value of IMAGE_FILE_MACHINE_ARM64 is 0xAA64 (as per the Microsoft Portable Executable and Common Object Format Specification v8.3). Reviewers: rnk Subscribers: llvm-commits, compnerd, ruiu Differential Revision: http://reviews.llvm.org/D11511 llvm-svn: 243434
* Fix fetching the symbol table of a thin archive.Rafael Espindola2015-07-221-6/+11
| | | | | | We were trying to read it as an external file. llvm-svn: 242926
* Fix handling of relative paths in thin archives.Rafael Espindola2015-07-161-3/+32
| | | | | | The member has to end up with a path relative to the archive. llvm-svn: 242362
* llvm-ar: Don't write the directory in the string table.Rafael Espindola2015-07-151-1/+1
| | | | | | | We were already doing the right thing for short file names, but not long ones. llvm-svn: 242354
* Silence GCC -Wparenthesis warningDavid Majnemer2015-07-151-3/+2
| | | | llvm-svn: 242348
* For new archive member we only need to store the full path.Rafael Espindola2015-07-151-4/+4
| | | | | | | We were storing both the path and the file name, which was redundant and easy to get confused up with. llvm-svn: 242347
* Simplify a few uses of remove_filename by using parent_path instead.Rafael Espindola2015-07-151-3/+2
| | | | llvm-svn: 242334
* Handle the error of trying to convert a regular archive to a thin one.Rafael Espindola2015-07-151-0/+3
| | | | | | While at it, test that we can add to a thin archive. llvm-svn: 242330
* Initial support for writing thin archives.Rafael Espindola2015-07-151-13/+24
| | | | llvm-svn: 242269
OpenPOWER on IntegriCloud