summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Attemp to fix botGeorge Rimar2017-05-261-1/+1
| | | | | | http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/8549/steps/build_Lld/logs/stdio llvm-svn: 304016
* Avoid a couple uses of OutputSections.Rafael Espindola2017-05-261-5/+12
| | | | | | After fabricateDefaultCommands we can look at the script commands. llvm-svn: 304014
* Avoid using EhFrameHdr->Sections.Rafael Espindola2017-05-261-2/+4
| | | | | | This is a necessary step for moving clearOutputSections earlier. llvm-svn: 304009
* Order writable executable sections before writable ones.Rafael Espindola2017-05-269-198/+212
| | | | | | | | | | | | | | On SPARC, .plt is both writeable and executable. The current way sections are sorted means that lld puts it after .data/.bss. but it really needs to be close to .test to make sure branches into .plt don't overflow. I'd argue that because .bss is supposed to come last on all architectures, we should change the default sort order such that writable and executable sections come before sections that are just writeable. read-only executable sections should still come after sections that are just read-only of course. This diff makes this change. llvm-svn: 304008
* [ELF] - Follow up for r303975. NFCi.George Rimar2017-05-261-1/+1
| | | | | | | Restore bitwise-or order and fix warning (was changed by mistake during resolve of conflicts). llvm-svn: 303976
* [ELF] - Do not produce duplicate values in .gdb_index's constant pool area.George Rimar2017-05-263-5/+66
| | | | | | | | | | | | | | | | | | | | | | I found this when builded llc binary using gcc 5.4.1 + LLD. gcc produces duplicate entries in .debug_gnu_pubtypes section, ex: UnifyFunctionExitNodes.cpp.o has: 0x0000ac07 EXTERNAL TYPE "std::success_type<void*>" 0x0000ac07 EXTERNAL TYPE "std::success_type<void*>" clang produces single entry here: 0x0000d291 EXTERNAL TYPE "std::__success_type<void *>" If we link output from gcc with LLD, that would produce excessive duplicate entries in .gdb_index constant pool area. That does not seem affect gdb work, but makes .gdb_index larger than it can be. I also checked that gold filters out such duplicates too. Patch fixes it. Differential revision: https://reviews.llvm.org/D32647 llvm-svn: 303975
* [ELF] - Simplify implementation of constant pool when building .gdb_indexGeorge Rimar2017-05-262-11/+8
| | | | | | | | | | | | | | | https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html says: "A CU vector in the constant pool is a sequence of offset_type values. The first value is the number of CU indices in the vector. Each subsequent value is the index and symbol attributes of a CU in the CU list." Previously we keeped 2 values until the end, what was useless. Initially was a part of D32647, though it is possible to split out. Patch do that. Differential revision: https://reviews.llvm.org/D33551 llvm-svn: 303973
* Rearrange code for the sake of readability. NFC.Rui Ueyama2017-05-261-18/+20
| | | | llvm-svn: 303961
* Simplify. NFC.Rui Ueyama2017-05-261-4/+6
| | | | llvm-svn: 303959
* Inline a trivial constructor.Rui Ueyama2017-05-262-7/+1
| | | | llvm-svn: 303958
* Remove dummy cast. NFC.Rafael Espindola2017-05-261-1/+1
| | | | llvm-svn: 303948
* When uncompressing sections, remove SHF_COMPRESSED bits. NFC.Rui Ueyama2017-05-253-7/+4
| | | | | | | In this way, the content and the flag is always consistent, which I think better than removing the bit when input sections reaches the Writer. llvm-svn: 303926
* Revert "Simplify a variable type by using StringRef instead of ↵Rafael Espindola2017-05-254-14/+20
| | | | | | | | | | | CachedHashStringRef." This reverts commit r303787. It caused a slowdown in fast links. That is, links with no debug info or optimizations. llvm-svn: 303925
* [lld] Fix a bug where we continually re-follow type servers.Zachary Turner2017-05-251-5/+6
| | | | | | | | | | | | | | | | | | | Originally this was intended to be set up so that when linking a PDB which refers to a type server, it would only visit the PDB once, and on subsequent visitations it would just skip it since all the records had already been added. Due to some C++ scoping issues, this was not occurring and it was revisiting the type server every time, which caused every record to end up being thrown away on all subsequent visitations. This doesn't affect the performance of linking clang-cl generated object files because we don't use type servers, but when linking object files and libraries generated with /Zi via MSVC, this means only 1 object file has to be linked instead of N object files, so the speedup is quite large. llvm-svn: 303920
* Accept not only --reproduce <foo> but also --reproduce=<foo>.Rui Ueyama2017-05-252-1/+2
| | | | llvm-svn: 303905
* Use MD5::hash(). NFC.Rui Ueyama2017-05-251-10/+6
| | | | llvm-svn: 303893
* Do not allow delay-importing data symbols.Rui Ueyama2017-05-253-0/+78
| | | | | | | | | | | | | | | | | | | If you pass /delayload:<dllname> to the COFF linker, it creates thunks so that DLLs are loaded when they are used for the first time instead of load-time. This mechanism do not work for data symbols as there's no way to trap acccesses to data imported from DLLs. (Technically, I think if we do not initially map dllimport tables in memory, we could actually trap accesses and delay-load data symbols, but that's not what Windows do.) This patch is to report an error when you try to delay-load data symbols. Fixes https://bugs.llvm.org/show_bug.cgi?id=33106 Differential Revision: https://reviews.llvm.org/D33557 llvm-svn: 303890
* Reduce indentation. NFC.Rui Ueyama2017-05-241-8/+11
| | | | llvm-svn: 303815
* Garbage collect dllimported symbols.Rui Ueyama2017-05-248-9/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a different implementation than r303225 (which was reverted in r303270, re-submitted in r303304 and then re-reverted in r303527). In the previous patch, I tried to add Live bit to each dllimported symbol. It turned out that it didn't work with "oldnames.lib" which contains a lot of weak aliases to dllimported symbols. The way we handle weak aliases is to check if undefined symbols can be resolved using weak aliases, and if so, memcpy the Defined symbols to weak Undefined symbols, so that any references to weak aliases automatically see defined symbols instead of undefined ones. This memcpy happens before MarkLive kicks in. That means we may have multiple copies of dllimported symbols. So turning on one instance's Live bit is not enough. This patch moves the Live bit to dllimport file. Since multiple copies of dllsymbols still point to the same file, we can use it as the central repository to keep track of liveness. Differential Revision: https://reviews.llvm.org/D33520 llvm-svn: 303814
* Simplify MipsRldMapSection::writeTo.Rafael Espindola2017-05-242-11/+1
| | | | | | | | | It is not clear why a synthetic section wants to use padding defined in the linker script. The padding is for the space between sections. It was also missing a test. llvm-svn: 303812
* Fix the sanitizer-windows bot.Rui Ueyama2017-05-241-2/+7
| | | | | | | Looks like r303801 broke the sanitizer-windows bot. I don't fully understand what is going on, so I'll partially revert that patch. llvm-svn: 303805
* Close the gap between ELF and COFF ICF implementations. NFC.Rui Ueyama2017-05-241-21/+13
| | | | | | | We originally wrote the ICF code for COFF and ported it to ELF. They started diverging since then. This patch closes the gap. llvm-svn: 303801
* Improve parallelism of ICF.Rui Ueyama2017-05-242-4/+4
| | | | | | | | | | | | | | | This is the only place we use threads for ICF. The intention of this code was to split an input vector into 256 shards and process them in parallel. What the code was actually doing was to split an input into 257 shards, process the first 256 shards in parallel, and the remaining one in serial. That means this code takes ceil(256/n)+1 instead of ceil(256/n) where n is the number of available CPU cores. The former converges to 2 while the latter converges to 1. This patches fixes the above issue. llvm-svn: 303797
* Replace std::call_once with llvm:call_onceKamil Rytarowski2017-05-242-2/+4
| | | | | | | | | | | | | | | | | | | | | Summary: This is required on some platforms, as GNU libstdc++ std::call_once is known to be buggy. This fixes operation of LLD on at least NetBSD and perhaps OpenBSD and Linux PowerPC. The same change has been introduced to LLVM and LLDB. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, #lld Tags: #lld Differential Revision: https://reviews.llvm.org/D33508 llvm-svn: 303788
* Simplify a variable type by using StringRef instead of CachedHashStringRef.Rui Ueyama2017-05-244-20/+14
| | | | | | | | | | A variable `ComdatGroup` is not supposed to contain a large number of items. Even when linking clang, it ends up having only 300K strings. It doesn't make sense to use CachedHashStringRef for this hash table. This patch has neutral or slightly positive impact on performance while reducing code complexity. llvm-svn: 303787
* Move writeTo to OutputSectionCommand.Rafael Espindola2017-05-246-103/+118
| | | | | | | | | | | | This reduces how many times we have to map from OutputSection to OutputSectionCommand. It is a required step to moving clearOutputSections earlier. In order to always use writeTo in OutputSectionCommand we have to call fabricateDefaultCommands for -r links and move section compression after it. llvm-svn: 303784
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-05-241-1/+1
| | | | llvm-svn: 303781
* Rewrite badly-formatted switch. NFC.Rui Ueyama2017-05-241-8/+11
| | | | llvm-svn: 303777
* Make key-value types explicit. NFC.Rui Ueyama2017-05-241-3/+8
| | | | llvm-svn: 303776
* Change the control flow so that the function is a bit more readable. NFC.Rui Ueyama2017-05-241-6/+4
| | | | llvm-svn: 303775
* Do not track section types of previous sections, always use PROGBITS for ↵Dmitry Mikulin2017-05-242-3/+10
| | | | | | | | dummy sections. Fix for PR33029. llvm-svn: 303770
* Don't do a full scan of the type stream before processing records.Zachary Turner2017-05-241-2/+1
| | | | | | | | | | | | | LazyRandomTypeCollection is designed for random access, and in order to provide this it lazily indexes ranges of types. In the case of types from an object file, there is no partial index to build off of, so it has to index the full stream up front. However, merging types only requires sequential access, and when that is needed, this extra work is simply wasted. Changing the algorithm to work on sequential arrays of types rather than random access type collections eliminates this up front scan. llvm-svn: 303707
* Clear OutSec->Sections.Rafael Espindola2017-05-232-10/+22
| | | | | | | | | | | Once the dummy linker script is created, we want it to be used for everything to avoid having two redundant representations that can get out of sync. We were already clearing OutputSections. With this patch we clear the Sections vector of every OutputSection. llvm-svn: 303703
* Use more strict types. NFC.Rafael Espindola2017-05-232-14/+14
| | | | | | | | | By the time we get to linker scripts, all special InputSectionBase should have been combined into synthetic sections, which are a type of InputSection. The net result is that we can use InputSection in a few places that were using InputSectionBase. llvm-svn: 303702
* ELF: The later of --build-id and --build-id= wins.Peter Collingbourne2017-05-232-2/+10
| | | | | | | | | If the compiler driver passes --build-id and the user uses -Wl to pass --build-id= then the user's flag should take precedence. Differential Revision: https://reviews.llvm.org/D33461 llvm-svn: 303689
* [lld] Infer relocation model from module flags in relocatable LTO link.Evgeniy Stepanov2017-05-223-1/+63
| | | | | | Fix for PR33096. llvm-svn: 303579
* Implement various flavors of type merging.Zachary Turner2017-05-221-2/+3
| | | | | | | | | | | | | | Previous algotirhm assumed that types and ids are in a single unified stream. For inputs that come from object files, this is the case. But if the input is already a PDB, or is the result of a previous merge, then the types and ids will already have been split up, in which case we need an algorithm that can accept operate on independent streams of types and ids that refer across stream boundaries to each other. Differential Revision: https://reviews.llvm.org/D33417 llvm-svn: 303577
* Revert r303304: Re-submit r303225: Garbage collect dllimported symbols.Rui Ueyama2017-05-227-147/+27
| | | | | | | | This reverts commit r303304 because it looks like the change introduced a crash bug. At least after that change, LLD with thinlto crashes when linking Chromium. llvm-svn: 303527
* COFF: migrate def parser from LLD to LLVM [2/2]Martell Malone2017-05-205-824/+83
| | | | | | | | | | | | This is split up into two commits. This commit removes the DEF parser from LLD See the previous commit for the creation in LLVM. Reviewers: ruiu Differential Revision: https://reviews.llvm.org/D32689 llvm-svn: 303491
* Resubmit "[CodeView] Provide a common interface for type collections."Zachary Turner2017-05-191-5/+5
| | | | | | | | | | | | This was originally reverted because it was a breaking a bunch of bots and the breakage was not surfacing on Windows. After much head-scratching this was ultimately traced back to a bug in the lit test runner related to its pipe handling. Now that the bug in lit is fixed, Windows correctly reports these test failures, and as such I have finally (hopefully) fixed all of them in this patch. llvm-svn: 303446
* Revert "[CodeView] Provide a common interface for type collections."Zachary Turner2017-05-191-5/+5
| | | | | | | | | | | | | | | | | | This is a squash of ~5 reverts of, well, pretty much everything I did today. Something is seriously broken with lit on Windows right now, and as a result assertions that fire in tests are triggering failures. I've been breaking non-Windows bots all day which has seriously confused me because all my tests have been passing, and after running lit with -a to view the output even on successful runs, I find out that the tool is crashing and yet lit is still reporting it as a success! At this point I don't even know where to start, so rather than leave the tree broken for who knows how long, I will get this back to green, and then once lit is fixed on Windows, hopefully hopefully fix the remaining set of problems for real. llvm-svn: 303409
* [CodeView] Raise the source to ID map out of the TypeStreamMerger.Zachary Turner2017-05-181-2/+3
| | | | | | | This map will be needed to rewrite symbol streams after re-writing the corresponding type streams. llvm-svn: 303390
* [CodeView] Provide a common interface for type collections.Zachary Turner2017-05-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now we have multiple notions of things that represent collections of types. Most commonly used are TypeDatabase, which is supposed to keep mappings from TypeIndex to type name when reading a type stream, which happens when reading PDBs. And also TypeTableBuilder, which is used to build up a collection of types dynamically which we will later serialize (i.e. when writing PDBs). But often you just want to do some operation on a collection of types, and you may want to do the same operation on any kind of collection. For example, you might want to merge two TypeTableBuilders or you might want to merge two type streams that you loaded from various files. This dichotomy between reading and writing is responsible for a lot of the existing code duplication and overlapping responsibilities in the existing CodeView library classes. For example, after building up a TypeTableBuilder with a bunch of type records, if we want to dump it we have to re-invent a bunch of extra glue because our dumper takes a TypeDatabase or a CVTypeArray, which are both incompatible with TypeTableBuilder. This patch introduces an abstract base class called TypeCollection which is shared between the various type collection like things. Wherever we previously stored a TypeDatabase& in some common class, we now store a TypeCollection&. The advantage of this is that all the details of how the collection are implemented, such as lazy deserialization of partial type streams, is completely transparent and you can just treat any collection of types the same regardless of where it came from. Differential Revision: https://reviews.llvm.org/D33293 llvm-svn: 303388
* Use linker script commands in writeMapFile.Rafael Espindola2017-05-184-13/+19
| | | | | | | | | | This converts the last (chronologically) user of OutputSections to use the linker script commands instead. The idea is to convert all uses after fabricateDefaultCommands, so that we have a single representation. llvm-svn: 303384
* Set IMAGE_DLL_CHARACTERISTICS_NO_BIND.Rui Ueyama2017-05-185-13/+10
| | | | | | | | | Our output is not compatible with the Binding feature, so make it explicit that. Differential Revision: https://reviews.llvm.org/D33336 llvm-svn: 303378
* Merge IAT and ILT.Rui Ueyama2017-05-185-16/+14
| | | | | | | | | | | | | | | | | | Previously, LLD-produced executables had IAT (Import Address Table) and ILT (Import Lookup Table) as separate chunks of data, although their contents are identical. My interpretation of the COFF spec when I wrote the COFF linker is that they need to be separate tables even though they are the same. But Peter found that the Windows loader is fine with executables in which IAT and ILT are merged. This is a patch to merge IAT and ILT. I confirmed that an lld-link self-hosted with this patch works fine. Fixes https://bugs.llvm.org/show_bug.cgi?id=33064 Differential Revision: https://reviews.llvm.org/D33326 llvm-svn: 303374
* COFF: Replace DLLNames maps with vectors.Peter Collingbourne2017-05-182-16/+8
| | | | | | | | | The import lists are already binned by DLL name, so there's no need to deduplicate here. Differential Revision: https://reviews.llvm.org/D33330 llvm-svn: 303371
* Use a forward declaration. NFC.Rafael Espindola2017-05-182-1/+3
| | | | llvm-svn: 303363
* Use make<> everywhere in COFF to make it consistent with ELF.Rui Ueyama2017-05-189-143/+112
| | | | | | | | | We've been using make<> to allocate new objects in ELF. We have the same function in COFF, but we didn't use it widely due to negligence. This patch uses the function in COFF to close the gap between ELF and COFF. llvm-svn: 303357
* Alternative way to detemplate GotSection.Rafael Espindola2017-05-186-46/+46
| | | | | | | | | | | | | | | | | | | | GetSection is a template because write calls relocate. relocate has two parts. The non alloc code really has to be a template, as it is looking a raw input file data. The alloc part is only a template because of getSize. This patch folds the value of getSize early, detemplates getRelocTargetVA and splits relocate into a templated non alloc case and a regular function for the alloc case. This has the nice advantage of making sure we collect all the information we need for relocations before getting to InputSection::relocateNonAlloc. Since we know got is alloc, it can just call the function directly and avoid the template. llvm-svn: 303355
OpenPOWER on IntegriCloud