summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* If --dynamic-list is given, only those symbols are preemptible.Rafael Espindola2017-09-081-0/+19
| | | | | | | | | | | | | 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-19/+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/+19
| | | | | | | | | | | | | | 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-19/+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/+19
| | | | | | | | | | | | | | | | | 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
* Rename {Lazy,}ObjectKind -> {Lazy,}ObjKind.Rui Ueyama2017-08-191-1/+1
| | | | | | | I renamed corresponding classes in r309199 but forgot to rename enums at the moment. Rename them now to make them consistent. llvm-svn: 311214
* Remove SymbolTable::findInCurrentDSO.Rui Ueyama2017-08-151-7/+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
* Move File from SymbolBody to Symbol.Rafael Espindola2017-08-041-15/+17
| | | | | | | | | | | | | With this Symbol has the same size as before, but DefinedRegular goes from 72 to 64 bytes. I also find this a bit easier to read. There are fewer places initializing File for example. This has a small but measurable speed improvement on all tests (1% max). llvm-svn: 310142
* Rename ObjectFile -> ObjFile.Rui Ueyama2017-07-261-10/+10
| | | | | | | Rename it because it was too easy to conflict with llvm::object::ObjectFile which broke buildbots several times. llvm-svn: 309199
* Attempt to fix buildbots.Rui Ueyama2017-07-261-0/+13
| | | | llvm-svn: 309188
* Detemplate SymbolTable.Rafael Espindola2017-07-261-87/+155
| | | | | | NFC, just makes it easier to access from non templated code. llvm-svn: 309152
* Simplify. NFC.Rafael Espindola2017-07-251-1/+1
| | | | llvm-svn: 309053
* Reduce templating. NFC.Rafael Espindola2017-07-251-6/+5
| | | | llvm-svn: 309051
* Call StringRef::contains only once for each StringRef.Rui Ueyama2017-07-191-2/+4
| | | | llvm-svn: 308529
* Use StringRef::contains().Rui Ueyama2017-07-191-5/+3
| | | | llvm-svn: 308526
* Bring back r307364.Rafael Espindola2017-07-191-29/+34
| | | | | | | | | | | | | | | | | | | | | | | In addition this includes a change to prefer symbols with a default version @@ over unversioned symbols. Original commit message: [ELF] - Handle symbols with default version early. This fixes last testcase provided in PR28414. In short issue is next: when we had X@@Version symbol in object A, we did not resolve it to X early. Then when in another object B we had reference to undefined X, symbol X from archive was fetched. Since both archive and object A contains another symbol Z, duplicate symbol definition was triggered as a result. Correct behavior is to use X@@Version from object A instead and do not fetch any symbols from archive. Differential revision: https://reviews.llvm.org/D35059 llvm-svn: 308492
* [ELF] - Apply clang-format. NFC.George Rimar2017-07-181-6/+6
| | | | llvm-svn: 308297
* Revert r307364: [ELF] - Handle symbols with default version early.Rui Ueyama2017-07-181-8/+23
| | | | | | | This reverts commit r307364 because that change is likely to have caused https://bugs.llvm.org/show_bug.cgi?id=33820. llvm-svn: 308239
* Bring back InVersionScript.Rafael Espindola2017-07-121-1/+3
| | | | | | We were producing bogus warnings without it. llvm-svn: 307820
* [ELF] - Give a symbol version extracted from name a priority over version ↵George Rimar2017-07-121-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set by script. This fixes PR33712. Imagine following script and code: VER1 { global: foo; local: *; }; VER2 { global: foo; }; .global bar bar: .symver bar, foo@VER1 .global zed zed: .symver zed, foo@@VER2 We add foo@@VER2 as foo to symbol table, because have to resolve references to foo for default symbols. Later we are trying to assign symbol versions from script. For that we are searching for 'foo' again. Here it is placed under VER1 and VER2 at the same time, we find it twice and trying to set version again both times, hence LLD shows a warning. Though sample code is correct: we have 2 different versions of foo. Patch gives a symbol version extracted from name a priority over version set by script. Differential revision: https://reviews.llvm.org/D35207 llvm-svn: 307792
* [ELF] - Fix handling of weak symbols from static library when using version ↵George Rimar2017-07-121-1/+1
| | | | | | | | | | | | | | script. When version script was used, binding opf undefined weak symbols sometimes was calculated as STB_LOCAL, making them non-preemtible what broke correct relocations handling logic for them. Fixes PR33738. Differential revision: https://reviews.llvm.org/D35263 llvm-svn: 307767
* Remove unnecessary local variable.Rui Ueyama2017-07-111-2/+1
| | | | llvm-svn: 307703
* Delete redundant InVersionScript field.Rafael Espindola2017-07-111-3/+1
| | | | | | Thanks to Rui for the suggestion. llvm-svn: 307690
* [ELF] - Handle symbols with default version early.George Rimar2017-07-071-19/+9
| | | | | | | | | | | | | | | | This fixes last testcase provided in PR28414. In short issue is next: when we had X@@Version symbol in object A, we did not resolve it to X early. Then when in another object B we had reference to undefined X, symbol X from archive was fetched. Since both archive and object A contains another symbol Z, duplicate symbol definition was triggered as a result. Correct behavior is to use X@@Version from object A instead and do not fetch any symbols from archive. Differential revision: https://reviews.llvm.org/D35059 llvm-svn: 307364
* [ELF] - Resolve references properly when using .symver directiveGeorge Rimar2017-07-041-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is PR28414. Previously LLD was unable to link following: (failed with undefined symbol bar) Version script: SOME_VERSION { global: *; }; .global _start .global bar .symver _start, bar@@SOME_VERSION _start: jmp bar Manual has next description: .symver name, name2@@nodename In this case, the symbol name must exist and be defined within the file being assembled. It is similar to name2@nodename. The difference is name2@@nodename will also be used to resolve references to name2 by the linker https://sourceware.org/binutils/docs/as/Symver.html Patch implements that. If we have name@@ver symbol and name is undefined, name@@ver is used to resolve references to name. If name is defined then multiple definition error is emited, that is consistent with what bfd do. Differential revision: https://reviews.llvm.org/D33680 llvm-svn: 307077
* Revert r306813: "[ELF] - Resolve references properly when using .symver ↵Rui Ueyama2017-07-031-20/+4
| | | | | | | | | directive" This reverts commit r306813 because it broke linking of the FreeBSD base system. llvm-svn: 306996
* [ELF] - Resolve references properly when using .symver directiveGeorge Rimar2017-06-301-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is PR28414. Previously LLD was unable to link following: (failed with undefined symbol bar) ``` Version script: SOME_VERSION { global: *; }; .global _start .global bar .symver _start, bar@@SOME_VERSION _start: jmp bar ``` Manual has next description: // .symver name, name2@@nodename In this case, the symbol name must exist and be defined within the file being assembled. It is similar to name2@nodename. **The difference is name2@@nodename will also be used to resolve references to name2 by the linker** https://sourceware.org/binutils/docs/as/Symver.html // Patch implements that. If we have name@@ver symbol and name is undefined, name@@ver is used to resolve references to name. Differential revision: https://reviews.llvm.org/D33680 llvm-svn: 306813
* Move copy function from Symbol to SymbolBody.Rui Ueyama2017-06-281-1/+1
| | | | | | | | We could have add this function either Symbol or SymbolBody. I added it to Symbol at first. But I noticed that if I've added it to SymbolBody, we could've removed SymbolBody::setName(). So I'll do that in this patch. llvm-svn: 306590
* Define Symbol::copyBody function.Rui Ueyama2017-06-281-7/+1
| | | | | | | This patch adds a utility function to Symbol. This function should be useful in https://reviews.llvm.org/D33680 too. llvm-svn: 306587
* Keep the original symbol name when renamed.Rui Ueyama2017-06-221-11/+13
| | | | | | | | | | | | | | Previously, when symbol A is renamed B, both A and B end up having the same name. This is because name is a symbol's attribute, and we memcpy symbols for symbol renaming. This pathc saves the original symbol name and restore it after memcpy to keep the original name. This patch shouldn't change program's meaning, but names in symbol tables make more sense than before. llvm-svn: 306036
* Implement the --exclude-libs option.Rui Ueyama2017-06-211-5/+6
| | | | | | | | | 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-9/+29
| | | | | | | | | | 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
* Reduce code duplication. NFC.Rafael Espindola2017-05-041-6/+3
| | | | llvm-svn: 302155
* Handle mixed strong and weak undefined symbols.Rafael Espindola2017-05-031-2/+3
| | | | | | | | We were ignoring strong undefined symbols if they followed weak ones. Fixes pr32899. llvm-svn: 302065
* Removes createELFFile which takes a template class as a template parameter.Rui Ueyama2017-04-261-0/+3
| | | | | | | | | This patch is to reduce amount of template uses. The new code is less exciting and boring than before, but I think it is easier to read. Differential Revision: https://reviews.llvm.org/D32467 llvm-svn: 301488
* [ELF] - Implemented --defsym option.George Rimar2017-04-261-0/+13
| | | | | | | | | | | | | | | | | | | | | | 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
* Export __progname even if a -dynamic-list is given.Rui Ueyama2017-04-251-5/+14
| | | | | | | | | | | | | | | | | BSD's __progname symbol is defined in crt1.o and linked against main executables. The libc expects that main executables export __progname symbol via .dynsym sections. In order to handle this case, we scan undefined symbols in DSOs and exported them by setting Sym->ExportDynamic to true. But it turned out that setting that variable is not enough to make sure that symbols are exported in all use cases. If a -dynamic-list option is given, all symbols not explicitly mentioned in a version script are hidden by default. That hides __progname symbol. This patch fixes the issue. Fixes https://bugs.llvm.org/show_bug.cgi?id=32703 llvm-svn: 301282
* Remove DefaultSoName.Rafael Espindola2017-04-241-1/+1
| | | | | | | | We can just use the existing SoName member variable. It now initially contains what was in DefaultSoName and is modified if the .so has an actual soname. llvm-svn: 301259
* Don't resolve hidden undef to a DSO.Rafael Espindola2017-04-041-3/+11
| | | | | | | | | | | | | | The ELF spec says: all of the non-default visibility attributes, when applied to a symbol reference, imply that a definition to satisfy that reference must be provided within the current executable or shared object. But we were trying to resolve those undef references to shared symbols. That causes odd results like creating a got entry with a relocation pointing to 0. llvm-svn: 299464
* Change the error message format for duplicate symbols.Rui Ueyama2017-03-311-21/+37
| | | | | | | | | | | | | | | | | | | | | | | | | This patch is intended to improve readability of "duplicate symbol" error messages. Without this patch: /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Relocations.cpp:1054: duplicate symbol 'lld::elf::demangle(llvm::StringRef)' /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Strings.cpp:93: previous definition was here With this patch: /ssd/clang/bin/ld.lld: error: duplicate symbol: lld::elf::demangle(llvm::StringRef) >>> defined at Strings.cpp:93 (/ssd/llvm-project/lld/ELF/Strings.cpp:93) >>> Strings.cpp.o:(lld::elf::demangle(llvm::StringRef)) in archive lib/liblldELF.a >>> defined at Relocations.cpp:1054 (/ssd/llvm-project/lld/ELF/Relocations.cpp:1054) >>> Relocations.cpp.o:(.text+0x4C30) in archive lib/liblldELF.a Discussion thread: http://lists.llvm.org/pipermail/llvm-dev/2017-March/111459.html Differential Revision: https://reviews.llvm.org/D31507 llvm-svn: 299280
* Remove DefinedSynthetic.Rafael Espindola2017-03-081-23/+8
| | | | | | | | | | | | | 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-2/+2
| | | | llvm-svn: 297282
* Use make<> instead of new (BAlloc). NFC.Rui Ueyama2017-02-281-1/+1
| | | | | | We converted them before, but there were a few remaining occurrences. llvm-svn: 296510
* De-template DefinedRegular.Rui Ueyama2017-02-281-12/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* De-template SharedSymbol.Rui Ueyama2017-02-261-7/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D30351 llvm-svn: 296303
* Merge OutputSectionBase and OutputSection. NFC.Rafael Espindola2017-02-241-1/+1
| | | | | | | 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-11/+9
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
OpenPOWER on IntegriCloud