aboutsummaryrefslogtreecommitdiff
path: root/lld
AgeCommit message (Collapse)AuthorFilesLines
2014-12-14Remove code duplication.Rui Ueyama6-51/+8
llvm-svn: 224206
2014-12-13[ELF] Clean up OPT_INPUT handler. NFC.Rui Ueyama1-33/+31
llvm-svn: 224192
2014-12-13Make YAML files own MemoryBuffer.Rui Ueyama1-5/+2
YAML files have references such as StringRef to the underlying MemoryBuffer, so we shouldn't deallocate the buffer. llvm-svn: 224191
2014-12-13Move definitions to the correct file.Rui Ueyama2-15/+16
llvm-svn: 224190
2014-12-12Make File always take the ownership of a MemoryBuffer.Rui Ueyama21-90/+88
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
2014-12-12Separate file parsing from File's constructors.Rui Ueyama20-369/+443
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
2014-12-12[ELF] Remove isThumb().Shankar Easwaran1-2/+0
llvm-svn: 224099
2014-12-11ELF/AArch64: Add a test for R_AARCH64_ABS32Will Newton1-0/+59
llvm-svn: 224014
2014-12-11ELF/AArch64: Add a test for R_AARCH64_ABS64Will Newton1-0/+59
llvm-svn: 224013
2014-12-11[ELF] Remove duplicate constructor code.Rui Ueyama6-182/+52
This piece of code was copied multiple times to each archs. llvm-svn: 224001
2014-12-10[ELF] Allow target to adjust a symbol's value for using in a dynamic tagSimon Atanasyan3-2/+65
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
2014-12-10Remove unreachable return statement.Rui Ueyama1-1/+0
llvm-svn: 223920
2014-12-10[ELF] Make -init/-fini options compatible with the gnu linkerSimon Atanasyan21-404/+180
The LLD linker searches initializer and finalizer function names and emits DT_INIT/DT_FINI dynamic table tags to point to these symbols. The -init/-fini command line options override initializer ("_init") and finalizer ("_fini") function names used by default. Now the -init/-fini options do not affect .init_array/.fini_array sections. The corresponding code has been removed. Differential Revision: http://reviews.llvm.org/D6578 llvm-svn: 223917
2014-12-10Re-commit r223330: Rewrite InputGraph's GroupRui Ueyama20-353/+239
llvm-svn: 223867
2014-12-10Fix Darwin linker. Patch from Jean-Daniel Dupas.Rui Ueyama1-1/+1
llvm-svn: 223865
2014-12-09ELF: Add AArch64 test case missing from previous commitWill Newton1-0/+44
llvm-svn: 223817
2014-12-09Fix the MSVC buildHans Wennborg2-2/+4
llvm-svn: 223796
2014-12-09ELF: Add a standard method for unknown relocation errorsWill Newton19-64/+63
At present each TargetRelocationHandler generates a pretty similar error string and calls llvm_unreachable() when encountering an unknown relocation. This is not ideal for two reasons: 1. llvm_unreachable disappears in release builds but we still want to know if we encountered a relocation we couldn't handle in release builds. 2. Duplication is bad - there is no need to have a per-architecture error message. This change adds a test for AArch64 to test whether or not the error message actually works. The other architectures have not been tested but they compile and check-lld passes. llvm-svn: 223782
2014-12-05[mach-o] fix leak in atoms -> normalizedNick Kledzik1-0/+17
llvm-svn: 223530
2014-12-05[mach-o] Switch MachOFile and MachODylibFile to use BumpPtr in lld::FileNick Kledzik1-28/+24
llvm-svn: 223529
2014-12-05Add BumpPtrAllocator to lld::File. Switch SimpleDefinedAtom to allocateNick Kledzik2-22/+97
its SimpleRefernces using the BumpPtrAllocator. llvm-svn: 223528
2014-12-05[mach-o] Pass vectors by reference and name empty vector.Nick Kledzik1-5/+8
llvm-svn: 223527
2014-12-05[PECOFF] Fix exported symbols in an import library.Rui Ueyama3-6/+14
Looks like if you have symbol foo in a module-definition file (.def file), and if the actual symbol name to match that export description is _foo@x (where x is an integer), the exported symbol name becomes this. - foo in the .dll file - foo@x in the .lib file I have checked in a few fixes recently for exported symbol name mangling. I haven't found a simple rule that governs all the mangling rules. There may not ever exist. For now, this is a patch to improve .lib file compatibility. llvm-svn: 223524
2014-12-05ELF: Use ELF reloc .def files to reduce duplicationWill Newton6-330/+32
Tested with check-lld with no regressions. llvm-svn: 223462
2014-12-04Remove extra semicolon.Rui Ueyama1-1/+1
llvm-svn: 223411
2014-12-04Fix a bunch of -Winconsistent-missing-override warnings.Eric Christopher1-7/+7
llvm-svn: 223400
2014-12-04Revert "Rewrite InputGraph's Group"Rui Ueyama20-239/+353
This reverts commit r223330 because it broke Darwin and ELF linkers in a way that we couldn't have caught with the existing test cases. llvm-svn: 223373
2014-12-04[ELF] Adjust ELF header entry symbol value if this symbol is microMIPS encodedSimon Atanasyan7-25/+190
To find an AtomLayout object for the given symbol I replace the `Layout::findAtomAddrByName` method by `Layout::findAtomLayoutByName` method. llvm-svn: 223359
2014-12-04[PECOFF] Improve /export compatibility.Rui Ueyama4-42/+63
Looks like the rule of /export is more complicated than I was thinking. If /export:foo, for example, is given, and if the actual symbol name in an object file is _foo@<number>, we need to export that symbol as foo, not as the mangled name. If only /export:_foo@<number> is given, the symbol is exported as _foo@<number>. If both /export:foo and /export:_foo@<number> are given, they are considered as duplicates, and the linker needs to choose the unmangled name. The basic idea seems that the linker needs to export a symbol with the same name as given as /export. We exported mangled symbols. This patch fixes that issue. llvm-svn: 223341
2014-12-04Rewrite InputGraph's GroupRui Ueyama20-353/+239
The aim of this patch is to reduce the excessive abstraction from the InputGraph. We found that even a simple thing, such as sorting input files (Mach-O) or adding a new file to the input file list (PE/COFF), is nearly impossible with the InputGraph abstraction, because it hides too much information behind it. As a result, we invented complex interactions between components (e.g. notifyProgress() mechanism) and tricky code to work around that limitation. There were many occasions that we needed to write awkward code. This patch is a first step to make it cleaner. As a first step, this removes Group class from the InputGraph. The grouping feature is now directly handled by the Resolver. notifyProgress is removed since we no longer need that. I could have cleaned it up even more, but in order to keep the patch minimum, I focused on Group. SimpleFileNode class, a container of File objects, is now limited to have only one File. We shold have done this earlier. We used to allow putting multiple File objects to FileNode. Although SimpleFileNode usually has only one file, the Driver class actually used that capability. I modified the Driver class a bit, so that one FileNode is created for each input File. We should now probably remove SimpleFileNode and directly store File objects to the InputGraph in some way, because a container that can contain only one object is useless. This is a TODO. Mach-O input files are now sorted before they are passe to the Resolver. DarwinInputGraph class is no longer needed, so removed. PECOFF still has hacky code to add a new file to the input file list. This will be cleaned up in another patch. llvm-svn: 223330
2014-12-04[PECOFF] Improve compatibility of /export option.Rui Ueyama2-2/+12
llvm-svn: 223326
2014-12-03[PECOFF] Fix a bug in /export option handler.Rui Ueyama2-7/+12
/export option can be given multiple times to specify multiple symbols to be exported. /export accepts both decorated and undecorated name. If you give both undecorated and decorated name of the same symbol to /export, they are resolved to the same symbol. In this case, we need to de-duplicate the exported names, so that we don't have duplicated items in the export symbol table in a DLL. We remove duplicate items from a vector. The bug was there. Because we had pointers pointing to elements of the vector, after an item is removed, they would point wrong elements. This patch is to remove these pointers. Added a test for that case. llvm-svn: 223200
2014-12-02Disable warning 4530 for MSVC builds.Zachary Turner1-0/+4
We compile with exceptions off for LLVM and all other LLVM subprojects, so this brings parity to LLD and disables this warning. Reviewed by: Rui Ueyama llvm-svn: 223131
2014-12-02[mach-o] Fix TrieEdge leakNick Kledzik1-5/+6
In PR21682 Jean-Daliel Dupas found a leak in the trie builder and suggested a fix was to use a list instead of SmallVector so that the list elements could be allocated in the BumpPtrAllocator. llvm-svn: 223104
2014-12-02[mach-o] add support for arm64 compact unwind infoNick Kledzik2-11/+348
Tim previously added generic compact unwind processing and x86_64 support. This patch adds arm64 support. llvm-svn: 223103
2014-12-01[Core] Remove function to not override RoundTripPasses.Shankar Easwaran2-5/+1
RoundTripPasses should always be called in DEBUG mode if the environment variable "LLD_RUN_ROUNDTRIP_TEST" is set. Flavors should not be able to override this behavior. llvm-svn: 223073
2014-12-01[Core] Add flag to check if RoundTripPasses need to be run.Shankar Easwaran3-4/+32
This would allow other flavor specific contexts to override the default value, if they want to optionally run the round trip passes. There is some information lost like the original file owner of the atom with RoundTripPasses. The Gnu flavor needs this information inorder to implement LinkerScript matching and for other diagnostic outputs such as Map files. The flag also can be used to record information in the Atom if the information to the Writer needs to be conveyed through References too. llvm-svn: 222983
2014-11-30[ELF] Fix layout of output sections.Shankar Easwaran2-2/+11
The AtomSections were improperly merging sections from various input files. This patch fixes the problem, with an updated test that was provided by Simon. Thanks to Simon Atanasyan for catching this issue. llvm-svn: 222982
2014-11-30[ELF] Rename align2 to alignment.Shankar Easwaran7-61/+61
No change in functionality. llvm-svn: 222975
2014-11-30[ELF] Fix creation of segments.Shankar Easwaran4-5/+206
Linker was creating a separate output segment in some cases if input sections had huge alignments. This patch fixes the issue. llvm-svn: 222974
2014-11-30[ELF] Create input and output section namesShankar Easwaran5-26/+58
No change in functionality. llvm-svn: 222973
2014-11-30[ELF] Rename MergedSection to OutputSection.Shankar Easwaran4-102/+95
No change in functionality. llvm-svn: 222972
2014-11-26Rename R_AARCH64_TLSDESC_ADR_PAGE to R_AARCH64_TLSDESC_ADR_PAGE21Will Newton1-1/+1
llvm-svn: 222823
2014-11-26Fix comment in AArch64 ELF backendWill Newton1-1/+1
llvm-svn: 222814
2014-11-26Use SafelyCloseFileDescriptor instead of close.Rui Ueyama1-7/+2
Opening a file using openFileForWrite and closing it using close was asymmetric. It also had a subtle portability problem (details are described in the commit message for r219189). llvm-svn: 222802
2014-11-26[PECOFF] Properly close a file descriptor.Rui Ueyama1-0/+7
This was basically benign resource leak on Unix, but on Windows it could cause builds to fail because opened file descriptor prevents other processes from moving or removing the file. llvm-svn: 222799
2014-11-25[PECOFF] Ignore /maxilkfile option.Rui Ueyama2-1/+3
.ilk file is a file for incremental linking. We don't create nor use that file. /MAXILKFILE is an undocumented option to specify the maximum size of the .ilk file, IIUC. We should just ignore the option. llvm-svn: 222777
2014-11-25[PECOFF] Create an empty PDB file if debug option is enabled.Rui Ueyama6-11/+90
There are many build files in the wild that depend on the fact that link.exe produces a PDB file if /DEBUG option is given. They fail if the file is not created. This patch is to make LLD create an empty (dummy) file to satisfy such build targets. This doesn't do anything other than "touching" the file. If a target depends on the content of the PDB file, this workaround is no help, of course. Otherwise this patch should help build some stuff. llvm-svn: 222773
2014-11-22Silence a -Wcast-qual warningDavid Majnemer1-1/+1
llvm-svn: 222598
2014-11-21[Mips] Use endian::read() for relocation addendum readingSimon Atanasyan1-3/+5
llvm-svn: 222574