summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Binary.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Object: Handle Mach-O kext bundle filesJustin Bogner2015-02-251-0/+1
| | | | | | This particular subtype of Mach-O was missing. Add it. llvm-svn: 230567
* Support ELF files of unknown type.Michael J. Spencer2014-11-181-0/+1
| | | | llvm-svn: 222208
* unique_ptrify MachOUniversalBinary::createDavid Blaikie2014-09-031-2/+1
| | | | llvm-svn: 217052
* Ensure ErrorOr cannot implicitly invoke explicit ctors of the underlying type.David Blaikie2014-09-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | An unpleasant surprise while migrating unique_ptrs (see changes in lib/Object): ErrorOr<int*> was implicitly convertible to ErrorOr<std::unique_ptr<int>>. Keep the explicit conversions otherwise it's a pain to convert ErrorOr<int*> to ErrorOr<std::unique_ptr<int>>. I'm not sure if there should be more SFINAE on those explicit ctors (I could check if !is_convertible && is_constructible, but since the ctor has to be called explicitly I don't think there's any need to disable them when !is_constructible - they'll just fail anyway. It's the converting ctors that can create interesting ambiguities without proper SFINAE). I had to SFINAE the explicit ones because otherwise they'd be ambiguous with the implicit ones in an explicit context, so far as I could tell. The converting assignment operators seemed unnecessary (and similarly buggy/dangerous) - just rely on the converting ctors to convert to the right type for assignment instead. llvm-svn: 217048
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries (like Archive) and we had to create dummy buffers just to handle that. It is also a bad fit for IRObjectFile where the Module wants to own the buffer too. Keeping this ownership would make supporting IR inside native objects particularly painful. This patch focuses in lib/Object. If something elsewhere used to own an Binary, now it also owns a MemoryBuffer. This patch introduces a few new types. * MemoryBufferRef. This is just a pair of StringRefs for the data and name. This is to MemoryBuffer as StringRef is to std::string. * OwningBinary. A combination of Binary and a MemoryBuffer. This is needed for convenience functions that take a filename and return both the buffer and the Binary using that buffer. The C api now uses OwningBinary to avoid any change in semantics. I will start a new thread to see if we want to change it and how. llvm-svn: 216002
* Use std::unique_ptr to make the ownership explicit.Rafael Espindola2014-07-311-3/+4
| | | | llvm-svn: 214377
* Correct the ownership passing semantics of object::createBinary and make ↵David Blaikie2014-07-211-2/+2
| | | | | | | | | | | | | | | | them explicit in the type system. createBinary documented that it destroyed the parameter in error cases, though by observation it does not. By passing the unique_ptr by value rather than lvalue reference, callers are now explicit about passing ownership and the function implements the documented contract. Remove the explicit documentation, since now the behavior cannot be anything other than what was documented, so it's redundant. Also drops a unique_ptr::release in llvm-nm that was always run on a null unique_ptr anyway. llvm-svn: 213557
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-3/+4
| | | | llvm-svn: 212405
* Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.Rafael Espindola2014-06-241-4/+4
| | | | | | | Once the objects are constructed, they own the buffer. Passing a unique_ptr makes that clear. llvm-svn: 211595
* Pass a std::unique_ptr& to the create??? methods is lib/Object.Rafael Espindola2014-06-231-4/+4
| | | | | | | | This makes the buffer ownership on error conditions very natural. The buffer is only moved out of the argument if an object is constructed that now owns the buffer. llvm-svn: 211546
* Make ObjectFile and BitcodeReader always own the MemoryBuffer.Rafael Espindola2014-06-231-13/+8
| | | | | | | | | | This allows us to just use a std::unique_ptr to store the pointer to the buffer. The flip side is that they have to support releasing the buffer back to the caller. Overall this looks like a more efficient and less brittle api. llvm-svn: 211542
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-1/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-2/+2
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* [C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles2014-03-051-4/+4
| | | | llvm-svn: 202957
* Add a SymbolicFile interface between Binary and ObjectFile.Rafael Espindola2014-02-211-5/+5
| | | | | | | | | | | This interface allows IRObjectFile to be implemented without having dummy methods for all section and segment related methods. Both llvm-ar and llvm-nm are changed to use it. Unfortunately the mangler is still not plugged in since it requires some refactoring to make a Module hold a DataLayout. llvm-svn: 201881
* Make createObjectFile's signature a bit less error prone.Rafael Espindola2014-01-291-1/+1
| | | | | | | This will be better with c++11, but right now file_magic converts to bool, which makes the api really easy to misuse. llvm-svn: 200357
* Make ObjectFile ownership of the MemoryBuffer optional.Rafael Espindola2014-01-241-4/+4
| | | | | | This allows llvm-ar to mmap the input files only once. llvm-svn: 200040
* Pass the computed magic to createBinary and createObjectFile if available.Rafael Espindola2014-01-221-10/+10
| | | | | | | identify_magic is not free, so we should avoid calling it twice. The argument also makes it cheap for createBinary to just forward to createObjectFile. llvm-svn: 199813
* Be a bit more consistent about using ErrorOr when constructing Binary objects.Rafael Espindola2014-01-211-35/+10
| | | | | | | | | | | | | | | | | | | | | | | The constructors of classes deriving from Binary normally take an error_code as an argument to the constructor. My original intent was to change them to have a trivial constructor and move the initial parsing logic to a static method returning an ErrorOr. I changed my mind because: * A constructor with an error_code out parameter is extremely convenient from the implementation side. We can incrementally construct the object and give up when we find an error. * It is very efficient when constructing on the stack or when there is no error. The only inefficient case is where heap allocating and an error is found (we have to free the memory). The result is that this is a much smaller patch. It just standardizes the create* helpers to return an ErrorOr. Almost no functionality change: The only difference is that this found that we were trying to read past the end of COFF import library but ignoring the error. llvm-svn: 199770
* Return an ErrorOr<Binary *> from createBinary.Rafael Espindola2014-01-151-31/+25
| | | | | | | | I did write a version returning ErrorOr<OwningPtr<Binary> >, but it is too cumbersome to use without std::move. I will keep the patch locally and submit when we switch to c++11. llvm-svn: 199326
* Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth2014-01-071-1/+1
| | | | | | | | | | subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. llvm-svn: 198685
* Path: Recognize COFF import library file magic.Rui Ueyama2013-11-151-0/+1
| | | | | | | | | | | | Summary: Make identify_magic to recognize COFF import file. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2165 llvm-svn: 194852
* Path: Recognize Windows compiled resource file.Rui Ueyama2013-10-151-1/+2
| | | | | | | | | | | | | | Some background: One can pass compiled resource files (.res files) directly to the linker on Windows. If a resource file is given, the linker will run "cvtres" command in background to convert the resource file to a COFF file to link it. What I'm trying to do with this patch is to make the linker to recognize the resource file by file magic, so that it can run cvtres command. Differential Revision: http://llvm-reviews.chandlerc.com/D1943 llvm-svn: 192742
* Make a switch in createBinary fully-covered. Add forgotten ↵Alexey Samsonov2013-06-281-2/+7
| | | | | | macho_dsym_companion case. llvm-svn: 185139
* Basic support for parsing Mach-O universal binaries in LLVMObject libraryAlexey Samsonov2013-06-181-0/+7
| | | | llvm-svn: 184191
* readobj: Dump PE/COFF optional records.Rui Ueyama2013-06-121-2/+4
| | | | | | | | | | | | These records are mandatory for executables and are used by the loader. Reviewers: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D939 llvm-svn: 183852
* Convert a use of sys::identifyFileType to sys::fs::identify_magic.Rafael Espindola2013-06-111-16/+18
| | | | | | No functionality change. llvm-svn: 183745
* Pass a StringRef to sys::identifyFileType.Rafael Espindola2013-06-101-2/+1
| | | | llvm-svn: 183669
* Don't artifically restrict input object size.Sean Silva2013-06-081-2/+0
| | | | | | | | sys::IdentifyFileType is already conscious of the length, and object_error::invalid_file_type is returned below anyway if sys::IdentifyFileType doesn't recognize the file. llvm-svn: 183605
* Object: Add support for opening stdin.Michael J. Spencer2011-10-081-1/+1
| | | | llvm-svn: 141449
* Object: Add archive support.Michael J. Spencer2011-09-271-1/+8
| | | | llvm-svn: 140626
* Make Binary the parent of ObjectFile and update children to new interface.Michael J. Spencer2011-06-251-3/+49
| | | | llvm-svn: 133870
* Add Binary class. This is a cleaner parent than ObjectFile.Michael J. Spencer2011-06-251-0/+50
| | | | llvm-svn: 133869
* Revert r132910 and r132909 on behalf of Michael. They didn't build with clang.Benjamin Kramer2011-06-131-50/+0
| | | | llvm-svn: 132914
* Revert the last two commits in the series. r132911, r132912.Michael J. Spencer2011-06-131-49/+3
| | | | llvm-svn: 132913
* Make Binary the parent of ObjectFile and update children to new interface.Michael J. Spencer2011-06-131-3/+49
| | | | llvm-svn: 132911
* Add Binary class. This is a cleaner parent than ObjectFile.Michael J. Spencer2011-06-131-0/+50
llvm-svn: 132910
OpenPOWER on IntegriCloud