summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
Commit message (Collapse)AuthorAgeFilesLines
...
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings in ↵Eugene Zelenko2017-02-091-14/+22
| | | | | | | | SubtargetFeature; other minor fixes (NFC). Same changes in files affected by reduced SubtargetFeature.h dependencies. llvm-svn: 294548
* Fix a typo in an error message for a check of invalid Mach-O files whereKevin Enderby2017-02-071-1/+1
| | | | | | | | | | | | it was printing the field name fileoff instead of filesize. The original check was added in r278557. This was found in tracking down the problem that lead to the fix in r293842 - [dsymutil] Fix __LINKEDIT vmsize in dsymutil upgrade path rdar://30386075 llvm-svn: 294354
* [WebAssembly] Add wasm support for llvm-readobjDerek Schuff2017-01-301-5/+6
| | | | | | | | | | | Create a WasmDumper subclass of ObjDumper to support Webassembly binary files. Patch by Sam Clegg Differential Revision: https://reviews.llvm.org/D27355 llvm-svn: 293569
* Fix llvm-objdump so it picks a good CPU based for Mach-O filesKevin Enderby2017-01-241-0/+4
| | | | | | | | | | | for CPU_SUBTYPE_ARM_V7S and CPU_SUBTYPE_ARM_V7K. For these two cpusubtypes they should default to a cortex-a7 CPU to give proper disassembly without a -mcpu= flag. rdar://27431703 llvm-svn: 292993
* Add support for the x86_thread_state32_t andKevin Enderby2017-01-231-1/+20
| | | | | | | | | | | | | in llvm-objdump for Mach-O files add the printing of the x86_thread_state32_t in the same format as otool-classic(1) on darwin. To do this the 32-bit x86 general tread state needed to be defined in include/llvm/Support/MachO.h . rdar://30110111 llvm-svn: 292829
* Add LC_BUILD_VERSION load commandSteven Wu2017-01-231-0/+34
| | | | | | | | | | | | | | | | | | | Summary: Add a new load command LC_BUILD_VERSION. It is a generic version of LC_*_VERSION_MIN load_command used on Apple platforms. Instead of having a seperate load command for each platform, LC_BUILD_VERSION is recording platform info as an enum. It also records SDK version, min_os, and tools that used to build the binary. rdar://problem/29781291 Reviewers: enderby Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29044 llvm-svn: 292824
* Add support for the new LC_NOTE load command.Kevin Enderby2017-01-191-0/+33
| | | | | | | | | | It describes a region of arbitrary data included in a Mach-O file. Its initial use is to record extra data in MH_CORE files. rdar://30001545 rdar://30001731 llvm-svn: 292500
* [ARM] Create SubtargetFeatures from build attrsSam Parker2017-01-181-42/+153
| | | | | | | | | | | An ELFObjectFile can now create SubtargetFeatures from the available ARM build attributes, in a similar manner to MIPS. I've moved the MIPS code into its own function and the ARM handler also has a separate function. Differential Revision: https://reviews.llvm.org/D28291 llvm-svn: 292403
* [ARM] Create objdump subtarget from build attrsSam Parker2017-01-181-0/+67
| | | | | | | | | | | Enable an ELFObjectFile to read the its arm build attributes to produce a target triple with a specific ARM architecture. llvm-objdump now uses this functionality to automatically produce a more accurate target. Differential Revision: https://reviews.llvm.org/D28769 llvm-svn: 292366
* Recommit r292214 "[Support/Compression] - Change zlib API to return Error ↵George Rimar2017-01-171-4/+1
| | | | | | | | | | | | | | | | | | instead of custom status" No any changes, will follow up with D28807 commit containing APLi change for clang to fix build issues happened. Original commit message: [Support/Compression] - Change zlib API to return Error instead of custom status. Previously API returned custom enum values. Patch changes it to return Error with string description. That should help users to report errors in universal way. Differential revision: https://reviews.llvm.org/D28684 llvm-svn: 292226
* Revert r292214 "[Support/Compression] - Change zlib API to return Error ↵George Rimar2017-01-171-1/+4
| | | | | | | | | instead of custom status." It broked clang: http://lab.llvm.org:8080/green//job/clang-stage1-cmake-RA-incremental_build/34218/consoleFull#46141505449ba4694-19c4-4d7e-bec5-911270d8a58c llvm-svn: 292217
* [Support/Compression] - Change zlib API to return Error instead of custom ↵George Rimar2017-01-171-4/+1
| | | | | | | | | | | | status. Previously API returned custom enum values. Patch changes it to return Error with string description. That should help users to report errors in universal way. Differential revision: https://reviews.llvm.org/D28684 llvm-svn: 292214
* Revert r291903 and r291898. Reason: they break check-lld on the bots.Ivan Krasin2017-01-131-65/+0
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Revert [ARM] Fix ubig32_t read in ARMAttributeParser Now using support functions to read data instead of trying to perform casts. =========================================================== Revert [ARM] Enable objdump to construct triple for ARM Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Subscribers: llvm-commits, samparker, aemerson, mgorny Differential Revision: https://reviews.llvm.org/D28683 llvm-svn: 291911
* [ARM] Enable objdump to construct triple for ARMSam Parker2017-01-131-0/+65
| | | | | | | | | | | | | Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Differential Revision: https://reviews.llvm.org/D28281 llvm-svn: 291898
* [lib/Object] Unbreak build with -Werror (unused variable). NFCI.Davide Italiano2017-01-111-1/+1
| | | | llvm-svn: 291691
* [lib/Object] - Introduce Decompressor class.George Rimar2017-01-112-0/+103
| | | | | | | | | | | | | Decompressor intention is to reduce duplication of code. Currently LLD has own implementation of decompressor for compressed debug sections. This class helps to avoid it and share the code. LLD patch for reusing it is D28106 Differential revision: https://reviews.llvm.org/D28105 llvm-svn: 291675
* llvm-objdump: speed up -objc-meta-dataSaleem Abdulrasool2017-01-081-0/+8
| | | | | | | | | | | | | | | | | | Running a Debug build of objdump -objc-meta-data with a large Mach-O file is currently unnecessarily slow. With some local test input, this change reduces the run time from 75-85s down to 15-20s. The two changes are: Assert on pointer equality not array equality Replace vector<pair<address, symbol>> with DenseMap<address, symbol> Additionally, use a std::unique_ptr rather than handling the memory manually. Patch by Dave Lee! llvm-svn: 291398
* [ThinLTO] Optionally ignore empty index fileTeresa Johnson2017-01-061-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In order to simplify distributed build system integration, where actions may be scheduled before the Thin Link which determines the list of objects selected by the linker. The gold plugin currently will emit 0-sized index files for objects not selected by the link, to enable checking for expected output files by the build system. If the build system then schedules a backend action for these bitcode files, we want to be able to fall back to normal compilation instead of failing. This is the LLVM side support for optionally enabling fallback instead of issuing an error. Return a null CombinedIndex from llvm::getModuleSummaryIndexForFile under the option when the file is empty. Clang can then ignore the index when it is null. Clang patch is D28362. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28410 llvm-svn: 291302
* Fix a bugs with using some Mach-O command line flags like "-arch armv7m".Kevin Enderby2016-12-162-2/+37
| | | | | | | | | | | | | | | | | | The Mach-O command line flag like "-arch armv7m" does not match the arch name part of its llvm Triple which is "thumbv7m-apple-darwin”. I think the best way to fix this is to have llvm::object::MachOObjectFile::getArchTriple() optionally return the name of the Mach-O arch flag that would be used with -arch that matches the CPUType and CPUSubType. Then change llvm::object::MachOUniversalBinary::ObjectForArch::getArchTypeName() to use that and change it to getArchFlagName() as the type name is really part of the Triple and the -arch flag name is a Mach-O thing for a specific Triple with a specific Mcpu value. rdar://29663637 llvm-svn: 290001
* [ThinLTO] Import composite types as declarationsTeresa Johnson2016-12-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: When reading the metadata bitcode, create a type declaration when possible for composite types when we are importing. Doing this in the bitcode reader saves memory. Also it works naturally in the case when the type ODR map contains a definition for the same composite type because it was used in the importing module (buildODRType will automatically use the existing definition and not create a type declaration). For Chromium built with -g2, this reduces the aggregate size of the generated native object files by 66% (from 31G to 10G). It reduced the time through the ThinLTO link and backend phases by about 20% on my machine. Reviewers: mehdi_amini, dblaikie, aprantl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27775 llvm-svn: 289993
* Object: Make IRObjectFile own multiple modules and enumerate symbols from ↵Peter Collingbourne2016-12-131-13/+26
| | | | | | | | | | all modules. This implements multi-module support in IRObjectFile. Differential Revision: https://reviews.llvm.org/D26951 llvm-svn: 289578
* Object: Remove module accessors from IRObjectFile, and hide its constructor.Peter Collingbourne2016-12-131-7/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D27079 llvm-svn: 289577
* [Object][MachO] Reference-ify some helper function arguments. NFC.Lang Hames2016-12-041-201/+200
| | | | | | | Changes all static helper functions in MachOObjectFile.cpp that expect a non-null MachOObjectFile pointer to take a reference instead. llvm-svn: 288608
* Remove iostream include from WasmObjectFilePavel Labath2016-12-011-2/+0
| | | | | | | The file does not seems to use c++ iostreams (and is is llvm policy to avoid that). Committing as obvious. llvm-svn: 288364
* Object: Set SF_Indirect in ModuleSymbolTable.Peter Collingbourne2016-12-011-0/+2
| | | | | | | | This lets us remove the last use of IRObjectFile::getSymbolGV() in llvm-nm. Differential Revision: https://reviews.llvm.org/D27076 llvm-svn: 288321
* Object: Add SF_Executable symbol flag.Peter Collingbourne2016-12-011-1/+4
| | | | | | | | | | | | This allows us to remove a few uses of IRObjectFile::getSymbolGV() in llvm-nm. While here change host-dependent logic in llvm-nm to target-dependent logic. Differential Revision: https://reviews.llvm.org/D27075 llvm-svn: 288320
* Object: Extract a ModuleSymbolTable class from IRObjectFile.Peter Collingbourne2016-12-013-144/+195
| | | | | | | | | | | | This class represents a symbol table built from in-memory IR. It provides access to GlobalValues and should only be used if such access is required (e.g. in the LTO implementation). We will eventually change IRObjectFile to read from a bitcode symbol table rather than using ModuleSymbolTable, so it would not be able to expose the module. Differential Revision: https://reviews.llvm.org/D27073 llvm-svn: 288319
* Only computeRelativePath() on new membersDavid Callahan2016-11-301-3/+8
| | | | | | | | | | | | | | | Summary: When using thin archives, and processing the same archive multiple times, we were mangling existing entries. The root cause is that we were calling computeRelativePath() more than once. Here, we only call it when adding new members to an archive. Note that D27218 changes the way thin archives are printed, and will break the new unit test included here. Depending on which one lands first, the other will need to be slightly modified. Reviewers: rafael, davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27217 llvm-svn: 288280
* [WebAssembly] Add llvm-objdump support for wasm file formatDerek Schuff2016-11-305-1/+322
| | | | | | | | | | | This is the first part of an effort to add wasm binary support across all llvm tools. Patch by Sam Clegg Differential Revision: https://reviews.llvm.org/D26172 llvm-svn: 288251
* Add error checking for Mach-O universal files.Kevin Enderby2016-11-281-6/+67
| | | | | | | | | | | | Add the checking for both the MachO::fat_header and the MachO::fat_arch struct values in the constructor for MachOUniversalBinary. Such that when the constructor for ObjectForArch is called it can assume the values in the MachO::fat_arch for the offset and size are contained in the file after the MachOUniversalBinary constructor is called for the Parent. llvm-svn: 288084
* Object: Add IRObjectFile::getTargetTriple().Peter Collingbourne2016-11-241-0/+2
| | | | | | | | This lets us remove a use of IRObjectFile::getModule() in llvm-nm. Differential Revision: https://reviews.llvm.org/D27074 llvm-svn: 287846
* Object: Simplify the IRObjectFile symbol iterator implementation.Peter Collingbourne2016-11-241-89/+25
| | | | | | | | | | | | | | Change the IRObjectFile symbol iterator to be a pointer into a vector of PointerUnions representing either IR symbols or asm symbols. This change is in preparation for a future change for supporting multiple modules in an IRObjectFile. Although it causes an increase in memory consumption, we can deal with that issue separately by introducing a bitcode symbol table. Differential Revision: https://reviews.llvm.org/D26928 llvm-svn: 287845
* Object: Make SymbolicFile::symbol_{begin,end}() virtual and remove ↵Peter Collingbourne2016-11-223-6/+6
| | | | | | unnecessary wrappers. llvm-svn: 287611
* Object: Simplify; remove unnecessary use of unique_ptr.Peter Collingbourne2016-11-181-4/+4
| | | | llvm-svn: 287305
* Object: replace backslashes with slashes in embedded relative thin archive ↵Peter Collingbourne2016-11-151-0/+6
| | | | | | | | | | paths on Windows. This makes these thin archives portable between *nix and Windows. Differential Revision: https://reviews.llvm.org/D26696 llvm-svn: 287038
* Fix llvm-symbolizer to correctly sort a symbol array and calculate symbol sizesKuba Brecka2016-11-151-12/+6
| | | | | | | | Sometimes, llvm-symbolizer gives wrong results due to incorrect sizes of some symbols. The reason for that was an incorrectly sorted array in computeSymbolSizes. The comparison function used subtraction of unsigned types, which is incorrect. Let's change this to return explicit -1 or 1. Differential Revision: https://reviews.llvm.org/D26537 llvm-svn: 287028
* Fix -Wswitch.Rui Ueyama2016-11-152-0/+2
| | | | llvm-svn: 286920
* Add a file magic for CL.exe's object file created with /GL.Rui Ueyama2016-11-151-0/+1
| | | | | | | | | | | | This patch makes it possible to identify object files created by CL.exe with /GL option. Such file contains Microsoft proprietary intermediate code instead of target machine code to do LTO. I need this to print out user-friendly error message from LLD. Differential Revision: https://reviews.llvm.org/D26645 llvm-svn: 286919
* Add a checkSymbolTable() method to the MachOObjectFile class.Kevin Enderby2016-11-141-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The philosophy of the error checking in libObject for Mach-O files is that the constructor will check the load commands so for their tables the offsets and sizes are properly contained in the file. But there is no checking of the entries of any of the tables. For the contents of the tables themselves the methods accessing the contents of the entries return errors as needed. In some cases this however makes it difficult or cumbersome to produce a good error message which would include the tool name, file name, archive member, and name of the architecture of a slice of a universal file the error occurred in. So idea is that there will be a method to check a table which can be called up front before using it allowing a good error message to be produced before a table is used. And if only verification of the Mach-O file and its tables are wanted a new possible method checkAllTables() could be added to call all of the methods to check all the tables at some time when such methods exist. The checkSymbolTable() is the first of such methods to check one of the Mach-O file tables. This method initially will used in llvm-objdump’s DisassembleMachO() routine before it gets the section and symbol information. As if there are problems with the symbol table currently the error is first encountered by the bool operator() in the SymbolSorter() struct which passed to std::sort(). In this case there is no context as to the file name the symbol which results a poor error message: LLVM ERROR: truncated or malformed object (bad string index: 22 for symbol at index 1) with the added call to the checkSymbolTable() method the error message includes the tool name and file name: llvm-objdump: 'macho-invalid-symbol-strx': truncated or malformed object (bad string table index: 22 past the end of string table, for symbol at index 1) llvm-svn: 286887
* Restore "[ThinLTO] Prevent exporting of locals used/defined in module level asm"Teresa Johnson2016-11-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This restores the rest of r286297 (part was restored in r286475). Specifically, it restores the part requiring adding a dependency from the Analysis to Object library (downstream use changed to correctly model split BitReader vs BitWriter libraries). Original description of this part of patch follows: Module level asm may also contain defs of values. We need to prevent export of any refs to local values defined in module level asm (e.g. a ref in normal IR), since that also requires renaming/promotion of the local. To do that, the summary index builder looks at all values in the module level asm string that are not marked Weak or Global, which is exactly the set of locals that are defined. A summary is created for each of these local defs and flagged as NoRename. This required adding handling to the BitcodeWriter to look at GV declarations to see if they have a summary (rather than skipping them all). Finally, added an assert to IRObjectFile::CollectAsmUndefinedRefs to ensure that an MCAsmParser is available, otherwise the module asm parse would silently fail. Initialized the asm parser in the opt tool for use in testing this fix. Fixes PR30610. llvm-svn: 286844
* Bitcode: Change module reader functions to return an llvm::Expected.Peter Collingbourne2016-11-132-9/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D26562 llvm-svn: 286752
* Fix -Wpessimizing-move warning.Rui Ueyama2016-11-111-1/+1
| | | | llvm-svn: 286629
* Bitcode: Change getModuleSummaryIndex() to return an llvm::Expected.Peter Collingbourne2016-11-111-22/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D26539 llvm-svn: 286624
* Bitcode: Clean up error handling for certain bitcode query functions.Peter Collingbourne2016-11-111-12/+0
| | | | | | | | | | | | | The functions getBitcodeTargetTriple(), isBitcodeContainingObjCCategory(), getBitcodeProducerString() and hasGlobalValueSummary() now return errors via their return value rather than via the diagnostic handler. To make this work, re-implement these functions using non-member functions so that they can be used without the LLVMContext required by BitcodeReader. Differential Revision: https://reviews.llvm.org/D26532 llvm-svn: 286623
* Split Bitcode/ReaderWriter.h into separate reader and writer headersTeresa Johnson2016-11-112-2/+2
| | | | | | | | | | | | | | | | | | | | | Summary: Split ReaderWriter.h which contains the APIs into both the BitReader and BitWriter libraries into BitcodeReader.h and BitcodeWriter.h. This is to address Chandler's concern about sharing the same API header between multiple libraries (BitReader and BitWriter). That concern is why we create a single bitcode library in our downstream build of clang, which led to r286297 being reverted as it added a dependency that created a cycle only when there is a single bitcode library (not two as in upstream). Reviewers: mehdi_amini Subscribers: dlj, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D26502 llvm-svn: 286566
* Make the Error class constructor protectedMehdi Amini2016-11-114-16/+15
| | | | | | | | | This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 llvm-svn: 286561
* [lli] Simplify the code a bit. No functional change intended.Davide Italiano2016-11-111-3/+1
| | | | llvm-svn: 286555
* Revert "[ThinLTO] Prevent exporting of locals used/defined in module level asm"Mehdi Amini2016-11-091-1/+2
| | | | | | | | This reverts commit r286297. Introduces a dependency from libAnalysis to libObject, which I missed during the review. llvm-svn: 286329
* [ThinLTO] Prevent exporting of locals used/defined in module level asmTeresa Johnson2016-11-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch uses the same approach added for inline asm in r285513 to similarly prevent promotion/renaming of locals used or defined in module level asm. All static global values defined in normal IR and used in module level asm should be included on either the llvm.used or llvm.compiler.used global. The former were already being flagged as NoRename in the summary, and I've simply added llvm.compiler.used values to this handling. Module level asm may also contain defs of values. We need to prevent export of any refs to local values defined in module level asm (e.g. a ref in normal IR), since that also requires renaming/promotion of the local. To do that, the summary index builder looks at all values in the module level asm string that are not marked Weak or Global, which is exactly the set of locals that are defined. A summary is created for each of these local defs and flagged as NoRename. This required adding handling to the BitcodeWriter to look at GV declarations to see if they have a summary (rather than skipping them all). Finally, added an assert to IRObjectFile::CollectAsmUndefinedRefs to ensure that an MCAsmParser is available, otherwise the module asm parse would silently fail. Initialized the asm parser in the opt tool for use in testing this fix. Fixes PR30610. Reviewers: mehdi_amini Subscribers: johanengelen, krasin, llvm-commits Differential Revision: https://reviews.llvm.org/D26146 llvm-svn: 286297
* IR, Bitcode: Change bitcode reader to no longer own its memory buffer.Peter Collingbourne2016-11-081-4/+1
| | | | | | | | | | | | | | | | | | Unique ownership is just one possible ownership pattern for the memory buffer underlying the bitcode reader. In practice, as this patch shows, ownership can often reside at a higher level. With the upcoming change to allow multiple modules in a single bitcode file, it will no longer be appropriate for modules to generally have unique ownership of their memory buffer. The C API exposes the ownership relation via the LLVMGetBitcodeModuleInContext and LLVMGetBitcodeModuleInContext2 functions, so we still need some way for the module to own the memory buffer. This patch does so by adding an owned memory buffer field to Module, and using it in a few other places where it is convenient. Differential Revision: https://reviews.llvm.org/D26384 llvm-svn: 286214
OpenPOWER on IntegriCloud