summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* COFF: Remove the old COFF linker and make link an alias to link2.Rui Ueyama2015-08-061-388/+0
| | | | | | It's time to remove old COFF linker because the new one is now complete. llvm-svn: 244226
* Use MemoryBufferRef instead of MemoryBuffer&. NFC.Rafael Espindola2015-04-241-1/+1
| | | | | | This just reduces the noise from another patch. llvm-svn: 235776
* Return an ErrorOr<std::unique_ptr<File>>. NFC.Rafael Espindola2015-04-241-6/+6
| | | | llvm-svn: 235741
* Delete unnecessary generality in loadFile.Rafael Espindola2015-04-241-5/+5
| | | | | | | | | | | | | loadFile could load mulitple files just because yaml has a feature for putting multiple documents in one file. Designing a linker around what yaml can do seems like a bad idea to me. This patch changes it to read a single file. There are further improvements to be done to the api and they will follow shortly. llvm-svn: 235724
* Define make_dynamic_error_code(const char *).Rui Ueyama2015-04-141-1/+1
| | | | | | | | | | | | The function took either StringRef or Twine. Since string literals are ambiguous when resolving the overloading, many code calls used this function with explicit type conversion. That led awkward code like make_dynamic_error_code(Twine("Error occurred")). This patch adds a function definition for string literals, so that you can directly call the function with literals. llvm-svn: 234841
* Remove the Native file format.Rui Ueyama2015-04-101-1/+1
| | | | | | | | | | | | | The Native file format was designed to be the fastest on-memory or on-disk file format for object files. The problem is that no one is working on that. No LLVM tools can produce object files in the Native, thus the feature of supporting the format is useless in the linker. This patch removes the Native file support. We can add it back if we really want it in future. llvm-svn: 234641
* Rename atom_collection -> AtomVector.Rui Ueyama2015-04-081-6/+6
| | | | | | Type names should start with an uppercase letter in the LLVM coding style. llvm-svn: 234452
* Separate atom_collection type into two different types. NFC.Rui Ueyama2015-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | atom_collection is basically a wrapper for std::vector. The class provides begin and end member functions, so that it "hides" the other member functions provided by std::vector. However, you can still directly access _atoms member since the member is not protected. We cannot simply make the member private because we need that member when we are constructing atom vectors. This patch splits atom_collection into two types: std::vector<Atom *> and AtomRange. When we are constructing atom vectors, we use the former class. We return instances of the latter class from File objects so that callers cannot add or remove atoms from the lists. std::vector<Atom *> is automatically converted to AtomRange. llvm-svn: 234450
* Merge atom_collection_vector with atom_collection.Rui Ueyama2015-04-081-2/+2
| | | | | | | atom_collection_vector is the only derived class of atom_collection. This patch merges the two. llvm-svn: 234443
* Remove a parameter for file extension from canParse.Rui Ueyama2015-04-041-3/+2
| | | | | | | | canParse took three parameters -- file magic, filename extension and memory buffer. All but YAMLReader ignored the second parameter. This patch removes the parameter. llvm-svn: 234080
* Use alignment values everywhere instead of log2.Rui Ueyama2015-03-261-1/+1
| | | | | | | | This patch defines implicit conversion between integers and PowerOf2 instances, so uses of the classes is now implicit and look like regular integers. Now we are ready to remove the scaffolding. llvm-svn: 233245
* Remove COFFReference and use SimpleReference instead.Rui Ueyama2015-03-091-9/+14
| | | | | | | SimpleReference, which is defined in Core, provides the same functionality as COFFReference does, so we don't need a custom class. llvm-svn: 231715
* Remove include/lld/Core/Endian.h and use llvm/Support/Endian.h instead.Rui Ueyama2015-03-021-1/+2
| | | | llvm-svn: 231005
* Add missing includes for make_unique, lld edition.Benjamin Kramer2015-03-021-0/+1
| | | | llvm-svn: 230925
* Remove unused #includes.Rui Ueyama2015-02-271-1/+0
| | | | llvm-svn: 230726
* Add {read,write}{16,32,64}{le,be} functions.Rui Ueyama2015-02-271-6/+5
| | | | | | | | | | | | | | Nothing wrong with reinterpret_cast<llvm::support::ulittle32_t *>(loc), but that's redundant and not great from readability point of view. The new functions are wrappers for that kind of reinterpet_casts. Surprisingly or unsurprisingly, there was no use of big endian read and write. {read,write}{16,32,64}be have no user. But I think they still worth to be there in the header for completeness. http://reviews.llvm.org/D7927 llvm-svn: 230725
* Re-commit r225674: Convert other drivers to use WrapperNode.Rui Ueyama2015-01-151-7/+6
| | | | | | | | The original commit had an issue with Mac OS dylib files. It didn't handle fat binary dylib files correctly. This patch includes a fix. A test for that case has already been committed in r225764. llvm-svn: 226123
* Revert "Convert other drivers to use WrapperNode" and subsequent commits.Rui Ueyama2015-01-141-2/+2
| | | | | | | r225764 broke a basic functionality on Mac OS. This change reverts r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832. llvm-svn: 225859
* Convert other drivers to use WrapperNode.Rui Ueyama2015-01-131-2/+2
| | | | llvm-svn: 225764
* PE/COFF: add support to import functions in ARM NTSaleem Abdulrasool2015-01-081-7/+46
| | | | | | | | | | This is necessary to support linking a basic program which references symbols outside of the module itself. Add the import thunk for ARM NT style imports. This allows us to create the reference. However, it is still insufficient to generate executables that will run due to base relocations not being emitted for the import. llvm-svn: 225428
* Make File always take the ownership of a MemoryBuffer.Rui Ueyama2014-12-121-1/+1
| | | | | | | | | | | | | | The documentation of parseFile() said that "the resulting File object may take ownership of the MemoryBuffer." So, whether or not the ownership of a MemoryBuffer would be taken was not clear. A FileNode (a subclass of InputElement, which is being deprecated) keeps the ownership if a File doesn't take it. This patch makes File always take the ownership of a buffer. Buffers lifespan is not always the same as File instances. Files are able to deallocate buffers after parsing the contents. llvm-svn: 224113
* Separate file parsing from File's constructors.Rui Ueyama2014-12-121-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a second patch for InputGraph cleanup. Sorry about the size of the patch, but what I did in this patch is basically moving code from constructor to a new method, parse(), so the amount of new code is small. This has no change in functionality. We've discussed the issue that we have too many classes to represent a concept of "file". We have File subclasses that represent files read from disk. In addition to that, we have bunch of InputElement subclasses (that are part of InputGraph) that represent command line arguments for input file names. InputElement is a wrapper for File. InputElement has parseFile method. The method instantiates a File. The File's constructor reads a file from disk and parses that. Because parseFile method is called from multiple worker threads, file parsing is processed in parallel. In other words, one reason why we needed the wrapper classes is because a File would start reading a file as soon as it is instantiated. So, the reason why we have too many classes here is at least partly because of the design flaw of File class. Just like threads in a good threading library, we need to separate instantiation from "start" method, so that we can instantiate File objects when we need them (which should be very fast because it involves only one mmap() and no real file IO) and use them directly instead of the wrapper classes. Later, we call parse() on each file in parallel to let them do actual file IO. In this design, we can eliminate a reason to have the wrapper classes. In order to minimize the size of the patch, I didn't go so far as to replace the wrapper classes with File classes. The wrapper classes are still there. In this patch, we call parse() immediately after instantiating a File, so this really has no change in functionality. Eventually the call of parse() should be moved to Driver::link(). That'll be done in another patch. llvm-svn: 224102
* Use llvm::make_unique.Rui Ueyama2014-10-141-1/+1
| | | | llvm-svn: 219709
* [PECOFF] Refactor _imp_ symbol generator.Rui Ueyama2014-10-091-21/+28
| | | | | | | | We are going to have another type of jump table for the delay-load import table. In order to prepare for that, we want to factor out the function handling the jump table. No functionality change. llvm-svn: 219446
* [PECOFF] Remove another use of is64 to support non-Intel architectureRui Ueyama2014-10-091-19/+30
| | | | llvm-svn: 219438
* [PECOFF] Explicitly pass machine typeRui Ueyama2014-08-221-2/+0
| | | | | | | x86 and x64 are created equal -- taking x86 as the default argument made it hard to find bugs. llvm-svn: 216295
* [PECOFF] Fix PE+ relocationsRui Ueyama2014-08-221-9/+25
| | | | | | | | | | | | | The implementation of AMD64 relocations was imcomplete and wrong. On AMD64, we of course have to use AMD64 relocations instead of i386 ones. This patch fixes the issue. LLD is now able to link hello64.obj (created from hello64.asm) against user32.lib and kernel32.lib to create a Win64 binary. llvm-svn: 216253
* Remove dead code.Rui Ueyama2014-08-211-24/+0
| | | | llvm-svn: 216152
* Remove a 'using std::error_code' I missed in the previous pass.Rafael Espindola2014-06-131-11/+11
| | | | llvm-svn: 210878
* More prefixing of error_code.Rafael Espindola2014-06-121-0/+1
| | | | llvm-svn: 210831
* include system_error directly.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210801
* Run llvm/utils/sort_includes.py in a few files.Rafael Espindola2014-06-121-6/+3
| | | | | | This will reduce the noise in a followup patch. llvm-svn: 210800
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-3/+3
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209948
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-2/+2
| | | | | | | | | | definition below all of the header #include lines, LLD edition. IF you want to know more details about this, you can see the recent commits to Debug.h in LLVM. This is just the LLD segment of a cleanup I'm doing globally for this macro. llvm-svn: 206851
* [PECOFF] Fix -Wsign-compare warning.Simon Atanasyan2014-03-191-1/+1
| | | | llvm-svn: 204223
* Add "override" to member functions where appropriate.Rui Ueyama2014-03-051-13/+13
| | | | llvm-svn: 202998
* Run clang-format on r197727.Rui Ueyama2013-12-201-5/+4
| | | | llvm-svn: 197788
* [lld] Introduce registry and Reference kind tupleNick Kledzik2013-12-191-15/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main changes are in: include/lld/Core/Reference.h include/lld/ReaderWriter/Reader.h Everything else is details to support the main change. 1) Registration based Readers Previously, lld had a tangled interdependency with all the Readers. It would have been impossible to make a streamlined linker (say for a JIT) which just supported one file format and one architecture (no yaml, no archives, etc). The old model also required a LinkingContext to read an object file, which would have made .o inspection tools awkward. The new model is that there is a global Registry object. You programmatically register the Readers you want with the registry object. Whenever you need to read/parse a file, you ask the registry to do it, and the registry tries each registered reader. For ease of use with the existing lld code base, there is one Registry object inside the LinkingContext object. 2) Changing kind value to be a tuple Beside Readers, the registry also keeps track of the mapping for Reference Kind values to and from strings. Along with that, this patch also fixes an ambiguity with the previous Reference::Kind values. The problem was that we wanted to reuse existing relocation type values as Reference::Kind values. But then how can the YAML write know how to convert a value to a string? The fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace (e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and a 16-bit value. This tuple system allows conversion to and from strings with no ambiguities. llvm-svn: 197727
* [PECOFF] Rename lld::coff -> lld::pecoff.Rui Ueyama2013-12-131-2/+2
| | | | | | We had lld::coff and lld::pecoff namespaces for no reason. Unify them. llvm-svn: 197201
* Run clang-format for PECOFF reader/writer code. No other changes.Rui Ueyama2013-12-111-15/+15
| | | | llvm-svn: 197039
* Fix a variety of typos in function names and commentsAlp Toker2013-12-011-1/+1
| | | | | | No change in functionality. llvm-svn: 196053
* [PECOFF] Set ordinals to linker internal atoms.Rui Ueyama2013-11-251-1/+1
| | | | | | | | | This patch won't change the output because the layout of linker internal atoms is forced by layout-{before,after} references. Ordinals of the linker internal atoms are not currently used. (That's why it's working even if there are atoms having the same ordinals.) llvm-svn: 195610
* [PECOFF] Use INT3 instead of NOP.Rui Ueyama2013-11-151-1/+1
| | | | | | | | | | This patch does not change the meaning of the program, but if something's wrong in the linker or the compiler and the control reaches to the gap of imported function table, it will stop immediately because of the presence of INT3. If NOP, it'd fall through to the next call instruction, which is usually a completely foreign function call. llvm-svn: 194860
* [PECOFF] Remove unnecessary static member.Rui Ueyama2013-11-151-17/+10
| | | | llvm-svn: 194851
* Remove unnecessary namespace qualifier.Rui Ueyama2013-11-051-2/+2
| | | | llvm-svn: 194037
* Update error classes from all lowercase to camel case.Rui Ueyama2013-10-091-2/+2
| | | | llvm-svn: 192261
* [PECOFF] Trim at most one character from imported symbols.Rui Ueyama2013-08-121-2/+10
| | | | | | | | | | | | | | The import name is not always the same as the symbol name. If the name/type field in the import header is NOPREFIX or UNDECORATE, we need to strip some characters from symbol to get its import name. The Microsoft PE/COFF spec is vague if symbol contains more than two consecutive characters to be stripped. We used to strip all characters, but it doesn't seem right as we couldn't link against the system library because of this name mangling. Looks like we shouldn't strip more than one character. llvm-svn: 188154
* Rename TargetInfo -> LinkingContext.Rui Ueyama2013-08-061-6/+6
| | | | | | | | | Also change some local variable names: "ti" -> "context" and "_targetInfo" -> "_context". Differential Revision: http://llvm-reviews.chandlerc.com/D1301 llvm-svn: 187823
* [PECOFF] Add a comment on the idata section fragments.Rui Ueyama2013-07-311-0/+19
| | | | llvm-svn: 187484
* [PECOFF] Process Import Name/Type field in the import library.Rui Ueyama2013-07-291-6/+43
| | | | | | | | This patch removes hacky mangle() function, which strips all decorations uncondtitionally. LLD now interprets Import Name/Type field in the import library properly as described in the Microsoft PE/COFF Spec. llvm-svn: 187388
OpenPOWER on IntegriCloud