summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Pass StringRefs instead of StringMatcher because it's simpler.Rui Ueyama2016-11-171-2/+2
| | | | llvm-svn: 287234
* Use uint16_t instead of size_t for symbol version ID.Rui Ueyama2016-11-171-2/+2
| | | | | | Because it is uint16_t in the ELF spec. Using size_t was confusing. llvm-svn: 287198
* Split scanVersionScript. NFC.Rui Ueyama2016-11-171-0/+2
| | | | llvm-svn: 287191
* [ELF] Add Section() to expression objectEugene Leviant2016-11-161-2/+2
| | | | | | | | | This allows making symbols containing ADDR(section) synthetic, and defining synthetic symbols outside SECTIONS block. Differential revision: https://reviews.llvm.org/D25441 llvm-svn: 287090
* Refactor symbol version assignmnt code.Rui Ueyama2016-11-151-1/+12
| | | | | | | | | | | | | | | | The code to handle symbol versions is getting tricky and hard to understand, so it is probably time to simplify it. This patch does the following. - Add `DemangledSyms` variable to SymbolTable so that we don't need to pass it around to findDemangled. - Define `initDemangledSyms` to initialize the variable lazily. - hasExternCpp is removed because we no longer have to initialize the map eagerly. - scanScriptVersion is split. - Comments are updated. llvm-svn: 287002
* [ELF] - Better diagnostic for relative relocation to an absolute value error.George Rimar2016-11-151-2/+2
| | | | | | | | | | | | | | Patch adds a filename to that error message. I faced next error when debugged one of FreeBSD port: error: relocation R_X86_64_PLT32 cannot refer to absolute symbol __tls_get_addr error message was poor and this patch improves it to show the locations of symbol declaration and using. Differential revision: https://reviews.llvm.org/D26508 llvm-svn: 286940
* Remove an overloaded function to simplify.Rui Ueyama2016-11-091-4/+2
| | | | | | | This version of addRegular is almost identical to the other except it lacked "size" parameter. llvm-svn: 286416
* Make OutputSectionBase a class instead of class template.Rafael Espindola2016-11-091-3/+3
| | | | | | | | The disadvantage is that we use uint64_t instad of uint32_t for some value in 32 bit files. The advantage is a substantially simpler code, faster builds and less code duplication. llvm-svn: 286414
* [ELF] Better error reporting for duplicate symbolEugene Leviant2016-11-081-2/+0
| | | | | | Differential revision: https://reviews.llvm.org/D26397 llvm-svn: 286244
* Create a vector containing all input sections.Rui Ueyama2016-11-051-0/+2
| | | | | | | | | | | | | | | | Previously, we do this piece of code to iterate over all input sections. for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles()) for (InputSectionBase<ELFT> *S : F->getSections()) It turned out that this mechanisms doesn't work well with synthetic input sections because synthetic input sections don't belong to any input file. This patch defines a vector that contains all input sections including synthetic ones. llvm-svn: 286051
* Add [<chars>] to the glob matcher to eliminate use of llvm::Regex.Rui Ueyama2016-11-031-2/+2
| | | | | | | | | | | | | Previously, it didn't support the character class, so we couldn't eliminate the use fo llvm::Regex. Now that it is supported, we can remove compileGlobPattern, which converts a glob pattern to a regex. This patch contains optimization for exact/prefix/suffix matches. Differential Revision: https://reviews.llvm.org/D26284 llvm-svn: 285949
* Use ArrayRef instead of const std::vector.Rui Ueyama2016-11-021-13/+4
| | | | llvm-svn: 285776
* Consolidate BumpPtrAllocators.Rui Ueyama2016-10-281-1/+0
| | | | | | | | | | | Previously, we have a lot of BumpPtrAllocators, but all these allocators virtually have the same lifetime because they are not freed until the linker finishes its job. This patch aggregates them into a single allocator. Differential revision: https://reviews.llvm.org/D26042 llvm-svn: 285452
* Don't create a dummy ELF to process a binary file.Rafael Espindola2016-10-271-1/+8
| | | | | | | Now that it is easy to create input section and symbols, this is simple. llvm-svn: 285322
* Have on addRegular forward to another. NFC.Rafael Espindola2016-10-261-0/+4
| | | | | | Another step in making it easier to create symbols without an ELf_Sym. llvm-svn: 285241
* Move a helper function that doesn't depend on a class out of the class.Rui Ueyama2016-10-261-1/+0
| | | | llvm-svn: 285220
* Use a CachedHashString for comdats too.Rafael Espindola2016-10-211-1/+1
| | | | | | | We were already using it in the larger sets/maps. This provides about 1% speedup in linking xul and chromium. llvm-svn: 284862
* Use CachedHashStringRef instead of CachedHash<StringRef>.Justin Lebar2016-10-181-1/+2
| | | | | | | | | | | | | | Summary: This uses one less word on 64-bit platforms, so should be a strict improvement. This change also lets us get rid of llvm::CachedHash. Reviewers: rafael, timshen Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25646 llvm-svn: 284502
* [ELF/LTO] Switch to the new resolution-based API.Davide Italiano2016-09-291-6/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D24492 llvm-svn: 282656
* Recommit r281318 "[ELF] - Versionscript: support mangled symbols with the ↵George Rimar2016-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | same name." Previouly bot was failing: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/413/steps/test-stage1-compiler/logs/stdio Fixed possible segfault, so commit should bix the buildbot. Initial commit message: This is PR30312. Info from bug page: Both of these symbols demangle to abc::abc(): _ZN3abcC1Ev _ZN3abcC2Ev (These would be abc's complete object constructor and base object constructor, respectively.) however with "abc::abc()" in the version script only one of the two receives the symbol version. Patch fixes that. It uses testcase created by Ed Maste (D24306). Differential revision: https://reviews.llvm.org/D24336 llvm-svn: 281605
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-10/+6
| | | | | | | | | | | | | | | | | | | | Previously, all input files were owned by the symbol table. Files were created at various places, such as the Driver, the lazy symbols, or the bitcode compiler, and the ownership of new files was transferred to the symbol table using std::unique_ptr. All input files were then free'd when the symbol table is freed which is on program exit. I think we don't have to transfer ownership just to free all instance at once on exit. In this patch, all instances are automatically collected to a vector and freed on exit. In this way, we no longer have to use std::unique_ptr. Differential Revision: https://reviews.llvm.org/D24493 llvm-svn: 281425
* revert: [ELF] - Versionscript: support mangled symbols with the same name.George Rimar2016-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Something broked BBots: 281318 failed on step 9: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/413 r281317 built step 9 green: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/415 Initial revision commits were: This is PR30312. Info from bug page: Both of these symbols demangle to abc::abc(): _ZN3abcC1Ev _ZN3abcC2Ev (These would be abc's complete object constructor and base object constructor, respectively.) however with "abc::abc()" in the version script only one of the two receives the symbol version. Patch fixes that. It uses testcase created by Ed Maste (D24306). Differential revision: https://reviews.llvm.org/D24336 llvm-svn: 281411
* Split scanVersionScript. NFC.Rui Ueyama2016-09-131-0/+1
| | | | llvm-svn: 281393
* [ELF] - Versionscript: support mangled symbols with the same name.George Rimar2016-09-131-1/+1
| | | | | | | | | | | | | | | | | This is PR30312. Info from bug page: Both of these symbols demangle to abc::abc(): _ZN3abcC1Ev _ZN3abcC2Ev (These would be abc's complete object constructor and base object constructor, respectively.) however with "abc::abc()" in the version script only one of the two receives the symbol version. Patch fixes that. It uses testcase created by Ed Maste (D24306). Differential revision: https://reviews.llvm.org/D24336 llvm-svn: 281318
* [ELF] Fix memory leak in BinaryFile handling.Michael J. Spencer2016-09-101-0/+1
| | | | llvm-svn: 281129
* [ELF] - Use std::regex instead of hand written logic in elf::globMatch()George Rimar2016-09-021-1/+2
| | | | | | | | | | Use std::regex instead of hand written matcher. Patch based on code and ideas of Rui Ueyama. Differential revision: https://reviews.llvm.org/D23829 llvm-svn: 280544
* Remove redundant argument. NFC.Rafael Espindola2016-08-311-2/+1
| | | | llvm-svn: 280243
* Pass Binding instead of IsWeak to addBitcode.Rafael Espindola2016-08-301-2/+2
| | | | | | We were computing the binding on both the caller and callee. llvm-svn: 280156
* [LTO] Fix the logic for dropping unnamed_addr.Davide Italiano2016-08-301-4/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D24037 llvm-svn: 280144
* [ELF] - Give automatically generated __start_* and __stop_* symbols default ↵George Rimar2016-08-191-1/+1
| | | | | | | | | | | | | | | | visibility. This patch is opposite to D19024, which made this symbols to be hidden by default. Unfortunately FreeBSD loader wants to see start_set_modmetadata_set/stop_set_modmetadata_set in the dynamic symbol table. They were not placed there because had hidden visibility. Patch makes them to have default visibility again. Differential revision: https://reviews.llvm.org/D23552 llvm-svn: 279262
* Simplify symbol version handling.Rui Ueyama2016-07-211-3/+2
| | | | | | | | | r275711 for "speedng up symbol version handling" was committed by misunderstanding; the benchmark number was measured with a debug build. The number with a release build didn't actually change. This patch removes false optimizations added in that patch. llvm-svn: 276267
* [ELF] - Fixed integral constant overflow warning under MSVS 2015. NFC.George Rimar2016-07-201-0/+1
| | | | | | | Under MSVS 2015 I observed integral constant overflow warning when aggregate initialization was used to init the bit field. Patch fixes that. llvm-svn: 276118
* Remove SymbolBody::PlaceholderKind.Rui Ueyama2016-07-181-1/+6
| | | | | | | | | | | | | In the last patch for --trace-symbol, I introduced a new symbol type PlaceholderKind and store it to SymVector storage. It made all code that iterates over SymVector to recognize and skip PlaceholderKind symbols. I found that that's annoying. In this patch, I removed PlaceholderKind and stop storing them to SymVector. Now the information whether a symbol is being watched by --trace-symbol is stored to the Symtab hash table. llvm-svn: 275747
* Implement almost-zero-cost --trace-symbol.Rui Ueyama2016-07-171-1/+2
| | | | | | | | | | | | | | | | | | | | --trace-symbol is a command line option to watch a symbol. Previosly, we looked up a hash table for a new symbol if the option is given. Any code that looks up a hash table for each symbol is expensive because the linker handles a lot of symbols. In our design, we look up a hash table strictly only once for a symbol, so --trace-symbol was an exception. This patch improves efficiency of the option by merging the hash table into the symbol table. Instead of looking up a separate hash table with a string, this patch sets `Traced` flag to symbols specified by --trace-symbol. So, if you insert a symbol and get a symbol with `Traced` flag on, you know that you need to print out a log message for the symbol. This is nearly zero cost. llvm-svn: 275716
* Handle versioned symbols efficiently.Rui Ueyama2016-07-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Versions can be assigned to symbols in two different ways. One is the usual version scripts, and the other is special symbol suffix '@'. If a symbol contains '@', the string after that is considered to specify a version name. Previously, we look for '@' for all symbols. Anything that works on every symbol can be expensive because the linker has to handle a lot of symbols. The search for '@' was not an exception. In this patch, I made two optimizations. The first optimization is to handle '@' only when at least one version is defined. If no versions are defined, no versions can be assigned to any symbols, so it's waste of time to search for '@'. The second optimization is to scan only suffixes of symbol names instead of entire symbol names. Symbol names can be very long, but symbol versions are usually short, so scanning entire symbol names is waste of time, too. There are some error cases which we no longer be able to detect with this patch. I don't think it's a major drawback because they are minor errors. Speed is more important. This change improves LLD with debug info self-link time from 6.6993 seconds to 6.3426 seconds (or -5.3%). Differential Revision: https://reviews.llvm.org/D22433 llvm-svn: 275711
* Recommit r275257 "[ELF] - Implement extern "c++" version script tag"George Rimar2016-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | BSD toolchain contains a bug: https://sourceforge.net/p/elftoolchain/tickets/491/ In short demangler works differently, fix was to update the testcase. It should fix the FreeBSD bot failture: http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/19432/steps/test_lld/logs/stdio Original commit message was: [ELF] - Implement extern "c++" version script tag Patch implements 'extern' version script tag. Currently only values in quotes(") are supported. Matching of externs is performed in the same pass as exact match of globals. Differential revision: http://reviews.llvm.org/D21930 llvm-svn: 275682
* Reverted r275257 "[ELF] - Implement extern "c++" version script tag"George Rimar2016-07-131-2/+0
| | | | | | | | It broke build bots: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/8204 http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/19432 llvm-svn: 275258
* [ELF] - Implement extern "c++" version script tagGeorge Rimar2016-07-131-0/+2
| | | | | | | | | | | Patch implements 'extern' version script tag. Currently only values in quotes(") are supported. Matching of externs is performed in the same pass as exact match of globals. Differential revision: http://reviews.llvm.org/D21930 llvm-svn: 275257
* [ELF] Support for wildcard in version scripts.Davide Italiano2016-06-291-0/+1
| | | | | | | | | | | | | | | Example: VERSION_1.0 { global: foo*; local: *; } now correctly matches all the symbols which name starts with `foo`. Differential Revision: http://reviews.llvm.org/D21732 llvm-svn: 274091
* Implement --trace-symbol=symbol option.Rui Ueyama2016-06-231-0/+2
| | | | | | | | | | | | | | | Patch by Shridhar Joshi. This option provides names of all the link time modules which define and reference symbols requested by user. This helps to speed up application development by detecting references causing undefined symbols. It also helps in detecting symbols being resolved to wrong (unintended) definitions in case of applications containing multiple definitions for same symbols with different types, bindings. Implements PR28226. llvm-svn: 273536
* Internalize symbols in comdats.Rafael Espindola2016-06-151-1/+1
| | | | | | | We were dropping the CanOmitFromDynSym bit when creating undefined symbols because of comdat. llvm-svn: 272812
* Don't include --start-lib/--end-lib files twice.Rafael Espindola2016-06-141-1/+1
| | | | | | | | | This should never happen with correct programs, but it is trivial write a testcase where lld would crash or report duplicated symbols. We now behave like when an archive is used and include the file only once. llvm-svn: 272724
* ELF: Remove the function SymbolTable<ELFT>::findFile.Peter Collingbourne2016-05-031-1/+0
| | | | | | We already have the function SymbolBody::getSourceFile which does the same thing. llvm-svn: 268353
* ELF: Forbid all relative relocations to absolute symbols in PIC, except for ↵Peter Collingbourne2016-05-031-1/+1
| | | | | | | | | | | | | | | | | | weak undefined. Weak undefined symbols resolve to the image base. This is a little strange, but it allows us to link function calls to such symbols. Normally such a call will be guarded with a comparison, which will load a zero from the GOT. There's one example of such a function call in crti.o in Linux's CRT. As part of this change, I also needed to make the synthetic start and end symbols image base relative in the case where their sections were empty, so that PC-relative references to those symbols would continue to work. Differential Revision: http://reviews.llvm.org/D19844 llvm-svn: 268350
* ELF: New symbol table design.Peter Collingbourne2016-05-011-9/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements a new design for the symbol table that stores SymbolBodies within a memory region of the Symbol object. Symbols are mutated by constructing SymbolBodies in place over existing SymbolBodies, rather than by mutating pointers. As mentioned in the initial proposal [1], this memory layout helps reduce the cache miss rate by improving memory locality. Performance numbers: old(s) new(s) Without debug info: chrome 7.178 6.432 (-11.5%) LLVMgold.so 0.505 0.502 (-0.5%) clang 0.954 0.827 (-15.4%) llvm-as 0.052 0.045 (-15.5%) With debug info: scylla 5.695 5.613 (-1.5%) clang 14.396 14.143 (-1.8%) Performance counter results show that the fewer required indirections is indeed the cause of the improved performance. For example, when linking chrome, stalled cycles decreases from 14,556,444,002 to 12,959,238,310, and instructions per cycle increases from 0.78 to 0.83. We are also executing many fewer instructions (15,516,401,933 down to 15,002,434,310), probably because we spend less time allocating SymbolBodies. The new mechanism by which symbols are added to the symbol table is by calling add* functions on the SymbolTable. In this patch, I handle local symbols by storing them inside "unparented" SymbolBodies. This is suboptimal, but if we do want to try to avoid allocating these SymbolBodies, we can probably do that separately. I also removed a few members from the SymbolBody class that were only being used to pass information from the input file to the symbol table. This patch implements the new design for the ELF linker only. I intend to prepare a similar patch for the COFF linker. [1] http://lists.llvm.org/pipermail/llvm-dev/2016-April/098832.html Differential Revision: http://reviews.llvm.org/D19752 llvm-svn: 268178
* Removed dead code. NFC.George Rimar2016-04-271-1/+0
| | | | llvm-svn: 267685
* ELF: Re-implement -u directly and remove CanKeepUndefined flag.Peter Collingbourne2016-04-271-0/+1
| | | | | | | | | | | | | | | | The semantics of the -u flag are to load the lazy symbol named by the flag. We were previously relying on this behavior falling out of symbol resolution against a synthetic undefined symbol, but that didn't quite give us the correct behavior, so we needed a flag to mark symbols created with -u so we could treat them specially in the writer. However, it's simpler and less error prone to implement the required behavior directly and remove the flag. This fixes an issue where symbols loaded with -u would receive hidden visibility even when the definition in an object file had wider visibility. Differential Revision: http://reviews.llvm.org/D19560 llvm-svn: 267639
* ELF: Implement basic support for --version-script.Peter Collingbourne2016-04-221-0/+1
| | | | | | | | | | | | | | | | | | | | This patch only implements support for version scripts of the form: { [ global: symbol1; symbol2; [...]; symbolN; ] local: *; }; No wildcards are supported, other than for the local entry. Symbol versioning is also not supported. It works by introducing a new Symbol flag which tracks whether a symbol appears in the global section of a version script. This patch also simplifies the logic in SymbolBody::isPreemptible(), and teaches it to handle the case where symbols with default visibility in DSOs do not appear in the dynamic symbol table because of a version script. Fixes PR27482. Differential Revision: http://reviews.llvm.org/D19430 llvm-svn: 267208
* Use llvm::CachedHash.Rafael Espindola2016-04-211-30/+1
| | | | llvm-svn: 266982
* Specialize the symbol table data structure a bit.Rafael Espindola2016-04-141-7/+6
| | | | | | | | | We never need to iterate over the K,V pairs, so we can avoid copying the key as MapVector does. This is a small speedup on most benchmarks. llvm-svn: 266364
OpenPOWER on IntegriCloud