summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move Memory.{h,cpp} to Common.Rui Ueyama2017-11-281-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40571 llvm-svn: 319221
* Bring back r319008.Rafael Espindola2017-11-281-2/+3
| | | | | | | | | | | | | | This includes a fix to mark copy reloc aliases as used. Original message: [ELF] Do not keep symbols if they referenced only from discarded sections. This patch also ensures that in case of "--as-needed" is used, DT_NEEDED entries are not created if they are required only by these eliminated symbols. llvm-svn: 319215
* Revert r319008, "[ELF] Do not keep symbols if they referenced only from ↵Igor Kudrin2017-11-281-3/+2
| | | | | | | | | | | discarded sections." and r319051, "Add a missing test." r319008 broke the LTO bots; r319051 depends on changes in r319008. llvm-svn: 319154
* Factor out common code to Common/Strings.cpp.Rui Ueyama2017-11-281-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D40530 llvm-svn: 319138
* Store the real binding of shared symbols.Rafael Espindola2017-11-281-8/+7
| | | | | | | | | | | | | | | | Currently we mark every shared symbol as STB_WEAK. That is a hack to make it easy to decide when a .so is needed or not because of a reference to a given symbol. That hack leaks when we create copy relocations as shown by the update to relocation-copy-alias.s. This patch stores the original binding when we first read a shared symbol. We still have to update the binding to weak if we see a weak undef, but I find the logic easier to read where it is now. llvm-svn: 319127
* Rename `Symtab` private memory to avoid confusion with global `Symtab`Sam Clegg2017-11-271-4/+4
| | | | | | | | | | | This is also consistent with SymVector that exists in COFF port and soon to be added to the wasm port. Split off as part of https://reviews.llvm.org/D40371 Differential Revision: https://reviews.llvm.org/D40525 llvm-svn: 319113
* [ELF] Do not keep symbols if they referenced only from discarded sections.Igor Kudrin2017-11-271-2/+3
| | | | | | | | | | This patch also ensures that in case of "--as-needed" is used, DT_NEEDED entries are not created if they are required only by these eliminated symbols. Differential Revision: https://reviews.llvm.org/D38790 llvm-svn: 319008
* Simplify as-needed handling.Rafael Espindola2017-11-221-2/+2
| | | | | | This is a reduction of a patch by Rui Ueyama. llvm-svn: 318852
* Remove IsLocal.Rafael Espindola2017-11-171-32/+27
| | | | | | | Since we always have Binding in the current symbol design IsLocal is redundant. llvm-svn: 318497
* Simplify. NFC.Rafael Espindola2017-11-111-3/+1
| | | | | | copyFrom doesn't copy the Binding, so this was a nop. llvm-svn: 317965
* Don't produce a duplicated __wrap_foo if there is no __real_foo.Rafael Espindola2017-11-111-4/+4
| | | | | | This fixes a regression from r317426. llvm-svn: 317956
* ELF: Remove SymbolTable::SymIndex class.Peter Collingbourne2017-11-061-12/+11
| | | | | | | | | The Traced flag is unnecessary because we only need to set the index to -1 to mark a symbol for tracing. Differential Revision: https://reviews.llvm.org/D39672 llvm-svn: 317450
* ELF: Remove function Symbol::isInCurrentOutput().Peter Collingbourne2017-11-061-6/+6
| | | | | | This function is now equivalent to isDefined(). llvm-svn: 317449
* ELF: Merge DefinedRegular and Defined.Peter Collingbourne2017-11-061-20/+20
| | | | | | | | | 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-13/+23
| | | | | | | | | 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
* Rewrite addSymbolWrap and applySymbolWrap. NFCI.Rui Ueyama2017-11-041-45/+31
| | | | | | | | | | | | | r317396 changed the way how we handle the -defsym option. The option is now handled using the infrastructure for the linker script. We used to handle both -defsym and -wrap using the same set of functions in the symbol table. Now, we don't need to do that. This patch rewrites the functions so that they become more straightforward. The new functions directly handle -wrap rather than abstract it. llvm-svn: 317426
* Remove dead code and update comment.Rui Ueyama2017-11-041-20/+3
| | | | llvm-svn: 317425
* Rename replaceBody -> replaceSymbol.Rui Ueyama2017-11-031-13/+13
| | | | llvm-svn: 317383
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-106/+99
| | | | | | | | | | | | | 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
* [ELF] - Teach LLD to report line numbers for data symbols.George Rimar2017-11-011-2/+2
| | | | | | | | | | | | | | | | | | | This is PR34826. Currently LLD is unable to report line number when reporting duplicate declaration of some variable. That happens because for extracting line information we always use .debug_line section content which describes mapping from machine instructions to source file locations, what does not help for variables as does not describe them. In this patch I am taking the approproate information about variables locations from the .debug_info section. Differential revision: https://reviews.llvm.org/D38721 llvm-svn: 317080
* Merge SymbolBody and Symbol into one class, SymbolBody.Rui Ueyama2017-10-311-143/+138
| | | | | | | | | | | | | | | | | | | 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
* Remove a redundant temporary variable.Rui Ueyama2017-10-291-2/+1
| | | | llvm-svn: 316862
* Reduce sizeof(Symbol) from 104 bytes to 88 bytes.Rui Ueyama2017-10-281-2/+1
| | | | | | | Finding aliases for shared symbols doesn't need st_shndx because we can just compare st_value. llvm-svn: 316848
* Pass symbol attributes instead of ElfSym to Shared symbol ctor.Rui Ueyama2017-10-281-3/+8
| | | | | | | This change allows us to use less templates for Shared symbol and the functions that deals with shared symbols. llvm-svn: 316841
* Rename isInCurrentDSO -> isInCurrentOutput.Rui Ueyama2017-10-271-6/+6
| | | | | | | | | | | | 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
* De-template elf::getObjMsg. NFC.Rui Ueyama2017-10-271-2/+2
| | | | llvm-svn: 316732
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-2/+2
| | | | | | | | | | | | | | | | | | | 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/+4
| | | | llvm-svn: 316455
* Revert r315877: Simplify.Konstantin Zhuravlyov2017-10-161-2/+2
| | | | | | | | It causes MSVC 2015 to emit "C4307: '-': integral constant overflow" warning Differential Revision: https://reviews.llvm.org/D38955 llvm-svn: 315926
* Remove Config::FirstElf.Rui Ueyama2017-10-151-4/+9
| | | | llvm-svn: 315881
* Simplify.Rui Ueyama2017-10-151-2/+2
| | | | llvm-svn: 315877
* Give shared symbols priority over lazy ones.Rafael Espindola2017-10-131-2/+2
| | | | | | | This matches the behavior of gold and bfd. It also matches lld's own behavior when the shared symbol is seen first llvm-svn: 315766
* Simplify. NFC.Rafael Espindola2017-10-131-1/+1
| | | | llvm-svn: 315734
* Convert a few cases of isUndefined to isInCurrentDSO.Rafael Espindola2017-10-131-3/+3
| | | | | | | I don't think there is an observable difference. We now just avoid doing silly things like setting versions in lazy symbols. llvm-svn: 315650
* Correctly handle shared and lazy symbols.Rafael Espindola2017-10-131-1/+1
| | | | | | | I will try to make this API a bit less error prone, but for now just get another test passing. llvm-svn: 315645
* Inline small function. NFC.Rafael Espindola2017-10-071-15/+0
| | | | llvm-svn: 315141
* Reland r315114, "ELF: Export preempted symbols even if there is a dynamic ↵Peter Collingbourne2017-10-061-1/+1
| | | | | | | | | list." which was reverted in r315116. I hadn't synced past the change that changed the default hash style to --hash-style=both, so my test had the symbols in the wrong order. llvm-svn: 315119
* Revert r315114, "ELF: Export preempted symbols even if there is a dynamic list."Peter Collingbourne2017-10-061-1/+1
| | | | | | | For some reason the symbols get emitted in the wrong order on one of the buildbots: http://bb9.pgr.jp/#builders/15/builds/180 llvm-svn: 315116
* ELF: Export preempted symbols even if there is a dynamic list.Peter Collingbourne2017-10-061-1/+1
| | | | | | | | | | | | Dynamic lists in an executable are additive, not restrictive, so we must continue to export preempted symbols even with a dynamic list. This fixes sanitizer interception of libc symbols (and should also fix symbol preemption by users of sanitizers). Differential Revision: https://reviews.llvm.org/D38647 llvm-svn: 315114
* Refine our --wrap implementation.Rafael Espindola2017-10-061-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | Before this patch we would copy foo into real_foo and wrap_foo into foo. The net result is that __wrap_foo shows up twice in the symbol table. With this patch we: * save a copy of __real_foo before copying foo. * drop one of the __wrap_foo from the symbol table. * if __real_foo was not undefined, add a *new* symbol with that content to the symbol table. The net result is that Anything using foo now uses __wrap_foo Anything using __real_foo now uses foo. Anything using __wrap_foo still does. And the symbol table has foo, __wrap_foo and __real_foo (if defined). Which I think is the desired behavior. llvm-svn: 315097
* Refactor duplicated code.Rafael Espindola2017-10-051-4/+4
| | | | | | | Since VisibleToRegularObj is weaker than LinkerRedefined, this should have no functionality change. llvm-svn: 314954
* Inline a small function.Rui Ueyama2017-10-031-11/+0
| | | | llvm-svn: 314841
* [ELF] Avoid promoting an undefined weak entry symbol to global.Igor Kudrin2017-10-031-8/+18
| | | | | | | Without this patch, lld emits "error: undefined symbol: _start" if it encountered only weak references to that symbol. llvm-svn: 314790
* [ELF] Keep symbols specified by '-u' over LTO.Igor Kudrin2017-10-031-3/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D38348 llvm-svn: 314789
* Make parameter lists of SymbolTable::add* functions more consistent. NFC.Rui Ueyama2017-09-301-11/+10
| | | | llvm-svn: 314591
* Speed up SymbolTable::insert().Rui Ueyama2017-09-261-2/+6
| | | | | | | | | | | | | | | | | SymbolTable::insert() is a hot path function. When linking a clang debug build, the function is called 3.7 million times. The total amount of "Name" string contents is 300 MiB. That means this `Name.find("@@")` scans almost 300 MiB of data. That's far from negligible. StringRef::find(StringRef) uses a sophisticated algorithm, but the function is slow for a short needle. This patch replaces it with StringRef::find(char). This patch alone speeds up a clang debug build link time by 0.5 seconds from 8.2s to 7.7s. That's 6% speed up. It seems too good for this tiny change, but looks like it's real. llvm-svn: 314192
* Rename copy -> copyFrom.Rui Ueyama2017-09-251-1/+1
| | | | | | This patch is to improve code readability. llvm-svn: 314089
* Move Config->SymbolRenaming to SymbolTable.Rui Ueyama2017-09-251-15/+18
| | | | | | | | | | | | In order to keep track of symbol renaming, we used to have Config->SymbolRenaming, and whether a symbol is in the map or not affects its symbol attribute (i.e. "LinkeRedefined" bit). This patch adds "CanInline" bit to Symbol to aggreagate symbol information in one place and removed the member from Config since no one except SymbolTable now uses the table. llvm-svn: 314088
* [ELF] - Introduce std::vector<InputFile *> global arrays.George Rimar2017-09-191-13/+11
| | | | | | | | | | | | This patch removes lot of static Instances arrays from different input file classes and introduces global arrays for access instead. Similar to arrays we have for InputSections/OutputSectionCommands. It allows to iterate over input files in a non-templated code. Differential revision: https://reviews.llvm.org/D35987 llvm-svn: 313619
* Use existing helper. NFC.Rafael Espindola2017-09-131-1/+1
| | | | llvm-svn: 313184
OpenPOWER on IntegriCloud