summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Do not use errs() or outs() directly. Instead use message(), log() or error()Rui Ueyama2017-02-211-1/+1
| | | | | | | | | LLD is a multi-threaded program. errs() or outs() are not guaranteed to be thread-safe (they are actually not). LLD's message(), log() or error() are thread-safe. We should use them. llvm-svn: 295787
* [ELF] Use SyntheticSections for ThunksPeter Smith2017-02-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Thunks are now implemented by redirecting the relocation to the symbol S, to a symbol TS in a Thunk. The Thunk will transfer control to S. This has the following implications: - All the side-effects of Thunks happen within createThunks() - Thunks are no longer stored in InputSections and Symbols no longer need to hold a pointer to a Thunk - The synthetic Thunk sections need to be merged into OutputSections This implementation is almost a direct conversion of the existing Thunks with the following exceptions: - Mips LA25 Thunks are placed before the InputSection that defines the symbol that needs a Thunk. - All ARM Thunks are placed at the end of the OutputSection of the first caller to the Thunk. Range extension Thunks are not supported yet so it is optimistically assumed that all Thunks can be reused. This is a recommit of r293283 with a fixed comparison predicate as std::merge requires a strict weak ordering. Differential revision: https://reviews.llvm.org/D29327 llvm-svn: 293757
* Revert "[ELF][ARM] Use SyntheticSections for Thunks"Rui Ueyama2017-01-281-3/+3
| | | | | | This reverts commit r293283 because it broke MSVC build. llvm-svn: 293352
* [ELF][ARM] Use SyntheticSections for ThunksPeter Smith2017-01-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Thunks are now implemented by redirecting the relocation to the symbol S, to a symbol TS in a Thunk. The Thunk will transfer control to S. This has the following implications: - All the side-effects of Thunks happen within createThunks() - Thunks are no longer stored in InputSections and Symbols no longer need to hold a pointer to a Thunk - The synthetic Thunk sections need to be merged into OutputSections This implementation is almost a direct conversion of the existing Thunks with the following exceptions: - Mips LA25 Thunks are placed before the InputSection that defines the symbol that needs a Thunk. - All ARM Thunks are placed at the end of the OutputSection of the first caller to the Thunk. Range extension Thunks are not supported yet so it is optimistically assumed that all Thunks can be reused. Differential Revision: https://reviews.llvm.org/D29129 llvm-svn: 293283
* Create _end symbol even if a .so defines it.Rafael Espindola2017-01-191-1/+1
| | | | | | | | | The freebsd sbrk implementation uses _end to find the initial value of brk, so it has to be defined in the main binary. This should fix the emacs build. llvm-svn: 292512
* Add a isInCurrentDSO helper. NFC.Rafael Espindola2017-01-171-3/+3
| | | | llvm-svn: 292228
* Give priority to linker scripts over preemption.Rafael Espindola2017-01-161-5/+1
| | | | | | | | | | | | LLD exports symbols that are also present in used shared libraries to make sure they are preempted at runtime. That is a reasonable default, but we must allow for it to be overwritten with linker script. If we don't, libraries that expect to be able to hide a c++ delete operator will fail. This should fix the firebird build. llvm-svn: 292146
* Don't add DT_INIT/DT_FINI for undef and shared symbols.Rafael Espindola2017-01-131-0/+8
| | | | | | | | | | 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
* Add support for anonymous local symbols.Rafael Espindola2017-01-101-20/+10
| | | | | | | | | This actually simplifies the code a bit as now all local symbols are handled uniformly. This should fix the build of www/webkit2-gtk3. llvm-svn: 291569
* [ELF] Add support for thunks to undefined non-weak symbolsPeter Smith2017-01-041-3/+3
| | | | | | | | | | | | In a shared library an undefined symbol is implicitly imported. If the symbol is called as a function a PLT entry is generated for it. When the caller is a Thumb b.w a thunk to the PLT entry is needed as all PLT entries are in ARM state. This change allows undefined symbols to have thunks in the same way that shared symbols may have thunks. llvm-svn: 290951
* Do not return null or Undefined from find{All,}ByVersion.Rui Ueyama2016-12-221-15/+15
| | | | | | | Vectors returned form that function contained nullptrs or Undefined symbols. This patch filter them out. This makes use of the function a bit easier. llvm-svn: 290334
* Define a getter function for a lazily-created object.Rui Ueyama2016-12-221-17/+14
| | | | | | | | 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
* Simplify. NFC.Rui Ueyama2016-12-221-7/+2
| | | | llvm-svn: 290321
* Define a function to avoid a magic variable 0x3.Rui Ueyama2016-12-221-6/+8
| | | | llvm-svn: 290320
* De-template DefinedSynthetic.Rui Ueyama2016-12-211-1/+1
| | | | | | | | DefinedSynthetic is not created for a real ELF object, so it doesn't have to be a template function. It has a virtual st_value, which is either 32 bit or 64 bit, but we can simply use 64 bit. llvm-svn: 290241
* Fix build broken by changes in StringMatcher interface r290213Vitaly Buka2016-12-211-1/+1
| | | | llvm-svn: 290231
* Remove lld/Support/Memory.h.Rui Ueyama2016-12-181-1/+1
| | | | | | | | | | | | I thought for a while about how to remove it, but it looks like we can just copy the file for now. Of course I'm not happy about that, but it's just less than 50 lines of code, and we already have duplicate code in Error.h and some other places. I want to solve them all at once later. Differential Revision: https://reviews.llvm.org/D27819 llvm-svn: 290062
* Rename find(SymbolVersion) to avoid overloading with find(StringRef).Rui Ueyama2016-12-101-6/+7
| | | | llvm-svn: 289293
* Fix a bogus warning.Rafael Espindola2016-12-091-2/+5
| | | | | | | | We first decide that the symbol is global, than that it should have version foo. Since it was already not the default version, we were producing a bogus warning. llvm-svn: 289284
* Don't crash on an extra symbol in a version script.Rafael Espindola2016-12-091-1/+2
| | | | llvm-svn: 289217
* Give preempting symbols precedence over linker script.Rafael Espindola2016-12-091-1/+5
| | | | llvm-svn: 289212
* Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.Rui Ueyama2016-12-081-1/+1
| | | | llvm-svn: 289084
* Change the implementation of --dynamic-list to use linker script parsing.Rafael Espindola2016-12-081-7/+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-17/+11
| | | | llvm-svn: 289067
* Handle C++ names in anon scripts.Rafael Espindola2016-12-081-2/+2
| | | | llvm-svn: 289066
* Inline two functions called only once. NFC.Rafael Espindola2016-12-081-26/+19
| | | | llvm-svn: 289065
* Add two helper functions. NFC.Rafael Espindola2016-12-081-7/+16
| | | | llvm-svn: 289064
* Simplify. NFC.Rafael Espindola2016-12-081-1/+1
| | | | llvm-svn: 289062
* [ELF] Correct addAbsolute function argument nameSimon Atanasyan2016-12-081-2/+2
| | | | | | Follow-up to r289025. llvm-svn: 289061
* [ELF][MIPS] Make _gp, _gp_disp, __gnu_local_gp global symbolsSimon Atanasyan2016-12-081-3/+4
| | | | | | | | | | | | | | 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
* Make demangle() return None instead of "" if a given string is not a mangled ↵Rui Ueyama2016-12-071-1/+4
| | | | | | symbol. llvm-svn: 288993
* Allow duplicated abs symbols with the same value.Rafael Espindola2016-12-021-6/+15
| | | | | | | | | This is a fairly reasonable bfd extension since there is one obvious value. dtrace depends on this feature as it creates multiple absolute symbols with the same value. llvm-svn: 288461
* Introduce StringRefZ class to represent null-terminated strings.Rui Ueyama2016-11-291-8/+10
| | | | | | | | | | | | | | 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-4/+4
| | | | llvm-svn: 287967
* Move getLocation from Relocations.cpp to InputSection.cpp.Rui Ueyama2016-11-251-2/+2
| | | | | | | | The function was used only within Relocations.cpp, but now we are using it in many places, so this patch moves it to a file that fits to the functionality. llvm-svn: 287943
* Use toString() to report incompatible files.Rui Ueyama2016-11-241-5/+6
| | | | llvm-svn: 287901
* Define toString(const SymbolBody &) and remove maybeDemangle instead.Rui Ueyama2016-11-241-4/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D27065 llvm-svn: 287899
* Remove HasError and use ErrorCount instead.Rui Ueyama2016-11-241-1/+1
| | | | | | HasError was always true if ErrorCount > 0, so we can use ErrorCount instead. llvm-svn: 287849
* Define toString() as a generic function to get a string for error message.Rui Ueyama2016-11-231-2/+2
| | | | | | | | | | | | | | | We have different functions to stringize objects to construct error messages. For InputFile, we have getFilename, and for InputSection, we have getName. You had to memorize them. I think this is the case where the function overloading comes in handy. This patch defines toString() functions that are overloaded for all these types, so that you just call it in error(). Differential Revision: https://reviews.llvm.org/D27030 llvm-svn: 287787
* Remove one of SymbolTable::addRegular function that forwards other addRegular.Rui Ueyama2016-11-231-8/+0
| | | | | | So that we have less number of overloaded functions. llvm-svn: 287745
* Remove a forwarding constructor that is used only once.Rui Ueyama2016-11-231-1/+1
| | | | llvm-svn: 287742
* Parse symbol versions in scanVersionScript() instead of insert().Rui Ueyama2016-11-231-33/+10
| | | | | | | | | | | | | | | | 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
* Remove unused #include.Rui Ueyama2016-11-191-1/+0
| | | | llvm-svn: 287467
* Use consistent variable name.Rui Ueyama2016-11-181-2/+2
| | | | llvm-svn: 287318
* Add single quotes to error messages.Rui Ueyama2016-11-171-2/+2
| | | | llvm-svn: 287254
* Use consistent variable name.Rui Ueyama2016-11-171-4/+4
| | | | llvm-svn: 287253
* Use llvm::reverse to get a reverse range.Rui Ueyama2016-11-171-3/+4
| | | | llvm-svn: 287252
* Pass StringRefs instead of StringMatcher because it's simpler.Rui Ueyama2016-11-171-5/+6
| | | | 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
* Add single quotes to a warning message for consistency.Rui Ueyama2016-11-171-1/+1
| | | | llvm-svn: 287197
OpenPOWER on IntegriCloud