summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Enable merging of SHF_MERGE sections with linker scripts.Rafael Espindola2016-09-131-5/+20
| | | | | | | | | This also fixes the related problem of non SHF_MERGE sections with different flags not being merged. Fixes pr30355. llvm-svn: 281338
* Turn createKey into a static helper. NFC.Rafael Espindola2016-09-131-18/+18
| | | | llvm-svn: 281325
* Define writeUint and use it. NFC.Rui Ueyama2016-09-081-10/+13
| | | | llvm-svn: 280994
* Compute section names only once.Rafael Espindola2016-09-081-4/+4
| | | | | | | | This simplifies error handling as there is now only one place in the code that needs to consider the possibility that the name is corrupted. Before we would do it in every access. llvm-svn: 280937
* Pack InputSectionData from 72 to 64 bytes. NFC.Rafael Espindola2016-09-081-1/+1
| | | | llvm-svn: 280925
* [ELF][MIPS] Fix initialization of TLS-related GOT entriesSimon Atanasyan2016-09-081-2/+29
| | | | | | | | | | | | | | This patch allows static linking of TLS code. To do that it fixes GOT entries initialization. If TLS-related GOT entry created for a preemptible symbol i.e. has a corresponding dynamic relocation, leave the entry initialized by zero. Write down adjusted TLS symbol's values otherwise. For the adjustments calculation use offsets for thread-local storage. https://www.linux-mips.org/wiki/NPTL llvm-svn: 280914
* [ELF][MIPS] Do not emit DT_REL[A]COUNT for MIPS targetsSimon Atanasyan2016-09-041-3/+8
| | | | | | | | It looks like MIPS dynamic loader does not support RELCOUNT tag. Both gold/bfd linkers does not emit this tag on MIPS. I will investigate the problem further but for now it is better to behave like GNU linkers. llvm-svn: 280630
* [ELF] - Fix for: bug 30237 - lld does not implement -f optionGeorge Rimar2016-09-021-0/+2
| | | | | | | | | | | | | FreeBSD's libstdc++ build (used on tier-2 architectures) uses GNU ld's -f <name> option, which sets the DT_AUXILIARY field to the specified name. Multiple -f options may be specified and the DT_AUXILIARY entries will be added in the order in which they appear. Patch implements that option. Differential revision: https://reviews.llvm.org/D24139 llvm-svn: 280475
* [ELF] Do not omit debug sections when computing build-idPetr Hosek2016-09-011-14/+10
| | | | | | | | | | The primary use of build-id is in debugging, hence omitting debug sections when computing it significantly reduces its usability as changes in debug section content wouldn't alter the build-id. Differential Revision: https://reviews.llvm.org/D24120 llvm-svn: 280421
* Eliminate LayoutInputSection classEugene Leviant2016-09-011-2/+0
| | | | | | | | | | Previously we used LayoutInputSection class to correctly assign symbols defined in linker script. This patch removes it and uses pointer to preceding input section in SymbolAssignment class instead. Differential revision: https://reviews.llvm.org/D23661 llvm-svn: 280348
* Delete DefinedBitcode.Rafael Espindola2016-08-311-2/+0
| | | | | | | Given that we almost always want to handle it as DefinedRegular, just use DefinedRegular. llvm-svn: 280226
* Add DT_REL(A)COUNT tag to .dynamic sectionEugene Leviant2016-08-311-0/+11
| | | | | | | | | | This patch groups relative relocations in a single block in combrelocs mode and adds DT_RELCOUNT or DT_RELACOUNT tag to .dynamic section Differential revision: https://reviews.llvm.org/D23661 llvm-svn: 280210
* [ELF] - Introduce DiscardPolicy instead of 3 relative bool fields.George Rimar2016-08-311-1/+1
| | | | | | | | | | | DiscardPolicy is enum replacing several boolean options. This approach is not only consistent with what we use for unresolveds (UnresolvedPolicy), but also should help to solve a problem of options with opposing meanings, mentioned in PR28843 Differential revision: https://reviews.llvm.org/D23868 llvm-svn: 280209
* Implement support for --build-id=uuid switchEugene Leviant2016-08-261-1/+12
| | | | | | Differential revision: https://reviews.llvm.org/D23349 llvm-svn: 279810
* [ELF] - Fix for PR28976 - Corrupted section contents when using linker scriptsGeorge Rimar2016-08-191-1/+1
| | | | | | | | | | | | This is fix for PR28976. Problem was that in scanRelocs, we computed relocation offset too early for case when linkerscript was used. Patch fixes the issue delaying the calculation. Differential revision: https://reviews.llvm.org/D23655 llvm-svn: 279264
* [ELF] - Linkerscript: set correct dynamic tag entries values when LS is used.George Rimar2016-08-191-3/+6
| | | | | | | | | | | | Previously DT_PREINIT_ARRAYSZ, DT_INIT_ARRAYSZ and DT_FINI_ARRAYSZ were set to zero when lincerscript was used becase sections sizes are calculated later that were taken. Patch delays values calculation for these entries. Testcase is provided. Differential revision: https://reviews.llvm.org/D23663 llvm-svn: 279258
* [ELF] - Do not change binding of symbols when creating relocatable output.George Rimar2016-08-191-0/+2
| | | | | | | | | | | | | Spec says "A hidden symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object". But we previously converted symbols to STB_LOCAL even when -r was specified. Broken binary was produced, this is PR28967, patch fixes the issue. Differential revision: https://reviews.llvm.org/D23514 llvm-svn: 279220
* [ELF][MIPS] Support .MIPS.abiflags sectionSimon Atanasyan2016-08-121-0/+48
| | | | | | | This section supersedes .reginfo and .MIPS.options sections. But for now we have to support all three sections for ABI transition period. llvm-svn: 278482
* Simplify output section ownership management.Rui Ueyama2016-08-121-1/+1
| | | | | | | | | One reason why we are (ab)using OutputSectionFactory class is because it owns output sections. Technically there's no need to have it own sections. So, this patch transfers the ownership to Out<ELFT>. llvm-svn: 278452
* [ELF] Symbol assignment within output section descriptionEugene Leviant2016-08-111-0/+2
| | | | llvm-svn: 278322
* [ELF] - Removed dead code. NFC.George Rimar2016-08-091-7/+0
| | | | llvm-svn: 278115
* Remove isOutputDynamic and use Out<ELFT>::DynSymTab instead.Rui Ueyama2016-08-091-1/+1
| | | | | | | This patch is to not instantiate DynSymTab and DynStrTab if the output is not a dynamic output. llvm-svn: 278095
* Remove redundant variable.Rui Ueyama2016-08-091-2/+3
| | | | llvm-svn: 278094
* Separate {Preinit,Init,Fini}Arrays from Out<ELFT>::Dynamic.Rui Ueyama2016-08-091-9/+9
| | | | | | | | Even if an output is not a dynamic object, the output may have .{preinit,init,fini} sections. Therefore, managing these sections as Out<ELFT>::Dynamic's members is not correct. llvm-svn: 278093
* Remove DefinedCommon::Section.Rui Ueyama2016-08-021-1/+1
| | | | | | | Since CommonInputSection is a singleton class, we don't need to store pointers to all DefinedCommon symbols. llvm-svn: 277410
* [ELF] Allows setting section for common symbols in linker scriptEugene Leviant2016-07-281-1/+1
| | | | llvm-svn: 277023
* Make toPhdrFlags a member function. NFC.Rafael Espindola2016-07-271-0/+10
| | | | llvm-svn: 276868
* Fix PR28575.Rafael Espindola2016-07-211-30/+12
| | | | | | | | | | Not all relocations from a .eh_frame that point to an executable section should be ignored. In particular, the relocation finding the personality function should not. This is a reduction from trying to bootstrap a static lld on linux. llvm-svn: 276329
* Create thunks before regular relocation scan.Rafael Espindola2016-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We will need to do something like this to support range extension thunks since that process is iterative. Doing this also has the advantage that when doing the regular relocation scan the offset in the output section is known and we can just store that. This reduces the number of times we have to run getOffset and I think will allow a more specialized .eh_frame representation. By itself this is already a performance win. firefox master 7.295045737 patch 7.209466989 0.98826892235 chromium master 4.531254468 patch 4.509221804 0.995137623774 chromium fast master 1.836928973 patch 1.823805241 0.992855612714 the gold plugin master 0.379768791 patch 0.380043405 1.00072310839 clang master 0.642698284 patch 0.642215663 0.999249070657 llvm-as master 0.036665467 patch 0.036456225 0.994293213284 the gold plugin fsds master 0.40395817 patch 0.404384555 1.0010555177 clang fsds master 0.722045545 patch 0.720946135 0.998477367518 llvm-as fsds master 0.03292646 patch 0.032759965 0.994943428477 scylla master 3.427376378 patch 3.368316181 0.98276810292 llvm-svn: 276146
* Simplify output section ownership.Rui Ueyama2016-07-201-0/+1
| | | | | | | | | This patch simplifies output section management by making Factory class have ownership of sections that creates. Differential Revision: https://reviews.llvm.org/D22575 llvm-svn: 276141
* Remove SymbolBody::PlaceholderKind.Rui Ueyama2016-07-181-1/+0
| | | | | | | | | | | | | In the last patch for --trace-symbol, I introduced a new symbol type PlaceholderKind and store it to SymVector storage. It made all code that iterates over SymVector to recognize and skip PlaceholderKind symbols. I found that that's annoying. In this patch, I removed PlaceholderKind and stop storing them to SymVector. Now the information whether a symbol is being watched by --trace-symbol is stored to the Symtab hash table. llvm-svn: 275747
* Implement almost-zero-cost --trace-symbol.Rui Ueyama2016-07-171-0/+1
| | | | | | | | | | | | | | | | | | | | --trace-symbol is a command line option to watch a symbol. Previosly, we looked up a hash table for a new symbol if the option is given. Any code that looks up a hash table for each symbol is expensive because the linker handles a lot of symbols. In our design, we look up a hash table strictly only once for a symbol, so --trace-symbol was an exception. This patch improves efficiency of the option by merging the hash table into the symbol table. Instead of looking up a separate hash table with a string, this patch sets `Traced` flag to symbols specified by --trace-symbol. So, if you insert a symbol and get a symbol with `Traced` flag on, you know that you need to print out a log message for the symbol. This is nearly zero cost. llvm-svn: 275716
* Add a pointer to a source file to SymbolBody.Rui Ueyama2016-07-171-2/+2
| | | | | | | | | | | | Previously, each subclass of SymbolBody had a pointer to a source file from which it was created. So, there was no single way to get a source file for a symbol. We had getSourceFile<ELFT>(), but the function was a bit inconvenient as it's a template. This patch makes SymbolBody have a pointer to a source file. If a symbol is not created from a file, the pointer has a nullptr. llvm-svn: 275701
* Remove redundant namespace specifiers.Rui Ueyama2016-07-161-3/+3
| | | | llvm-svn: 275694
* Rename SymbolVersions VersionDefinitions.Rui Ueyama2016-07-161-3/+3
| | | | | | SymbolVersions sounds like it had versions for a symbol, so rename it. llvm-svn: 275674
* Rename Version VersionDefinition.Rui Ueyama2016-07-161-2/+2
| | | | | | | | | | | The identifier `Version` was used too often in the code to handle symbol versions. The struct that contains version definitions is named `Version`. Local variables for version ID are named `Version`. Local varaible for version string are named `Version`. This patch give them different names. llvm-svn: 275673
* Remove redundant variable.Rui Ueyama2016-07-161-3/+2
| | | | llvm-svn: 275667
* Set sh_addralign in the constructor for consistency. NFC.Rui Ueyama2016-07-161-2/+3
| | | | llvm-svn: 275666
* Make Verdef and Verdaux adjacent in the version definition section.Rui Ueyama2016-07-161-21/+17
| | | | | | | | Previously, Verdefs and Verdauxs are separated in the section. The new layout is easier to write as we do not have to maintain two pointers and can avoid passing a reference to a pointer. llvm-svn: 275665
* Use SymbolVersion::Id instead of a hard-coded local variable.Rui Ueyama2016-07-161-2/+1
| | | | llvm-svn: 275660
* Set DT_MIPS_BASE_ADDRESS correctly if -image-base is given.Rui Ueyama2016-07-141-1/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D22323 llvm-svn: 275446
* Set sh_addralign to 1 instead of 0.Rui Ueyama2016-07-141-4/+2
| | | | | | | | ELF spec says that alignment of 0 is equivalent to 1. Previously, we arbitrary set to 0 or 1, but always setting to 1 makes our program simpler. llvm-svn: 275374
* Add GotEntrySize/GotPltEntrySize to ELF target.Rui Ueyama2016-07-131-5/+5
| | | | | | | | | | | | | Patch by H.J Lu. For x86-64 psABI, the entry size of .got and .got.plt sections is 8 bytes for both LP64 and ILP32. Add GotEntrySize and GotPltEntrySize to ELF target instead of using size of ELFT::uint. Now we can generate a simple working x32 executable. Differential Revision: http://reviews.llvm.org/D22288 llvm-svn: 275301
* Rename VAStart -> ImageBase. NFC.Rui Ueyama2016-07-131-1/+1
| | | | | | | | | | Config members are named after corresponding command line options. This patch renames VAStart ImageBase so that they are in line with --image-base. Differential Revision: http://reviews.llvm.org/D22277 llvm-svn: 275298
* Recommit r275161 "[ELF] - Move section factory out from writer to make it ↵George Rimar2016-07-121-0/+91
| | | | | | | | | | | | | | | | | | reusable." With fix: * fixed compilation error under linux: template <class ELFT> class OutputSectionFactory { ... typedef typename SectionKey<ELFT::Is64Bits> Key; changed to: template <class ELFT> class OutputSectionFactory { ... typedef typename elf::SectionKey<ELFT::Is64Bits> Key; llvm-svn: 275166
* Revert r275161 "[ELF] - Move section factory out from writer to make it ↵George Rimar2016-07-121-91/+0
| | | | | | | | | reusable." It broke build bot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-debian-fast/builds/39652 llvm-svn: 275163
* [ELF] - Move section factory out from writer to make it reusable.George Rimar2016-07-121-0/+91
| | | | | | | | | | | Since linkerscript should create sections by itself (if SECTIONS command is present), then we might want to reuse the OutputSectionFactory (D19976 already do that now), so this patch moves it out from writer cpp file for that purpose. Differential revision: http://reviews.llvm.org/D19977 llvm-svn: 275161
* [gardening] Switch back to auto. NFCI.Davide Italiano2016-07-061-3/+1
| | | | | | Pointed out by: Rui Ueyama. llvm-svn: 274643
* [OutputSection] Work around GCC not being able to deduce auto.Davide Italiano2016-07-041-5/+10
| | | | | | | | | | | | | | | | | | | The build otherwise fails with: [ 39%] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o /export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp: In member function ‘void lld::elf::GnuHashTableSection<ELFT>::addSymbols(std::vector<std::pair<lld::elf::SymbolBody*, long unsigned int> >&)’: /export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp:585:8: error: inconsistent deduction for ‘auto’: ‘auto’ and then ‘__gnu_cxx::__normal_iterator<std::pair<lld::elf::SymbolBody*, long unsigned int>*, std::vector<std::pair<lld::elf::SymbolBody*, long unsigned int> > >’ Reported by: H. J. Liu llvm-svn: 274518
* [ELF] - Depricate version references.George Rimar2016-07-011-25/+4
| | | | | | | | | | | | | | | | This is PR28358 According to https://www.akkadia.org/drepper/dsohowto.pdf "The fourth point, the VERS 1.0 version being referred to in the VERS 2.0 definition, is not really important in symbol versioning. It marks the predecessor relationship of the two versions and it is done to maintain the similar- ities with Solaris’ internal versioning. It does not cause any problem it might in fact be useful to a human reader so predecessors should always be mentioned." Patch partially reverts 273423 "[ELF] - Implemented version script hierarchies.", version references are just ignored now. Differential revision: http://reviews.llvm.org/D21888 llvm-svn: 274345
OpenPOWER on IntegriCloud