summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Symbols.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* ELF: Only add libcall symbols to the link if defined in bitcode.Peter Collingbourne2018-08-081-0/+9
| | | | | | | | | | | | | | | | | Adding all libcall symbols to the link can have undesired consequences. For example, the libgcc implementation of __sync_val_compare_and_swap_8 on 32-bit ARM pulls in an .init_array entry that aborts the program if the Linux kernel does not support 64-bit atomics, which would prevent the program from running even if it does not use 64-bit atomics. This change makes it so that we only add libcall symbols to the link before LTO if we have to, i.e. if the symbol's definition is in bitcode. Any other required libcall symbols will be added to the link after LTO when we add the LTO object file to the link. Differential Revision: https://reviews.llvm.org/D50475 llvm-svn: 339301
* [ELF] - Simplify Symbol::getSize(). NFC.George Rimar2018-07-171-3/+1
| | | | | | | | | | There are following symbols currently available: DefinedKind, SharedKind, UndefinedKind, LazyArchiveKind, LazyObjectKind. Our code calls getSize() only for first two and there seems to be no reason to return 0 for the rest. llvm-svn: 337265
* [ELF] Do not error for missing version when symbol has local version.Peter Smith2018-05-141-2/+4
| | | | | | | | | | | | | If a symbol with an undefined version in a DSO is not going to be exported into the dynamic symbol table then do not give an error message for the missing version. This can happen with the --exclude-libs option which implicitly gives all symbols in a static library the local version. This matches the behavior of ld.gold and is exploited by the Bionic dynamic linker on Arm. Differential Revision: https://reviews.llvm.org/D43126 llvm-svn: 332224
* Replace SharedSymbols with Defined when creating copy relocations.Rafael Espindola2018-04-261-15/+6
| | | | | | | | | | | | | This is slightly simpler to read IMHO. Now if a symbol has a position in the file, it is Defined. The main motivation is that with this a SharedSymbol doesn't need a section, which reduces the size of SymbolUnion. With this the peak allocation when linking chromium goes from 568.1 to 564.2 MB. llvm-svn: 330966
* Delete GotPltIndex.Rafael Espindola2018-04-261-1/+3
| | | | | | | | | It was always an offset of PltIndex. This doesn't reduce the size of the structures, but makes it easier to do so in a followup patch. llvm-svn: 330953
* Simplify. NFC.Rui Ueyama2018-04-261-9/+9
| | | | llvm-svn: 330892
* Pack symbols a bit more.Rafael Espindola2018-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Before this patch: Symbol 56 Defined 80 Undefined 56 SharedSymbol 88 LazyArchive 72 LazyObject 56 With this patch Symbol 48 Defined 72 Undefined 48 SharedSymbol 80 LazyArchive 64 LazyObject 48 The result is that peak allocation when linking chromium (according to heaptrack) goes from 578 to 568 MB. llvm-svn: 330874
* Also demote lazy symbols.Rafael Espindola2018-04-251-2/+1
| | | | | | | This is not a big simplification right now, but the special cases for lazy symbols have been a common source of bugs in the past. llvm-svn: 330869
* Simplify Repl handling.Rafael Espindola2018-04-191-1/+3
| | | | | | | | | | Now that we don't ICF synthetic sections, we can go back to the old logic on whose responsibility it is to check Repl. The idea is that Sec->something() will not check Repl. It is the responsibility of the caller to find the correct Sec. llvm-svn: 330346
* Simplify getOffset for synthetic sections.Rafael Espindola2018-04-191-0/+1
| | | | | | | | | | We had a single symbol using -1 with a synthetic section. It is simpler to just update its value. This is not a big will by itself, but will allow having a simple getOffset for InputSeciton. llvm-svn: 330340
* [ELF] Add profile guided section layoutMichael J. Spencer2018-04-171-0/+21
| | | | | | | | | | | | | | | | | This adds profile guided layout using the Call-Chain Clustering (C³) heuristic from https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf . RFC: [llvm-dev] [RFC] Profile guided section layout http://lists.llvm.org/pipermail/llvm-dev/2017-June/114178.html Pass `--call-graph-ordering-file <file>` to read a call graph profile where each line has the format: <from symbol> <to symbol> <call count> Differential Revision: https://reviews.llvm.org/D36351 llvm-svn: 330234
* [ELF] - Eliminate Lazy class.George Rimar2018-04-031-6/+0
| | | | | | | | | Patch removes Lazy class which is just an excessive layer. Differential revision: https://reviews.llvm.org/D45083 llvm-svn: 329086
* Merge LazyArchive::fetch() and ArchiveFile::getMember(). NFC.Rui Ueyama2018-04-031-15/+4
| | | | | | | | They are to pull out an object file for a symbol, but for a historical reason the code is written in two separate functions. This patch merges them. llvm-svn: 329039
* Inline two trivial functions that are called only once. NFC.Rui Ueyama2018-04-021-7/+4
| | | | llvm-svn: 329034
* Add a SectionBase::getVA helper. NFC.Rafael Espindola2018-03-241-4/+2
| | | | | | There were a few too many places duplicating this. llvm-svn: 328402
* Move a Repl access.Rafael Espindola2018-03-231-1/+0
| | | | | | | | Since SectionBase::getOutputSection handles ICF replaces and SectionBase::getOffset was handling it in some cases, it is more consistent to have getOffset always handle it. llvm-svn: 328391
* Drop redundant ->Repl.Rafael Espindola2018-03-231-1/+1
| | | | | | | SectionBase::getOutputSection handles replacement sections, so this code doesn't have to. llvm-svn: 328390
* Reduce code duplication a bit.Rafael Espindola2018-03-141-2/+1
| | | | | | | The code for computing the offset of an entry in the plt is simple, but it was duplicated in quite a few places. llvm-svn: 327536
* Consistent (non) use of empty lines in include blocksSam Clegg2018-02-201-1/+0
| | | | | | | | | The profailing style in lld seem to be to not include such empty lines. Clang-tidy/clang-format seem to handle this just fine. Differential Revision: https://reviews.llvm.org/D43528 llvm-svn: 325629
* Add --no-gnu-unique and --no-undefined-version for completeness.Rui Ueyama2018-02-021-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D42865 llvm-svn: 324145
* Define isUndefWeak inline.Rafael Espindola2017-12-211-6/+0
| | | | | | | This small function was showing up in the profile. Defining it inline gives about 0.3% speedup. llvm-svn: 321317
* Use a reference to a file in the LazyArchive symbol.Rafael Espindola2017-12-201-3/+3
| | | | | | It is never null. llvm-svn: 321198
* LazyObject's file is never null, use a reference.Rafael Espindola2017-12-201-2/+2
| | | | llvm-svn: 321196
* Move Repl to SectionBase.Rafael Espindola2017-12-131-7/+3
| | | | | | | | | | | | | | | | It is currently in InputSectionBase. Only InputSections are used in ICF, so Repl should be move to InputSection to clear the class hierarchy or, like this patch does, to SectionBase for convenience. The convenience of having it on the base class is that we can just access the replacement without having to first check if it is an InputSection. It is a bit less code and a bit faster as some of this code is very hot. I got up to 1.77% improvement in clang-gdb-index and no regressions according to lnt. llvm-svn: 320654
* Move Repl check to a symbol method.Rafael Espindola2017-12-131-2/+5
| | | | | | | | | | | | Having a SectionBase method check Repl is inconsistent with how we handle other section information. For example, if a section is replaced, Sec->Live is false and it is natural for Sec->getOutputSection() to be null. It is the symbol that is moved to the replacement section. llvm-svn: 320599
* Remove unused condition.Rui Ueyama2017-11-301-1/+1
| | | | | | | | Looks like all tests pass without this `isLocal()`. Differential Revision: https://reviews.llvm.org/D39780 llvm-svn: 319395
* Use Symbol::File directly.Rafael Espindola2017-11-291-19/+4
| | | | | | | We are already paying the cost of storing a InputFile in every Symbol, so use it uniformly. llvm-svn: 319378
* Replace copyFrom with memcpy.Rafael Espindola2017-11-291-15/+0
| | | | | | | It was only used for --wrap and I don't think the fields with special treatment had a meaningful impact on that feature. llvm-svn: 319265
* Copy the visibility in copyFrom.Rafael Espindola2017-11-281-1/+0
| | | | | | This is simpler and matches bfd's behavior on the changed test. llvm-svn: 319248
* Handle binding in --wrap.Rafael Espindola2017-11-281-1/+0
| | | | | | Copying the binding seems reasonable and matches the bfd behavior. llvm-svn: 319196
* Factor out common code to Common/Strings.cpp.Rui Ueyama2017-11-281-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D40530 llvm-svn: 319138
* Move MIPS-specific code from Symbols.cpp to MIPS.cpp.Rui Ueyama2017-11-071-16/+0
| | | | | | | | | We have a lot of "if (MIPS)" conditions in lld because the MIPS' ABI is different at various places than other arch's ABIs at where it don't have to be different, but we at least want to reduce MIPS-ness from the regular classes. llvm-svn: 317525
* ELF: Remove function Symbol::isInCurrentOutput().Peter Collingbourne2017-11-061-3/+3
| | | | | | This function is now equivalent to isDefined(). llvm-svn: 317449
* ELF: Merge DefinedRegular and Defined.Peter Collingbourne2017-11-061-22/+22
| | | | | | | | | Now that DefinedRegular is the only remaining derived class of Defined, we can merge the two classes. Differential Revision: https://reviews.llvm.org/D39667 llvm-svn: 317448
* ELF: Remove DefinedCommon.Peter Collingbourne2017-11-061-12/+2
| | | | | | | | | Common symbols are now represented with a DefinedRegular that points to a BssSection, even during symbol resolution. Differential Revision: https://reviews.llvm.org/D39666 llvm-svn: 317447
* Rename Body -> Sym.Rui Ueyama2017-11-041-6/+6
| | | | | | | | | | This patch is mechanically created by sed -i -e s/Body/Sym/g lld/ELF/*.{cpp,h} and clang-format-diff. llvm-svn: 317392
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-29/+27
| | | | | | | | | | | | | Now that we have only SymbolBody as the symbol class. So, "SymbolBody" is a bit strange name now. This is a mechanical change generated by perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF) nd clang-format-diff. Differential Revision: https://reviews.llvm.org/D39459 llvm-svn: 317370
* Merge SymbolBody and Symbol into one class, SymbolBody.Rui Ueyama2017-10-311-18/+26
| | | | | | | | | | | | | | | | | | | SymbolBody and Symbol were separated classes due to a historical reason. Symbol used to be a pointer to a SymbolBody, and the relationship between Symbol and SymbolBody was n:1. r2681780 changed that. Since that patch, SymbolBody and Symbol are allocated next to each other to improve memory locality, and they have 1:1 relationship now. So, the separation of Symbol and SymbolBody no longer makes sense. This patch merges them into one class. In order to avoid updating too many places, I chose SymbolBody as a unified name. I'll rename it Symbol in a follow-up patch. Differential Revision: https://reviews.llvm.org/D39406 llvm-svn: 317006
* Pass symbol attributes instead of ElfSym to Shared symbol ctor.Rui Ueyama2017-10-281-23/+2
| | | | | | | This change allows us to use less templates for Shared symbol and the functions that deals with shared symbols. llvm-svn: 316841
* Inline trivial symbol constructors.Rui Ueyama2017-10-271-27/+0
| | | | llvm-svn: 316811
* Rename isInCurrentDSO -> isInCurrentOutput.Rui Ueyama2017-10-271-3/+3
| | | | | | | | | | | | DSO is short for dynamic shared object, so the function name was a little confusing because it sounded like it didn't work when we were a creating statically-linked executable or something. What we mean by "DSO" here is the current output file that we are creating. Thus the new name. Alternatively, we could call it the current ELF module, but "module" is a overloaded word, so I avoided that. llvm-svn: 316809
* Handle all symbol types in --trace.Rafael Espindola2017-10-271-0/+4
| | | | | | | One case I was not sure was lazy symbols. bfd skips them completely, but that is probably an artifact of how they implement archives. llvm-svn: 316782
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-1/+1
| | | | | | | | | | | | | | | | | | | Summary: The COFF linker and the ELF linker have long had similar but separate Error.h and Error.cpp files to implement error handling. This change introduces new error handling code in Common/ErrorHandler.h, changes the COFF and ELF linkers to use it, and removes the old, separate implementations. Reviewers: ruiu Reviewed By: ruiu Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D39259 llvm-svn: 316624
* Refactor duplicated comment. NFC.Rafael Espindola2017-10-241-9/+1
| | | | llvm-svn: 316455
* [LLD] Fix typo. NFCShoaib Meenai2017-10-131-1/+1
| | | | llvm-svn: 315675
* Hide SymbolBody::IsLocal.Rui Ueyama2017-10-131-1/+1
| | | | | | | IsLocal member is initialized by the constructor and will never change. So we don't want to make it directly accessible. llvm-svn: 315667
* Add comment.Rui Ueyama2017-10-131-3/+11
| | | | llvm-svn: 315664
* [ELF] Simpler scheme for handling common symbolsBen Dunbobbin2017-09-291-9/+3
| | | | | | | | | Convert all common symbols to regular symbols after scan. This means that the downstream code does not to handle common symbols as a special case. Differential Revision: https://reviews.llvm.org/D38137 llvm-svn: 314495
* Rename copy -> copyFrom.Rui Ueyama2017-09-251-1/+1
| | | | | | This patch is to improve code readability. llvm-svn: 314089
* Keep some relocations with undefined weak symbols.Rafael Espindola2017-09-151-2/+2
| | | | | | | | | | | | | | | | | | | This fixes pr34301. As the bug points out, we want to keep some relocations with undefined weak symbols. This means that we cannot always claim that these symbols are not preemptible as we do now. Unfortunately, we cannot also just always claim that they are preemptible. Doing so would, for example, cause us to try to create a plt entry when we don't even have a dynamic symbol table. What almost works is to say that weak undefined symbols are preemptible if and only if we have a dynamic symbol table. Almost because we don't want to fail the build trying to create a copy relocation to a weak undefined. llvm-svn: 313372
OpenPOWER on IntegriCloud