summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove a redundant boolean.Rafael Espindola2015-11-031-2/+2
| | | | llvm-svn: 251921
* Make a method static. NFC.Rafael Espindola2015-11-021-5/+5
| | | | llvm-svn: 251799
* [ELF2] Ensure that .dynsym section is finalized before .gnu.hash.Igor Kudrin2015-11-021-2/+4
| | | | | | | | | It is required to fill up the GNU hash table section before its finalize() method is called. Differential Revision: http://reviews.llvm.org/D14196 llvm-svn: 251789
* [ELF2] R_X86_64_COPY relocation implementedGeorge Rimar2015-10-281-4/+20
| | | | | | Differential revision: http://reviews.llvm.org/D14090. llvm-svn: 251526
* [ELF2] Move sorting and data to the GNU hash table section.Igor Kudrin2015-10-281-51/+49
| | | | | | | | | It is the GNU hash table section that should be reaponsible for storing its own data and applying its requirements for the order to dynamic symbols. Differential Revision: http://reviews.llvm.org/D14084 llvm-svn: 251502
* Another fix of -Wqual-const warning.George Rimar2015-10-251-1/+1
| | | | llvm-svn: 251259
* Add support for merging string from SHF_STRINGS sections.Rafael Espindola2015-10-241-14/+57
| | | | llvm-svn: 251212
* ELF2: Remove setNameOffset and combine that with writeHeader. NFC.Rui Ueyama2015-10-241-0/+1
| | | | llvm-svn: 251193
* ELF2: Rename StringTableSection::getFileOff -> getOffset.Rui Ueyama2015-10-241-5/+5
| | | | | | | | getFileOff functions defined for other classes return an offset from beginning of the file. StringTableSection's getFileOff however returned an offset from beginning of the section. That was confusing. llvm-svn: 251192
* Drop a few const to reduce the noise from the next patch. NFC.Rafael Espindola2015-10-231-2/+2
| | | | llvm-svn: 251140
* ELF2: Implement --gc-sections.Rui Ueyama2015-10-221-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Section garbage collection is a feature to remove unused sections from outputs. Unused sections are sections that cannot be reachable from known GC-root symbols or sections. Naturally the feature is implemented as a mark-sweep garbage collector. In this patch, I added Live bit to InputSectionBase. If and only if Live bit is on, the section will be written to the output. Starting from GC-root symbols or sections, a new function, markLive(), visits all reachable sections and sets their Live bits. Writer then ignores sections whose Live bit is off, so that such sections are excluded from the output. This change has small negative impact on performance if you use the feature because making sections means more work. The time to link Clang changes from 0.356s to 0.386s, or +8%. It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes. That is 4.3% reduction. http://reviews.llvm.org/D13950 llvm-svn: 251043
* [ELF2] Add support for GNU Hash sectionIgor Kudrin2015-10-221-12/+178
| | | | | | | | | | | | | | | | | | | This patch implements --hash-style command line switch. * By default, or with "sysv" or "both" parameters, the linker generates a standard ELF hash section. * With "gnu" or "both", it produces a GNU-style hash section. That section requires the symbols in the dynamic symbol table section, which are referenced in the GNU hash section, to be placed after not hashed ones and to be sorted to correspond the order of hash buckets in the GNU Hash section. The division function, as well as estimations for the section's parameters, are just the first rough attempt and the subjects for further adjustments. Differential Revision: http://reviews.llvm.org/D13815 llvm-svn: 251000
* ELF2: Rename getMostConstrainingVisibility -> getVisibility. NFC.Rui Ueyama2015-10-211-4/+4
| | | | | | The previous name was too long. llvm-svn: 250920
* ELF2: Simplify DT_FLAGS{,_1} handling. NFC.Rui Ueyama2015-10-211-22/+20
| | | | llvm-svn: 250914
* [ELF2] Add support for -z origin.Davide Italiano2015-10-211-2/+6
| | | | llvm-svn: 250907
* Fix symbol value calculation in SHF_MERGE.Rafael Espindola2015-10-201-2/+1
| | | | | | We would get the wrong value if the symbol was in the middle of an entry. llvm-svn: 250865
* [ELF2] Determine the order of entries of symbol tables in the finalize() phase.Igor Kudrin2015-10-201-31/+30
| | | | | | | | | | | | | * Move the responsibility to call SymbolBody::setDynamicSymbolTableIndex() from the hash table to the dynamic symbol table. * Hash table is not longer responsible for filling the dynamic symbol table. * The final order of symbols of both symbol tables is set before writing phase starts. * Remove repeaded scan of the symbol table during writting SymbolTableSection. Differential Revision: http://reviews.llvm.org/D13911 llvm-svn: 250864
* [ELF2] Extract calculation of symbol binding as a separate function.Igor Kudrin2015-10-201-8/+12
| | | | | | Differential Revision: http://reviews.llvm.org/D13910 llvm-svn: 250855
* [ELF2] .shstrtab section implementedGeorge Rimar2015-10-201-3/+2
| | | | | | | | The section header table index of the entry that is associated with the section name string table. Differential Revision: http://reviews.llvm.org/D13904 llvm-svn: 250836
* [ELF2] - Lazy relocation support for x86_64.George Rimar2015-10-201-12/+84
| | | | | | | | Target has supportsLazyRelocations() method which can switch lazy relocations on/off (currently all targets are OFF except x64 which is ON). So no any other targets are affected now. Differential Revision: http://reviews.llvm.org/D13856?id=37726 llvm-svn: 250808
* [ELF2] Correctly set bits when -z now is specified.Davide Italiano2015-10-201-1/+3
| | | | | | | | | | The option now just sets NOW bit in DT_FLAGS_1 but some loaders seem to require also BIND_NOW bit to be set in DT_FLAGS. This is, also, what ld.bfd and gold do. Differential Revision: http://reviews.llvm.org/D13883 llvm-svn: 250799
* [ELF2] Introduce support for -z nodelete. Davide Italiano2015-10-201-1/+3
| | | | llvm-svn: 250771
* [ELF2/OutputSections] Allocate the correct number of entries after r250739.Davide Italiano2015-10-191-1/+3
| | | | llvm-svn: 250760
* [OutputSection] Set the symbolic bit in DT_FLAGS and not DT_FLAGS_1.Davide Italiano2015-10-191-0/+3
| | | | | | | | The two names are similar enough that they might lead to confusion. The output of readobj clarifies but I missed it when I originally committed this. Found while linking FreeBSD userland with lld. llvm-svn: 250739
* Add support for merging the contents of SHF_MERGE sections.Rafael Espindola2015-10-191-12/+78
| | | | | | For now SHF_STRINGS are not supported. llvm-svn: 250737
* Reduce nesting level. NFC.Rui Ueyama2015-10-191-9/+7
| | | | llvm-svn: 250732
* Change getLocalRelTarget to include the addend.Rafael Espindola2015-10-191-11/+20
| | | | | | | | | Given the name, it is natural for this function to compute the full target. This will simplify SHF_MERGE handling by allowing getLocalRelTarget to centralize the addend logic. llvm-svn: 250731
* Simplify by computing on relocation field at a time.Rafael Espindola2015-10-191-19/+21
| | | | llvm-svn: 250730
* [ELF2] In/out parameter of writeGlobalSymbols() is changed to in parameter.Igor Kudrin2015-10-191-1/+1
| | | | | | There is no outer code which requires the changed value. llvm-svn: 250688
* Use a reference. NFC.Rafael Espindola2015-10-161-2/+2
| | | | llvm-svn: 250578
* ELF2: Treat IsMips64EL as a global configuration.Rui Ueyama2015-10-161-6/+5
| | | | | | | | If one file is MIPS64EL, all files are MIPS64EL, and vice versa. We do not have to look up MIPS-ness for each file. Currently we do not support 64-bit MIPS, so the config value is always false. llvm-svn: 250566
* [ELF2] Remove unneeded new Type parameterHal Finkel2015-10-161-8/+7
| | | | | | | As pointed out by Rafael (with a further suggestion by Rui), the new Type parameter I added in r250555 is not needed. Remove it. llvm-svn: 250563
* [ELF2] Don't create RelativeReloc for weak undef symbolsHal Finkel2015-10-161-1/+4
| | | | | | | | | | | | When we have a R_PPC64_ADDR64 for a weak undef symbol, which thus resolves to 0, and we're creating a shared library, we need to make sure that it stays 0 (because code that conditionally calls the weak function tests for this). Unfortunately, we were creating a R_PPC64_RELATIVE for these relocation targets, making the address of the undefined weak symbol equal to the base address of the shared library (which is non-zero). In general, we should not be creating RelativeReloc relocs for undef weak symbols. llvm-svn: 250558
* [ELF2] getLocalRelTarget should handle R_PPC64_TOC directlyHal Finkel2015-10-161-9/+13
| | | | | | | | | | | | | | | | | | | R_PPC64_TOC does not have an associated symbol, but does have a non-zero VA that target-specific code must compute using some non-trivial rule. We handled this as a special case in PPC64TargetInfo::relocateOne, where we knew to write this special address, but that did not work when creating shared libraries. The special TOC address needs to be the subject of a R_PPC64_RELATIVE relocation, and so we also need to know how to encode this special address in the addend of that relocation. Thus, some target-specific logic is necessary when creating R_PPC64_RELATIVE as well. To solve this problem, we teach getLocalRelTarget to handle R_PPC64_TOC as a special case. This allows us to remove the special case in PPC64TargetInfo::relocateOne (simplifying code there), and naturally allows the existing logic to do the right thing when creating associated R_PPC64_RELATIVE relocations for shared libraries. llvm-svn: 250555
* Add a ObjectFile<ELFT>::getSection helper and simplify. NFC.Rafael Espindola2015-10-161-24/+5
| | | | llvm-svn: 250519
* ELF2: Use ELFT to template OutputSections.Rui Ueyama2015-10-151-69/+50
| | | | | | | | | | | | This patch is to use ELFT instead of Is64Bits to template OutputSection and its subclasses. This increases code size slightly because it creates two identical functions for some classes, but that's only 20 KB out of 33 MB, so it's negligible. This is as per discussion with Rafael. He's not fan of the idea but OK with this. We'll revisit later to this topic. llvm-svn: 250466
* ELF2: Move HashTableSection::hash out of the class.Rui Ueyama2015-10-151-0/+12
| | | | | | Because the function does not depend on the class. llvm-svn: 250462
* Remove a getter/setter that don't hide anything.Rui Ueyama2015-10-151-6/+6
| | | | llvm-svn: 250458
* Use OutputSectionBase in a few cases where we don't need a OutputSection.Rafael Espindola2015-10-151-2/+2
| | | | | | | NFC. This is just preparation for adding a new OutputSection dedicated to SHF_MERGE input sections. llvm-svn: 250419
* ELF2: Do not use OutputSection as a member variable name.Rui Ueyama2015-10-151-11/+9
| | | | | | We have OutputSection<ELFT> type. GCC 4.9.2 warns on the duplication. llvm-svn: 250358
* ELF2: Remove {set,get}OutputSection accessors.Rui Ueyama2015-10-141-9/+7
| | | | | | | These accessors didn't provide any additional value over a public member variable, too. llvm-svn: 250328
* ELF2: Remove {set,get}OutputSectionOff accessors.Rui Ueyama2015-10-141-5/+5
| | | | | | | These accessors didn't provide any additional value over a public member variable. llvm-svn: 250326
* Handle dynamic relocs to weak undefined when possible.Rafael Espindola2015-10-141-6/+28
| | | | llvm-svn: 250311
* ELF2: Remove getAddrSize().Rui Ueyama2015-10-141-2/+2
| | | | llvm-svn: 250296
* [ELF2] Don't allocate entry for DT_SYMBOLIC.Davide Italiano2015-10-131-3/+0
| | | | | | | This fixes an oversight from my previous commit. Reported by Rafael Espindola! llvm-svn: 250229
* [ELF2] Add support for -Bsymbolic.Davide Italiano2015-10-131-2/+9
| | | | llvm-svn: 250225
* ELF2: Add comments.Rui Ueyama2015-10-131-1/+5
| | | | llvm-svn: 250215
* Revert r250169: "This patch implements basic variant of lazy loading for ↵Rui Ueyama2015-10-131-80/+11
| | | | | | | | x86_x64 and for X86 targets." With this patch LLD is not able to self-host on x86-64 Linux. llvm-svn: 250182
* Remove trailing whitespaces.Rui Ueyama2015-10-131-1/+1
| | | | llvm-svn: 250170
* This patch implements basic variant of lazy loading for x86_x64 and for X86 ↵George Rimar2015-10-131-11/+80
| | | | | | | | | | | | | | | | | | | targets. What was done: 1) .got.plt section is created for functions that requires PLT. .got.plt has 3 predefined empty entries now that are required for dynamic linker. Also other new items created are configured to have correct jump to PLT[N]. 2) PLT section now has PLT[0] entry, also others ones are configured to support PLT->GOT(.got.plt) calls. 3) Implemented .rel[a].plt sections (based on patch http://reviews.llvm.org/D13569). 4) Fixed plt relocations types (based on patch http://reviews.llvm.org/D13589). NOTES: The .plt.got zero entry is still empty now. According to ELF specification it should hold the address of the dynamic structure, referenced with the symbol _DYNAMIC. The _DYNAMIC entry points to the .dynamic section which contains information used by the ELF interpreter to setup the binary. Differential Revision: http://reviews.llvm.org/D13651 llvm-svn: 250169
OpenPOWER on IntegriCloud