summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Re-commit r225766, r225767, r225769, r225814, r225816, r225829, and r225832.Rui Ueyama2015-01-158-167/+64
| | | | | | | These changes depended on r225674 and had been rolled back in r225859. Because r225674 has been re-submitted, it's safe to re-submit them. llvm-svn: 226132
* Attempt to fix a Linux buildbot.Rui Ueyama2015-01-151-1/+1
| | | | llvm-svn: 226127
* Re-commit r225674: Convert other drivers to use WrapperNode.Rui Ueyama2015-01-1523-365/+263
| | | | | | | | 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
* [cleanup] Re-sort #include lines using llvm/utils/sort_includes.pyChandler Carruth2015-01-146-6/+2
| | | | | | | | This is just a mechanical cleanup, no functionality changed. This just fixes very minor inconsistencies with how #include lines were spaced and sorted in LLD. llvm-svn: 225978
* Revert "Convert other drivers to use WrapperNode" and subsequent commits.Rui Ueyama2015-01-1426-318/+527
| | | | | | | r225764 broke a basic functionality on Mac OS. This change reverts r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832. llvm-svn: 225859
* Remove InputGraph::getNextFile().Rui Ueyama2015-01-132-58/+28
| | | | | | | | | | | | getNextFile used to have a complex logic to determine which file should be processed by the Resolver on next iteration. Now, it is just a sequential accessor to the internal array and provides no sensible feature. This patch also removes InputGraph::getGroupSize and InputGraph:: skipGroup to simplify the code. llvm-svn: 225832
* Simplify.Rui Ueyama2015-01-131-25/+8
| | | | | | | We can remove these methods because every InputElement has only one File. llvm-svn: 225816
* Replace vector<unique_ptr<File> with unique_ptr<File>.Rui Ueyama2015-01-132-5/+3
| | | | | | | Because each InputElement has exactly one File, we no longer have to use a vector to store pointers to Files. llvm-svn: 225814
* Remove dead code.Rui Ueyama2015-01-132-19/+0
| | | | | | | Now every InputElement has exactly one File in it, so "expand" method is now no-op. llvm-svn: 225769
* Remove InputGraph::registerObserver.Rui Ueyama2015-01-134-60/+34
| | | | | | | | | | | | PECOFF was the only user of the API, and the reason why we created the API is because, although the driver creates a list of input files, it has no knowledge on what files are being created. It was because everything was hidden behind the InputGraph abstraction. Now the driver knows what that's doing. We no longer need this indirection to get the file list being processed. llvm-svn: 225767
* Remove InputGraph::dump().Rui Ueyama2015-01-132-10/+0
| | | | | | This is dead code. llvm-svn: 225766
* Convert other drivers to use WrapperNode.Rui Ueyama2015-01-1323-360/+255
| | | | llvm-svn: 225764
* Update comment.Rui Ueyama2015-01-121-2/+2
| | | | llvm-svn: 225645
* 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
* PE/COFF: teach ARMNT backend about ADDR32NB for exportsSaleem Abdulrasool2015-01-072-0/+7
| | | | | | | | | This adds the ability to export symbols from a DLL built for ARMNT. Add this support first to help work towards adding support for import thunks on Windows on ARM. In order to generate the exports, add support for IMAGE_REL_ARM_ADDR32NB relocations. llvm-svn: 225339
* [ELF] Remove {ELF,}GNULinkerScript.Rui Ueyama2015-01-072-73/+57
| | | | | | | | | | | | | | | | | | | | Instead of representing a linker script file as an "InputElement", parse and evaluate scripts in the driver as we see them. Linker scripts are not regular input files (regular file is one of object, archive, or shared library file). They are more like extended command line options. Linker script handling was needlessly complicated because of that inappropriate abstraction (besides excessive class hierarchy -- there is no such thing like ELF linker script but we had two classes there for some reason.) LinkerScript was one of a few remaining InputElement subclasses that can be expanded to multiple files. With this patch, we are one step closer to retire InputElement. http://reviews.llvm.org/D6648 llvm-svn: 225330
* Convert CoreInputGraph.Rui Ueyama2015-01-063-7/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a part of InputGraph cleanup to represent input files as a flat list of Files (and some meta-nodes for group etc.) We cannot achieve that goal in one gigantic patch, so I split the task into small steps as shown below. (Recap the progress so far: Currently InputGraph contains a list of InputElements. Each InputElement contain one File (that used to have multiple Files, but I eliminated that use case in r223867). Files are currently instantiated in Driver::link(), but I already made a change to separate file parsing from object instantiation (r224102), so we can safely instantiate Files when we need them, instead of wrapping a file with the wrapper class (FileNode class). InputGraph used to act like a generator class by interpreting groups by itself, but it's now just a container of a list of InputElements (r223867).) 1. Instantiate Files in the driver and wrap them with WrapperNode. WrapperNode is a temporary class that allows us to instantiate Files in the driver while keep using the current InputGraph data structure. This patch demonstrates how this step 1 looks like, using Core driver as an example. 2. Do the same thing for the other drivers. When step 2 is done, an InputGraph consists of GroupEnd objects or WrapperNodes each of which contains one File. Other types of FileNode subclasses are removed. 3. Replace InputGraph with std::vector<std::unique_ptr<InputElement>>. InputGraph is already just a container of list of InputElements, so this step removes that needless class. 4. Remove WrapperNode. We need some code cleanup between each step, because many classes do a bit odd things (e.g. InputGraph::getGroupSize()). I'll straight things up as I need to. llvm-svn: 225313
* PECOFF: adjust the entry point on ARM NTSaleem Abdulrasool2015-01-041-3/+9
| | | | | | | | | ARM NT assumes a purely THUMB execution, and as such requires that the address of entry point is adjusted to indicate a thumb entry point. Unconditionally adjust the AddressOfEntryPoint in the PE header for PE/COFF ARM as we only support ARM NT at the moment. llvm-svn: 225139
* ReaderWriter: adjust ARM target addresses for execSaleem Abdulrasool2015-01-031-1/+8
| | | | | | | | | | | | ARM NT assumes a THUMB only environment. As such, any address that is detected as residing in an executable section is adjusted to have its bottom bit set to indicate THUMB in case of a mode exchange. Although the testing here seems insufficient (missing the negative cases) the existing test cases for the IMAGE_REL_ARM_{ADDR32,MOV32T} are relevant as they ensure that we do not incorrectly set the bit. llvm-svn: 225104
* ReaderWriter: teach the writer about IMAGE_REL_ARM_BRANCH24TSaleem Abdulrasool2015-01-021-1/+7
| | | | | | | | | | This adds support for IMAGE_REL_ARM_BRANCH24T relocations. Similar to the IMAGE_REL_ARM_BLX32T relocation, this relocation requires munging an instruction. The instruction encoding is quite similar, allowing us to reuse the same munging implementation. This is needed by the entry point stubs for modules provided by MSVCRT. llvm-svn: 225082
* ReaderWriter: teach the writer about IMAGE_REL_ARM_BLX23TSaleem Abdulrasool2015-01-021-0/+20
| | | | | | | | | This adds support for IMAGE_REL_ARM_BLX23T relocations. Similar to the IMAGE_REL_ARM_MOV32T relocation, this relocation requires munging an instruction. This inches us closer to supporting a basic hello world application. llvm-svn: 225081
* ReaderWriter: teach the writer about IMAGE_REL_ARM_MOV32TSaleem Abdulrasool2015-01-021-0/+17
| | | | | | | | | This adds support for the IMAGE_REL_ARM_MOV32T relocation. This is one of the most complicated relocations for the Window on ARM target. It involves re-encoding an instruction to contain an immediate value which is the relocation target. llvm-svn: 225072
* ReaderWriter: teach the writer about IMAGE_REL_ARM_ADDR32Saleem Abdulrasool2015-01-011-4/+25
| | | | | | | | This implements the IMAGE_REL_ARM_ADDR32 relocation. There are still a few more relocation types that need to resolved before lld can even attempt to link a trivial program for Windows on ARM. llvm-svn: 225057
* ReaderWriter: teach PE/COFF backend about ARM NTSaleem Abdulrasool2014-12-312-0/+6
| | | | | | | | | This teaches lld about the ARM NT object types. Add a trivial test to ensure that it can handle ARM NT object file inputs. It is still unable to perform the necessary relocations for ARM NT, but this allows the linker to at least read the objects. llvm-svn: 225052
* [Mips] Replace stderr output by the `llvm_unreachable` callSimon Atanasyan2014-12-251-4/+4
| | | | | | | | | If a regular symbol has microMIPS-bit we need to stop linking. Now the LLD does not check the `applyRelocation` return value and continues linking anyway. As a temporary workaround use the `llvm_unreachable` call to stop the linker. llvm-svn: 224831
* [Mips] Support linking of microMIPS 32-bit codeSimon Atanasyan2014-12-247-84/+530
| | | | | | | The change is rather large but mainly it just adds handling of new relocations, PLT entries etc. llvm-svn: 224826
* [Mips] Join two if statementsSimon Atanasyan2014-12-241-3/+1
| | | | | | No functional changes. llvm-svn: 224817
* [Mips] Make the comment more descriptiveSimon Atanasyan2014-12-241-1/+1
| | | | | | No functional changes. llvm-svn: 224816
* [Mips] Factor out the code checks a symbol's bindingSimon Atanasyan2014-12-241-5/+6
| | | | | | No functional changes. llvm-svn: 224815
* [Mips] Rename the function s/readAddend/getAddend/Simon Atanasyan2014-12-241-4/+4
| | | | | | No functional changes. llvm-svn: 224814
* [Mips] Use OR operation to set the microMIPS bitSimon Atanasyan2014-12-242-2/+2
| | | | llvm-svn: 224813
* [macho] Minor install_name fixesJean-Daniel Dupas2014-12-202-1/+5
| | | | | | | | | | | | | | | | | | | Summary: Fix the binary file reader to properly read dyld version info. Update the install_name test case to properly test the binary reader. We can't use '-print_atoms' as the output format is 'native' yaml and it does not contains the dyld current and compatibility versions. Also change the timestamp value of LD_ID_DYLD to match the one generated by ld64. The dynamic linker (dyld) used to expects different values for timestamp in LD_ID_DYLD and LD_LOAD_DYLD for prebound images. While prebinding is deprecated, we should probably keep it safe and match ld64. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6736 llvm-svn: 224681
* [macho] -rpath supportJean-Daniel Dupas2014-12-186-0/+62
| | | | | | | | | | | | | | | | | | | | | Summary: Work on adding -rpath support to the mach-o linker. This patch is based on the ld64 behavior for the command line option validation. It includes a basic test to check that the LC_RPATH load commands are properly generated when that option is used. It also add LC_RPATH support to the binary reader, but I don't know how to test it though. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6724 llvm-svn: 224544
* Replace ReaderError with DynamicError.Rui Ueyama2014-12-152-28/+1
| | | | | | | | | ReaderErrorCategory was used only at one place. We now have a DynamicErrorCategory for this kind of one-time error, so use it. The calling function doesn't really care the type of an error, so ReaderErrorCategory was actually dead code. llvm-svn: 224245
* Remove dead code.Rui Ueyama2014-12-151-4/+0
| | | | | | This field was not even initialized properly. llvm-svn: 224236
* Protect doParse() because that's not a public interface.Rui Ueyama2014-12-155-13/+17
| | | | llvm-svn: 224235
* Clean up #include dependency.Rui Ueyama2014-12-142-0/+2
| | | | | | Core/File.h does not use LinkingContext.h, so remove that dependency. llvm-svn: 224214
* Remove PECOFFLibraryNode.Rui Ueyama2014-12-141-2/+2
| | | | | | This class is empty, provides no additional feature to the base class. llvm-svn: 224212
* More WinLinkInputGraph cleanup.Rui Ueyama2014-12-142-10/+10
| | | | | | | This function is called only from WinLinkDriver.cpp. Move the function to that file and mark as static. llvm-svn: 224211
* [PECOFF] Resolve file name in the driver, not in InputElement.Rui Ueyama2014-12-142-17/+24
| | | | llvm-svn: 224209
* Simplify InputGraph API.Rui Ueyama2014-12-143-53/+22
| | | | | | | | | These member functions returns either no_more_files error or a File object. We could simply return a nullptr instead of a no_more_files. This function will be removed soon as a part of InputGraph cleanup. I had to do that step by step. llvm-svn: 224208
* Remove code duplication.Rui Ueyama2014-12-141-6/+0
| | | | llvm-svn: 224206
* [ELF] Clean up OPT_INPUT handler. NFC.Rui Ueyama2014-12-131-33/+31
| | | | llvm-svn: 224192
* Make YAML files own MemoryBuffer.Rui Ueyama2014-12-131-5/+2
| | | | | | | YAML files have references such as StringRef to the underlying MemoryBuffer, so we shouldn't deallocate the buffer. llvm-svn: 224191
* Move definitions to the correct file.Rui Ueyama2014-12-132-15/+16
| | | | llvm-svn: 224190
* Make File always take the ownership of a MemoryBuffer.Rui Ueyama2014-12-1216-79/+72
| | | | | | | | | | | | | | 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-1218-368/+422
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ELF] Remove isThumb().Shankar Easwaran2014-12-121-2/+0
| | | | llvm-svn: 224099
* [ELF] Remove duplicate constructor code.Rui Ueyama2014-12-116-182/+52
| | | | | | This piece of code was copied multiple times to each archs. llvm-svn: 224001
* [ELF] Allow target to adjust a symbol's value for using in a dynamic tagSimon Atanasyan2014-12-102-2/+20
| | | | | | | | | Some targets like microMIPS and ARM Thumb use the last bit of a symbol's value to mark 'compressed' code. This patch adds new virtual function `DynamicTable::getAtomVirtualAddress` which allows to adjust a symbol's value before using it in a dynamic table tags like DT_INIT / DT_FINI. llvm-svn: 223963
OpenPOWER on IntegriCloud