summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Accept not only --reproduce <foo> but also --reproduce=<foo>.Rui Ueyama2017-05-251-0/+1
| | | | llvm-svn: 303905
* 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
* Improve parallelism of ICF.Rui Ueyama2017-05-241-2/+2
| | | | | | | | | | | | | | | 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
* Do not track section types of previous sections, always use PROGBITS for ↵Dmitry Mikulin2017-05-241-3/+1
| | | | | | | | dummy sections. Fix for PR33029. llvm-svn: 303770
* 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-231-2/+6
| | | | | | | | | 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-221-1/+6
| | | | | | Fix for PR33096. llvm-svn: 303579
* 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
* Use a forward declaration. NFC.Rafael Espindola2017-05-182-1/+3
| | | | llvm-svn: 303363
* 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
* Fix flag to start with 1 << 0. NFC.Rafael Espindola2017-05-181-16/+16
| | | | | | Thanks to Andrew Ng for noticing it. llvm-svn: 303354
* [ELF] Support R_ARM_SBREL32 RelocationPeter Smith2017-05-183-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | This change adds support for the R_ARM_SBREL32 relocation. The relocation is a base relative relocation that is produced by clang/llvm when -frwpi is used. The use case for the -frwpi option is position independent data for embedded systems that do not have a GOT. With -frwpi all data is accessed via an offset from a base register (usually r9), where r9 is set at run time to where the data has been loaded. The base of the data is known as the static base. The ARM ABI defines the static base as: B(S) is the addressing origin of the output segment defining the symbol S. The origin is not required to be the base address of the segment. For simplicity we choose to use the base address of the segment. The ARM procedure call standard only defines a read write variant using R_ARM_SBREL32 relocations. The read-only data is accessed via pc-relative offsets from the code, this is implemented in clang as -fropi. Fixes PR32924 Differential Revision: https://reviews.llvm.org/D33280 llvm-svn: 303337
* [ELF] - Detemplate Thunk creation.George Rimar2017-05-175-96/+68
| | | | | | | | | Nothing special here, just detemplates code that became possible to detemplate after recent commits in a straghtforward way. Differential revision: https://reviews.llvm.org/D33234 llvm-svn: 303237
* [ELF] - Update for LLVM's r303163 change. NFCi.George Rimar2017-05-161-4/+4
| | | | llvm-svn: 303164
* [ELF] - Detemplate elf::addSyntheticLocal(). NFC.George Rimar2017-05-164-28/+14
| | | | llvm-svn: 303155
* [ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.George Rimar2017-05-164-61/+45
| | | | | | Follow up for r303150. llvm-svn: 303153
* [ELF] - Detemplate GnuHashTableSection and SymbolTableSection sections.George Rimar2017-05-163-47/+43
| | | | | | | | | | SymbolTableBaseSection was introduced. Detemplation of SymbolTableSection should allow to detemplate more things. Differential revision: https://reviews.llvm.org/D33124 llvm-svn: 303150
* [ELF] - Use llvm::to_integer() instead of StringRef::getAsInteger().George Rimar2017-05-164-13/+13
| | | | | | | | | | | Switch to llvm::to_integer() everywhere in LLD instead of StringRef::getAsInteger() because API of latter is confusing. It returns true on error and false otherwise what makes reading the code incomfortable. Differential revision: https://reviews.llvm.org/D33187 llvm-svn: 303149
* ELF: --gdb-index: Change findSection to return an InputSection.Peter Collingbourne2017-05-152-8/+9
| | | | | | | | | | | | | | | | | | | | We should only ever expect this function to return a regular InputSection; I would not expect a function definition to be in a MergeInputSection or EhInputSection. We were previously crashing in writeTo if this function returned a section that was not an InputSection because we do not set OutSec for such sections. This can happen in practice if a function is defined in an empty section which shares its offset-in-file with a MergeInputSection, as in the provided test case. A better fix for this bug would be to fix the DWARFUnit::collectAddressRanges() interface to provide section information (see D33183), but this at least fixes the crash. Differential Revision: https://reviews.llvm.org/D33176 llvm-svn: 303089
* ELF: --gdb-index: Do not add dead sections to the address area.Peter Collingbourne2017-05-151-1/+1
| | | | | | | | Fixes PR33032. Differential Revision: https://reviews.llvm.org/D33175 llvm-svn: 303088
* [ELF] - Apply clang-format. NFC.George Rimar2017-05-121-13/+28
| | | | llvm-svn: 302921
* Optimize orphan placement in a general way.Rafael Espindola2017-05-122-117/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | We used to place orphans by just using compareSectionsNonScript. Then we noticed that since linker scripts can use another order, we should first try match the section to a given PT_LOAD. But there is nothing special about PT_LOAD. The same issue can show up for PT_GNU_RELRO for example. In general, we have to search for the most similar section and put the orphan next to it. Most similar being defined as how long they follow the same code path in compareSecitonsNonScript. That is what this patch does. We now compute a rank for each output section, with a bit for each branch in what was compareSectionsNonScript. With this findOrphanPos is now fully general and orphan placement can be optimized by placing every section with the same rank at once. The included testcase is a variation of many-sections.s that uses allocatable sections to avoid the fast path in the existing code. Without threads it goes form 46 seconds to 0.9 seconds. llvm-svn: 302903
* [ELF] - Stop support of DF_STATIC_TLS flag.George Rimar2017-05-123-21/+9
| | | | | | | | This reverts changes introduced in r302414 "[ELF] - Set DF_STATIC_TLS flag for i386 target." Because DF_STATIC_TLS does not look to be used by glibc or anything else. llvm-svn: 302884
* [ELF] - Don't allow R_X86_64_TPOFF32 dynamic relocation when linking PICGeorge Rimar2017-05-121-1/+2
| | | | | | | | | | | | | | Both gold and bfd restrict that one: ld.bfd: test.o: relocation R_X86_64_TPOFF32 against `var' can not be used when making a shared object; recompile with -fPIC ld.gold: error: test.o: unsupported reloc 23 against global symbol var What looks reasonable because it is 32 bit one. Patch do the same. Differential revision: https://reviews.llvm.org/D33100 llvm-svn: 302881
* Detemplate compareSections. NFC.Rafael Espindola2017-05-111-2/+1
| | | | llvm-svn: 302849
* Detemplate compareSectionsNonScript. NFC.Rafael Espindola2017-05-111-5/+3
| | | | llvm-svn: 302848
* Detemplate isRelroSection. NFC.Rafael Espindola2017-05-112-10/+5
| | | | llvm-svn: 302847
* Detemplate SymbolBody::getGotVA. NFC.Rafael Espindola2017-05-113-10/+5
| | | | llvm-svn: 302846
* Detemplate the got.Rafael Espindola2017-05-117-63/+63
| | | | | | This is a bit hackish, but allows for a lot of followup cleanups. llvm-svn: 302845
* Reduce templating. NFC.Rafael Espindola2017-05-114-11/+11
| | | | llvm-svn: 302843
* Reduce template usage. NFC.Rafael Espindola2017-05-115-78/+77
| | | | llvm-svn: 302832
* Reduce template usage. NFC.Rafael Espindola2017-05-114-35/+32
| | | | llvm-svn: 302828
* Reduce template usage. NFC.Rafael Espindola2017-05-114-9/+9
| | | | llvm-svn: 302826
* [Support] Move Parallel algorithms from LLD to LLVM.Zachary Turner2017-05-111-5/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D33024 llvm-svn: 302748
* Remove unused #include.Rui Ueyama2017-05-101-1/+0
| | | | llvm-svn: 302719
* Rename parallelFor -> parallelForEachN.Rui Ueyama2017-05-105-6/+6
| | | | | | So that it is clear that the function is a wrapper for for_each_n. llvm-svn: 302718
* Use a DenseMap in LinkerScript::getCmd.Rafael Espindola2017-05-102-7/+12
| | | | | | This improves many-sections.s with a linker script from 22s to 0.9s. llvm-svn: 302708
* Refactor OutputSection to OutputSectionCommand mapping.Rafael Espindola2017-05-102-31/+25
| | | | | | We now always use getCmd. I will optimize it in a followup commit. llvm-svn: 302706
* [ELF] Improve error message for incompatible section typesRui Ueyama2017-05-101-2/+5
| | | | | | | | | | | | | | | | | Previously we were not printing out the type of the incompatible section which made it difficult to determine what the problem was. The error message format has been change to the following: error: section type mismatch for .shstrtab >>> <internal>:(.shstrtab): SHT_STRTAB >>> output section .shstrtab: Unknown Patch by Alexander Richardson. Differential Revision: https://reviews.llvm.org/D32488 llvm-svn: 302694
OpenPOWER on IntegriCloud