summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Internalize common variables.Rafael Espindola2016-08-311-3/+4
| | | | | | | | | | | Before this lld was always creating common symbols itself. It worked, but prevented them from being internalized when possible. Now it preserves common symbols is the bitcode and they are internalized. Fixes pr30184. llvm-svn: 280242
* Delete unnecessary template.Rafael Espindola2016-08-311-9/+7
| | | | llvm-svn: 280237
* Delete DefinedBitcode.Rafael Espindola2016-08-311-1/+1
| | | | | | | Given that we almost always want to handle it as DefinedRegular, just use DefinedRegular. llvm-svn: 280226
* Pass Binding instead of IsWeak to addBitcode.Rafael Espindola2016-08-301-3/+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-16/+23
| | | | | | Differential Revision: https://reviews.llvm.org/D24037 llvm-svn: 280144
* [ELF] - Use early return. NFC.George Rimar2016-08-301-10/+11
| | | | | | | This addresses forgotten review comment for r280067: "[ELF] - Versionscript: support wildcards for extern "c++" tag." llvm-svn: 280068
* [ELF] - Versionscript: support wildcards for extern "c++" tag.George Rimar2016-08-301-2/+19
| | | | | | | | | | | | | | | | Previously for extern keyword only names in quotes (exact match) was supported. Patch adds support for wildcards, so next scripts can be handled properly: LIBSAMPLE_1.0 { global: extern "C++" { foo*; }; }; Differential revision: https://reviews.llvm.org/D23794 llvm-svn: 280067
* [ELF] - Cleanup of scanVersionScript(): do not change local Demangled ↵George Rimar2016-08-301-2/+11
| | | | | | variable. NFC. llvm-svn: 280066
* [ELF] - Give automatically generated __start_* and __stop_* symbols default ↵George Rimar2016-08-191-4/+4
| | | | | | | | | | | | | | | | 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
* [ELF] Allows setting section for common symbols in linker scriptEugene Leviant2016-07-281-9/+12
| | | | llvm-svn: 277023
* Simplify symbol version handling.Rui Ueyama2016-07-211-82/+35
| | | | | | | | | 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-2/+2
| | | | | | | 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-18/+14
| | | | | | | | | | | | | 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
* Iterate over SymVector instead of Symtab hash table.Rui Ueyama2016-07-181-6/+7
| | | | | | | | SymVector contains all symbols, so we can iterate either Symtab or SymVector to visit all symbols. Iterating over SymVector makes the next change for --trace-symbol possible. llvm-svn: 275746
* Implement almost-zero-cost --trace-symbol.Rui Ueyama2016-07-171-13/+23
| | | | | | | | | | | | | | | | | | | | --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
* Print out file names for common symbols for --trace-symbol.Rui Ueyama2016-07-171-1/+1
| | | | | | | Previously, there was no way to get a file name for a DefinedCommon symbol. This patch adds it. llvm-svn: 275712
* Handle versioned symbols efficiently.Rui Ueyama2016-07-171-36/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add a pointer to a source file to SymbolBody.Rui Ueyama2016-07-171-9/+8
| | | | | | | | | | | | Previously, each subclass of SymbolBody had a pointer to a source file from which it was created. So, there was no single way to get a source file for a symbol. We had getSourceFile<ELFT>(), but the function was a bit inconvenient as it's a template. This patch makes SymbolBody have a pointer to a source file. If a symbol is not created from a file, the pointer has a nullptr. llvm-svn: 275701
* Remove redundant namespace specifiers.Rui Ueyama2016-07-161-4/+4
| | | | llvm-svn: 275694
* Resurrect code that was lost in conflicting commits.Rui Ueyama2016-07-161-1/+1
| | | | llvm-svn: 275693
* Recommit r275257 "[ELF] - Implement extern "c++" version script tag"George Rimar2016-07-161-22/+50
| | | | | | | | | | | | | | | | | | | | | 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
* Rename SymbolVersions VersionDefinitions.Rui Ueyama2016-07-161-6/+6
| | | | | | SymbolVersions sounds like it had versions for a symbol, so rename it. llvm-svn: 275674
* Rename Version VersionDefinition.Rui Ueyama2016-07-161-3/+3
| | | | | | | | | | | The identifier `Version` was used too often in the code to handle symbol versions. The struct that contains version definitions is named `Version`. Local variables for version ID are named `Version`. Local varaible for version string are named `Version`. This patch give them different names. llvm-svn: 275673
* Simplify. NFC.Rui Ueyama2016-07-161-8/+5
| | | | llvm-svn: 275670
* Simplify default symbol version management. NFC.Rui Ueyama2016-07-161-6/+3
| | | | llvm-svn: 275669
* Reverted r275257 "[ELF] - Implement extern "c++" version script tag"George Rimar2016-07-131-50/+22
| | | | | | | | 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-22/+50
| | | | | | | | | | | 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] - Add Id field to Version struct.George Rimar2016-07-121-9/+8
| | | | | | | | | | | That helps to avoid expressions like I + 2 in code that assigns version number to symbols. Change was suggested by Rui Ueyama. Differential revision: http://reviews.llvm.org/D22086 llvm-svn: 275159
* [ELF] - Do not error out when version declaration not found when building ↵George Rimar2016-07-081-0/+10
| | | | | | | | | | | | | | | | | executable. When building executable usually version script is absent. Before this patch error was shown in the case when symbol name contained version and there was no script to match it. Instead of error out patch allows to create new version declaration in this case and use it. gnu linkers do the same. That is PR28359. Differential revision: http://reviews.llvm.org/D21890 llvm-svn: 274828
* Move demangle() from Symbols.cpp to Strings.cpp.Rui Ueyama2016-07-071-3/+5
| | | | | | | | | | | | Symbols.cpp contains functions to handle ELF symbols. demangle() function is essentially a function to work on a string rather than on an ELF symbol. So Strings.cpp is a better place to put that function. This change also make demangle to demangle symbols unconditionally. Previously, it demangled symbols only when Config->Demangle is true. llvm-svn: 274804
* [ELF] - Fixed incorrect logic of version assignments when mixing wildcards ↵George Rimar2016-07-071-20/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with values matching. Previously we had incorrect logic here. Imagine we would have the next script: LIBSAMPLE_1.0 { global: a_2; local: *; }; LIBSAMPLE_2.0 { global: a*; }; According to previous logic it would assign version 1 to a_2 and then would try to reassign it to version 2 because of applying wildcard a*. And show a warning about that. Generally Ian Lance Tailor wrote about next rules that should be applied: (http://www.airs.com/blog/archives/300) Here are the current rules for gold: "If there is an exact match for the mangled name, we use it. If there is more than one exact match, we give a warning, and we use the first tag in the script which matches. If a symbol has an exact match as both global and local for the same version tag, we give an error. Otherwise, we look for an extern C++ or an extern Java exact match. If we find an exact match, we use it. If there is more than one exact match, we give a warning, and we use the first tag in the script which matches. If a symbol has an exact match as both global and local for the same version tag, we give an error. Otherwise, we look through the wildcard patterns, ignoring “*” patterns. We look through the version tags in reverse order. For each version tag, we look through the global patterns and then the local patterns. We use the first match we find (i.e., the last matching version tag in the file). Otherwise, we use the “*” pattern if there is one. We give a warning if there are multiple “*” patterns." Patch makes wildcard matching to be in revered order and to follow after the regular naming matching. Differential revision: http://reviews.llvm.org/D21894 llvm-svn: 274739
* [ELF] - Check the input bitcode files for compatibility.George Rimar2016-06-291-3/+2
| | | | | | | | | | | | Previously BC files were not checked for the same platform etc, That lead to confusing error "Invalid section header entry size (e_shentsize) in ELF header" when mixing files for different architectures. Patch fixes PR28324. Differential revision: http://reviews.llvm.org/D21832 llvm-svn: 274113
* [ELF] - Updated comments. NFC.George Rimar2016-06-291-2/+2
| | | | | | As was suggested by Rafael Espíndola. llvm-svn: 274111
* Create Strings.cpp and move string manipulation functions to that file.Rui Ueyama2016-06-291-0/+1
| | | | llvm-svn: 274109
* Rename matchStr -> globMatch.Rui Ueyama2016-06-291-1/+1
| | | | llvm-svn: 274103
* Make SymbolTable::findAll to return only defined symbols.Rui Ueyama2016-06-291-16/+24
| | | | | | | | | | We allowed the function to return a vector that contains nullptrs which is weird. This change makes the function to return only defined symbols. Differential Revision: http://reviews.llvm.org/D21828 llvm-svn: 274099
* [ELF] Support for wildcard in version scripts.Davide Italiano2016-06-291-11/+28
| | | | | | | | | | | | | | | 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
* Refactor ELF type inference functions.Rui Ueyama2016-06-291-1/+1
| | | | | | | | | | | | | Previously, we initialized Config->EKind and Config->EMachine when we instantiate ELF objects. That was not an ideal location to do that because the logic was buried too deep inside a concrete logic. This patch moves the code to the driver so that the initialization becomes explicit. Differential Revision: http://reviews.llvm.org/D21784 llvm-svn: 274089
* [ELF] - Implemented support of default/non-default symbols versionsGeorge Rimar2016-06-281-4/+29
| | | | | | | | | | | | | | | | | | | | t is possible to create new version of symbol instead of depricated one using combination of version script and asm commands. For example: __asm__(".symver b_1,b@LIBSAMPLE_1.0"); int b_1() { return 10; } __asm__(".symver b_2,b@@LIBSAMPLE_2.0"); int b_2() { return 20; } This code makes b_2() to be default implementation for b(). b_1() is used for compatibility with binaries compiled against library of older version LIBSAMPLE_1.0. This patch implements support for above functionality in lld. Differential revision: http://reviews.llvm.org/D21681 llvm-svn: 274002
* [ELF] - Implemented --no-undefined-version flagGeorge Rimar2016-06-281-6/+13
| | | | | | | | | | Option checks for cases where a version script explicitly lists a symbol, but the symbol is not defined and errors out such cases if any. Differential revision: http://reviews.llvm.org/D21745 llvm-svn: 273998
* [ELF] Warn for duplicate symbols in version scripts instead of erroring out.Davide Italiano2016-06-281-1/+1
| | | | | | | | | Emitting an error in this case breaks real-world application (e.g. libreoffice). See http://reviews.llvm.org/D21555 for context. Differential Revision: http://reviews.llvm.org/D21781 llvm-svn: 273989
* Implement --trace-symbol=symbol option.Rui Ueyama2016-06-231-0/+11
| | | | | | | | | | | | | | | 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
* [ELF] - Do not allow to mix global symbols versions.George Rimar2016-06-221-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | For next version script: VER1{ global: a; }; VER2{ global: a; }; gold would produce warning like: "warning: using 'VER1' as version for 'a' which is also named in version 'VER2' in script." Documentation also says we do not want this duplications (https://people.freebsd.org/~deischen/symver/library_versioning.txt): "Note that you do not want to duplicate symbols in the map file. The .symver directives are all that is required to add compatibility symbols into old versions." This patch restricts such mixing and makes lld to produce error in this case. Differential revision: http://reviews.llvm.org/D21555 llvm-svn: 273396
* [ELF] - Recommit r273143("[ELF] - Basic versioned symbols support implemented.")George Rimar2016-06-201-4/+22
| | | | | | | | | | | | | | | | | | With fix: -soname flag was not set in testcase. Hash calculated for base def was different on local and bot machines because filename fos used for calculating. Initial commit message: Patch implements basic support of versioned symbols. There is no wildcards patterns matching except local: *; There is no support for hierarchies. There is no support for symbols overrides (@ vs @@ not handled). This patch allows programs that using simple scripts to link and run. Differential revision: http://reviews.llvm.org/D21018 llvm-svn: 273152
* Revert r273143 "[ELF] - Basic versioned symbols support implemented."George Rimar2016-06-201-22/+4
| | | | | | | It broke buildbot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast llvm-svn: 273146
* [ELF] - Basic versioned symbols support implemented.George Rimar2016-06-201-4/+22
| | | | | | | | | | | | | Patch implements basic support of versioned symbols. There is no wildcards patterns matching except local: *; There is no support for hierarchies. There is no support for symbols overrides (@ vs @@ not handled). This patch allows programs that using simple scripts to link and run. Differential revision: http://reviews.llvm.org/D21018 llvm-svn: 273143
* Make local: optional.Rafael Espindola2016-06-171-1/+1
| | | | | | | | | | Doing that in an anonymous version is a bit silly, but this opens the way for supporting it in general. Since we don't support actual versions, for now we just disable the version script if we detect that it is missing a local. llvm-svn: 273000
* Internalize symbols in comdats.Rafael Espindola2016-06-151-2/+3
| | | | | | | 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-6/+9
| | | | | | | | | 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
* Use a reference instead of a pointer. NFC.Rafael Espindola2016-06-141-2/+2
| | | | llvm-svn: 272719
OpenPOWER on IntegriCloud