summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Rewrite addSymbolWrap and applySymbolWrap. NFCI.Rui Ueyama2017-11-041-9/+8
| | | | | | | | | | | | | 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-1/+0
| | | | llvm-svn: 317425
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-30/+29
| | | | | | | | | | | | | 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-26/+25
| | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | This change allows us to use less templates for Shared symbol and the functions that deals with shared symbols. llvm-svn: 316841
* Revert r315877: Simplify.Konstantin Zhuravlyov2017-10-161-2/+3
| | | | | | | | It causes MSVC 2015 to emit "C4307: '-': integral constant overflow" warning Differential Revision: https://reviews.llvm.org/D38955 llvm-svn: 315926
* Simplify.Rui Ueyama2017-10-151-3/+2
| | | | llvm-svn: 315877
* Inline small function. NFC.Rafael Espindola2017-10-071-3/+0
| | | | llvm-svn: 315141
* Refine our --wrap implementation.Rafael Espindola2017-10-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Inline a small function.Rui Ueyama2017-10-031-1/+0
| | | | llvm-svn: 314841
* [ELF] Avoid promoting an undefined weak entry symbol to global.Igor Kudrin2017-10-031-0/+1
| | | | | | | Without this patch, lld emits "error: undefined symbol: _start" if it encountered only weak references to that symbol. llvm-svn: 314790
* Make parameter lists of SymbolTable::add* functions more consistent. NFC.Rui Ueyama2017-09-301-3/+5
| | | | llvm-svn: 314591
* Move Config->SymbolRenaming to SymbolTable.Rui Ueyama2017-09-251-0/+10
| | | | | | | | | | | | 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
* If --dynamic-list is given, only those symbols are preemptible.Rafael Espindola2017-09-081-0/+2
| | | | | | | | | | | | | This allows combining --dynamic-list and version scripts too. The version script controls which symbols are visible, and --dynamic-list controls which of those are preemptible. Unlike previous versions, undefined symbols are still considered preemptible, which was the issue breaking the cfi tests. This fixes pr34053. llvm-svn: 312806
* Revert "Revert "Revert r311468: If --dynamic-list is given, only those ↵Rafael Espindola2017-09-081-2/+0
| | | | | | | | | | symbols are preemptible"" This reverts commit r312757. Evgenii Stepanov reports that it broke some tests. llvm-svn: 312771
* Revert "Revert r311468: If --dynamic-list is given, only those symbols are ↵Rafael Espindola2017-09-071-0/+2
| | | | | | | | | | | | | | preemptible" If --dynamic-list is given, only those symbols are preemptible. This allows combining --dynamic-list and version scripts too. The version script controls which symbols are visible, and --dynamic-list controls which of those are preemptible. This fixes pr34053. llvm-svn: 312757
* Revert r311468: If --dynamic-list is given, only those symbols are preemptibleRui Ueyama2017-08-221-2/+0
| | | | | | This reverts commit r311468 because it broke some CFI bots. llvm-svn: 311497
* If --dynamic-list is given, only those symbols are preemptibleRui Ueyama2017-08-221-0/+2
| | | | | | | | | | | | | | | | | Patch by Rafael Espíndola. This is PR34053. The implementation is a bit of a hack, given the precise location where IsPreemtible is set, it cannot be used from SymbolTable::handleAnonymousVersion. I could add another method to SymbolTable if you think that would be better. Differential Revision: https://reviews.llvm.org/D36499 llvm-svn: 311468
* Remove SymbolTable::findInCurrentDSO.Rui Ueyama2017-08-151-1/+0
| | | | | | | This function doesn't seem to add value to the symbol table as it is easy to write code without it. llvm-svn: 310925
* Rename ObjectFile -> ObjFile.Rui Ueyama2017-07-261-1/+1
| | | | | | | Rename it because it was too easy to conflict with llvm::object::ObjectFile which broke buildbots several times. llvm-svn: 309199
* Detemplate SymbolTable.Rafael Espindola2017-07-261-24/+19
| | | | | | NFC, just makes it easier to access from non templated code. llvm-svn: 309152
* Remove unused declarationsSam Clegg2017-06-301-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D34852 llvm-svn: 306772
* Implement the --exclude-libs option.Rui Ueyama2017-06-211-1/+1
| | | | | | | | | The --exclude-libs option is not a popular option, but at least some programs in Android depend on it, so it's worth to support it. Differential Revision: https://reviews.llvm.org/D34422 llvm-svn: 305920
* Symbols re-defined with -wrap and -defsym need to be excluded from inter-Dmitry Mikulin2017-06-051-2/+3
| | | | | | | | | | procedural optimizations to prevent dropping symbols and allow the linker to process re-directs. PR33145: --wrap doesn't work with lto. Differential Revision: https://reviews.llvm.org/D33621 llvm-svn: 304719
* Revert "Simplify a variable type by using StringRef instead of ↵Rafael Espindola2017-05-251-1/+1
| | | | | | | | | | | CachedHashStringRef." This reverts commit r303787. It caused a slowdown in fast links. That is, links with no debug info or optimizations. llvm-svn: 303925
* Simplify a variable type by using StringRef instead of CachedHashStringRef.Rui Ueyama2017-05-241-1/+1
| | | | | | | | | | 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
* [ELF] - Implemented --defsym option.George Rimar2017-04-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | gnu ld description of option is: --defsym=symbol=expression Create a global symbol in the output file, containing the absolute address given by expression. You may use this option as many times as necessary to define multiple symbols in the command line. A limited form of arithmetic is supported for the expression in this context: you may give a hexadecimal constant or the name of an existing symbol, or use "+" and "-" to add or subtract hexadecimal constants or symbols. If you need more elaborate expressions, consider using the linker command language from a script. Note: there should be no white space between symbol, the equals sign ("="), and expression. In compare with D32082, this patch does not support math expressions and absolute symbols. It implemented via code similar to --wrap. That covers 1 of 3 possible --defsym cases. Differential revision: https://reviews.llvm.org/D32171 llvm-svn: 301391
* Remove DefinedSynthetic.Rafael Espindola2017-03-081-4/+1
| | | | | | | | | | | | | With this we have a single section hierarchy. It is a bit less code, but the main advantage will be in a future patch being able to handle foo = symbol_in_obj; in a linker script. Currently that fails since we try to find the output section of symbol_in_obj. With this we should be able to just return an InputSection from the expression. llvm-svn: 297313
* Use uint32_t for alignment in more places, NFC.Rafael Espindola2017-03-081-1/+1
| | | | llvm-svn: 297305
* Convert a few uses of uintX_t to uint64_t.Rafael Espindola2017-03-081-4/+3
| | | | llvm-svn: 297282
* De-template DefinedRegular.Rui Ueyama2017-02-281-5/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* Move SymbolTable<ELFT>::Sections out of the class.Rui Ueyama2017-02-271-2/+0
| | | | | | | | | | The list of all input sections was defined in SymbolTable class for a historical reason. The list itself is not a template. However, because SymbolTable class is a template, we needed to pass around ELFT to access the list. This patch moves the list out of the class so that it doesn't need ELFT. llvm-svn: 296309
* Merge OutputSectionBase and OutputSection. NFC.Rafael Espindola2017-02-241-3/+2
| | | | | | | Now that all special sections are SyntheticSections, we only need one OutputSection class. llvm-svn: 296127
* Convert InputSectionBase to a class.Rafael Espindola2017-02-231-2/+2
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
* [ELF] Insert linkerscript symbols directly into symbol tablePetr Hosek2017-02-211-5/+5
| | | | | | | | | | This change exposes the symbol table insert method and uses it to insert the linkerscript defined symbols directly into the symbol table to avoid unnecessarily pulling the object out of an archive. Differential Revision: https://reviews.llvm.org/D30224 llvm-svn: 295780
* Add a isInCurrentDSO helper. NFC.Rafael Espindola2017-01-171-1/+1
| | | | llvm-svn: 292228
* Don't add DT_INIT/DT_FINI for undef and shared symbols.Rafael Espindola2017-01-131-0/+1
| | | | | | | | | | The freebsd dynamic linker doesn't check if the value is null (and it is reasonable for it to do that). That means that producing a .so with a null DT_INIT/DT_FINI causes the base address to be called. This should fix the libreoffice build. llvm-svn: 291944
* Define a getter function for a lazily-created object.Rui Ueyama2016-12-221-1/+1
| | | | | | | | Previously, you had to call initDemangledSyms() before accessing DemangledSyms. Now getDemangledSyms() initializes it and then returns it. So it is now less easy to use it in a wrong way. llvm-svn: 290323
* Remove a typedef that is used only once.Rui Ueyama2016-12-221-3/+1
| | | | llvm-svn: 290318
* Rename find(SymbolVersion) to avoid overloading with find(StringRef).Rui Ueyama2016-12-101-2/+2
| | | | llvm-svn: 289293
* Change the implementation of --dynamic-list to use linker script parsing.Rafael Espindola2016-12-081-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | The feature is documented as ----------------------------- The format of the dynamic list is the same as the version node without scope and node name. See *note VERSION:: for more information. -------------------------------- And indeed qt uses a dynamic list with an 'extern "C++"' in it. With this patch we support that The change to gc-sections-shared makes us match bfd. Just because we kept bar doesn't mean it has to be in the dynamic symbol table. The changes to invalid-dynamic-list.test and reproduce.s are because of the new parser. The changes to version-script.s are the only case where we change behavior with regards to bfd, but I would like to see a mix of --version-script and --dynamic-list used in the wild before complicating the code. llvm-svn: 289082
* Inline function called only once.Rafael Espindola2016-12-081-1/+0
| | | | llvm-svn: 289067
* Inline two functions called only once. NFC.Rafael Espindola2016-12-081-2/+0
| | | | llvm-svn: 289065
* Add two helper functions. NFC.Rafael Espindola2016-12-081-0/+2
| | | | llvm-svn: 289064
* [ELF] Correct addAbsolute function argument nameSimon Atanasyan2016-12-081-1/+1
| | | | | | Follow-up to r289025. llvm-svn: 289061
* [ELF][MIPS] Make _gp, _gp_disp, __gnu_local_gp global symbolsSimon Atanasyan2016-12-081-1/+2
| | | | | | | | | | | | | | These MIPS specific symbols should be global because in general they can have an arbitrary value. By default this value is a fixed offset from .got section. This patch adds more checks to the mips-gp-local.s test case but marks it as XFAIL because LLD does not allow redefinition of absolute symbols value by a linker script. This should be fixed by D27276. Differential revision: https://reviews.llvm.org/D27524 llvm-svn: 289025
* Introduce StringRefZ class to represent null-terminated strings.Rui Ueyama2016-11-291-2/+3
| | | | | | | | | | | | | | StringRefZ is a class to represent a null-terminated string. String length is computed lazily, so it's more efficient than StringRef to represent strings in string table. The motivation of defining this new class is to merge functions that only differ in string types; we have many constructors that takes `const char *` or `StringRef`. With StringRefZ, we can merge them. Differential Revision: https://reviews.llvm.org/D27037 llvm-svn: 288172
* [ELF] Be compliant with LLVM and rename Lto into LTO. NFCI.Davide Italiano2016-11-261-2/+2
| | | | llvm-svn: 287967
* Remove one of SymbolTable::addRegular function that forwards other addRegular.Rui Ueyama2016-11-231-2/+0
| | | | | | So that we have less number of overloaded functions. llvm-svn: 287745
* Parse symbol versions in scanVersionScript() instead of insert().Rui Ueyama2016-11-231-2/+2
| | | | | | | | | | | | | | | | There are two ways to set symbol versions. One way is to use symbol definition file, and the other is to embed version names to symbol names. In the latter way, symbol name is in the form of `foo@version1` where `foo` is a real name and `version1` is a version. We were parsing symbol names in insert(). That seems unnecessarily too early. We can do it later after we resolve all symbols. Doing it lazily is a good thing because it makes code easier to read (because now we have a separate pass to parse symbol names). Also it could slightly improve performance because if two identical symbols have versions, we now parse them only once. llvm-svn: 287741
OpenPOWER on IntegriCloud