summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Hash symbol names only once per global SymbolBody.Rafael Espindola2016-04-141-2/+33
| | | | | | | | | | | The DenseMap doesn't store hash results. This means that when it is resized it has to recompute them. This patch is a small hack that wraps the StringRef in a struct that remembers the hash value. That way we can be sure it is only hashed once. llvm-svn: 266357
* ELF: Implement --dynamic-listAdhemerval Zanella2016-04-131-0/+1
| | | | | | | | | | | | | | | | | | | | | This patch implements the --dynamic-list option, which adds a list of global symbol that either should not be bounded by default definition when creating shared libraries, or add in dynamic symbol table in the case of creating executables. The patch modifies the ScriptParserBase class to use a list of Token instead of StringRef, which contains information if the token is a quoted or unquoted strings. It is used to use a faster search for exact match symbol name. The input file follow a similar format of linker script with some simplifications (it does not have scope or node names). It leads to a simplified parser define in DynamicList.{cpp,h}. Different from ld/gold neither glob pattern nor mangled names (extern 'C++') are currently supported. llvm-svn: 266227
* ELF: Use hidden visibility for all DefinedSynthetic symbols.Peter Collingbourne2016-04-131-1/+1
| | | | | | | | | | | | | This simplifies the code by allowing us to remove the visibility argument to functions that create synthetic symbols. The only functional change is that the visibility of the MIPS "_gp" symbol is now hidden. Because this symbol is defined in every executable or DSO, it would be difficult to observe a visibility change here. Differential Revision: http://reviews.llvm.org/D19033 llvm-svn: 266208
* ELF: Implement --start-lib and --end-libRui Ueyama2016-04-071-0/+1
| | | | | | | | | | | | | | | | start-lib and end-lib are options to link object files in the same semantics as archive files. If an object is in start-lib and end-lib, the object is linked only when the file is needed to resolve undefined symbols. That means, if an object is in start-lib and end-lib, it behaves as if it were in an archive file. In this patch, I introduced a new notion, LazyObjectFile. That is analogous to Archive file type, but that works for a single object file instead of for an archive file. http://reviews.llvm.org/D18814 llvm-svn: 265710
* Change the type hierarchy for undefined symbols.Rafael Espindola2016-04-061-2/+1
| | | | | | | | | | We have to differentiate undefined symbols from bitcode and undefined symbols from other sources. Undefined symbols from bitcode should not inhibit the symbol being internalized. Undefined symbols from other sources should. llvm-svn: 265536
* Revert unintentional change.Rafael Espindola2016-04-041-1/+1
| | | | | | | | resolve can remain private. Thanks to Rui for noticing it. llvm-svn: 265336
* Don't store an Elf_Sym for most symbols.Rafael Espindola2016-04-041-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our symbol representation was redundant, and some times would get out of sync. It had an Elf_Sym, but some fields were copied to SymbolBody. Different parts of the code were checking the bits in SymbolBody and others were checking Elf_Sym. There are two general approaches to fix this: * Copy the required information and don't store and Elf_Sym. * Don't copy the information and always use the Elf_Smy. The second way sounds tempting, but has a big problem: we would have to template SymbolBody. I started doing it, but it requires templeting *everything* and creates a bit chicken and egg problem at the driver where we have to find ELFT before we can create an ArchiveFile for example. As much as possible I compared the test differences with what gold and bfd produce to make sure they are still valid. In most cases we are just adding hidden visibility to a local symbol, which is harmless. In most tests this is a small speedup. The only slowdown was scylla (1.006X). The largest speedup was clang with no --build-id, -O3 or --gc-sections (i.e.: focus on the relocations): 1.019X. llvm-svn: 265293
* Remove unused fwd decl for LLVM IR stuff that lives in LTO nowReid Kleckner2016-03-301-4/+0
| | | | llvm-svn: 264911
* Remove declaration of SymbolTable::codegen, this method was deleted in r264091Reid Kleckner2016-03-251-1/+0
| | | | llvm-svn: 264441
* [LTO] Remove dead code.Davide Italiano2016-03-231-2/+0
| | | | llvm-svn: 264133
* ELF: Create LTO.{cpp,h} and move LTO-related code to that file.Rui Ueyama2016-03-221-2/+3
| | | | | | | | | | | The code for LTO has been growing, so now is probably a good time to move it to its own file. SymbolTable.cpp is for symbol table, and because compiling bitcode files are semantically not a part of symbol table, this is I think a good thing to do. http://reviews.llvm.org/D18370 llvm-svn: 264091
* Use ELFT instead of ELFFile<ELFT>.Rui Ueyama2016-03-141-2/+2
| | | | llvm-svn: 263510
* [ELF] - Create _DYNAMIC symbol for dynamic outputGeorge Rimar2016-03-011-1/+1
| | | | | | | | | | | lld needs to provide _DYNAMIC symbol when creating a shared library both bfd and gold do that. This should fix the https://llvm.org/bugs/show_bug.cgi?id=26732 Differential revision: http://reviews.llvm.org/D17607 llvm-svn: 262348
* Rename elf2 to elf.Rafael Espindola2016-02-281-2/+2
| | | | llvm-svn: 262159
* Report duplicated symbols in bitcode.Rafael Espindola2016-02-261-1/+1
| | | | llvm-svn: 262076
* Add initial LTO support.Rafael Espindola2016-02-121-0/+11
| | | | llvm-svn: 260726
* Delete addIgnoredStrong.Rafael Espindola2016-01-191-1/+0
| | | | | | | It is not needed now that we resolve symbols is shared libraries correctly. llvm-svn: 258104
* [ELF][MIPS] Prevent substitution of _gp_disp symbolSimon Atanasyan2016-01-121-0/+1
| | | | | | | | | | | | | On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between start of function and gp pointer into GOT. To make seal with such symbol we add new method addIgnoredStrong(). It adds ignored symbol with global binding to prevent the symbol substitution. The addIgnored call is not enough here because this call adds a weak symbol which might be substituted by symbol from shared library. Differential Revision: http://reviews.llvm.org/D16084 llvm-svn: 257449
* Group members to match a comment. NFC.Rui Ueyama2016-01-081-3/+2
| | | | llvm-svn: 257218
* Use shorter name. NFC.Rui Ueyama2016-01-081-1/+1
| | | | llvm-svn: 257217
* Update comments.Rui Ueyama2016-01-081-2/+6
| | | | llvm-svn: 257216
* Remove an empty constructor.Rui Ueyama2016-01-081-2/+0
| | | | | | | We used to have code in SymbolTable constructor to add entry symbols, etc. That code has been moved to Driver. We can remove the constructor. llvm-svn: 257214
* ELF: Consistently return SymbolBody * from SymbolTable::add functions.Rui Ueyama2016-01-081-4/+7
| | | | | | | | For historical reasons, some add* functions for SymbolTable returns a pointer to a SymbolBody, while some are not. This patch is to make them consistently return a pointer to a newly added symbol. llvm-svn: 257211
* ELF: Implement --wrap.Rui Ueyama2016-01-071-0/+1
| | | | | | | | | | | | | In this patch, all symbols are resolved normally and then wrap options are applied. Renaming is implemented by mutating `Body` pointers of Symbols. (As a result, Symtab.find(SymbolName)->getName() may return a string that's different from SymbolName, but that is by design. I designed the symbol and the symbol table to allow this kind of operations.) http://reviews.llvm.org/D15896 llvm-svn: 257075
* Rename Comdats -> ComdatGroups.Rui Ueyama2016-01-061-1/+1
| | | | | | | I usually prefer short names, but in this case the new descriptive name should improve readability a bit. llvm-svn: 256899
* Remove SymbolTable::isUndefined.Rui Ueyama2016-01-051-1/+0
| | | | | | Because it can be implemented outside of the symbol table. llvm-svn: 256869
* Make findFile() a member function of SymbolTable to simplify. NFC.Rui Ueyama2016-01-051-5/+1
| | | | llvm-svn: 256867
* Simplify memory management.Rafael Espindola2015-12-231-1/+1
| | | | | | We no longer need an explicit delete or a polymorphic destructor. llvm-svn: 256333
* Split Undefined and UndefinedElf.Rafael Espindola2015-12-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | I am working on adding LTO support to the new ELF lld. In order to do that, it will be necessary to represent defined and undefined symbols that are not from ELF files. One way to do it is to change the symbol hierarchy to look like Defined : SymbolBody Undefined : SymbolBody DefinedElf<ELFT> : Defined UndefinedElf<ELFT> : Undefined Another option would be to use bogus Elf_Sym, but I think that is getting a bit too hackish. This patch does the Undefined/UndefinedElf. Split. The next one will do the Defined/DefinedElf split. llvm-svn: 256289
* Refactor duplicated code. NFC.Rafael Espindola2015-12-211-0/+5
| | | | llvm-svn: 256180
* ELF: Move shouldUseRela to Writer.cpp.Rui Ueyama2015-12-161-2/+0
| | | | | | | The function was used only in Writer.cpp and did not depend on SymbolTable. There is no reason to have that function in SymbolTable.cpp. llvm-svn: 255850
* ELF: Make checkCompatibility a non-member function.Rui Ueyama2015-12-161-1/+0
| | | | | | Because the function does not use any member of SymbolTable class. llvm-svn: 255849
* ELF: Remove duplicate code.Rui Ueyama2015-12-161-2/+4
| | | | | | | We had duplicate code that were called before addMemberFile. This patch makes them to be called at beginning of addMemberFile. llvm-svn: 255845
* ELF: Remove SymbolTable::addELFFile.Rui Ueyama2015-12-161-1/+0
| | | | | | | | addELFFile was called only from addFile, and what it did was actually just adding a file to the symbol table. There seems to be no reason to separate the two. llvm-svn: 255839
* ELF: Drop 'Sym' suffix from member function names for consistency.Rui Ueyama2015-12-161-5/+5
| | | | | | | Since the functions are members of SymbolTable class, it is obvious that they are adding symbols. llvm-svn: 255832
* ELF: Separate error message generation from call of error() or warning().Rui Ueyama2015-12-161-2/+1
| | | | | | | Previously reportConflict returned only when the third argument is false. Now it always returns a value. llvm-svn: 255829
* [ELF][MIPS] Handle R_MIPS_HI16/LO16 relocations against _gp_disp symbolSimon Atanasyan2015-12-161-1/+1
| | | | | | | | | | | | The `_gp_disp` is a magic symbol designates offset between start of function and gp pointer into GOT. Only `R_MIPS_HI16` and `R_MIPS_LO16` relocations are permitted with `_gp_disp`. The patch adds the `_gp_disp` as an ignored symbol and adjusts symbol value before call the `relocateOne` for `R_MIPS_HI16/LO16` relocations. Differential Revision: http://reviews.llvm.org/D15480 llvm-svn: 255768
* [ELF2] Add GOT section for MIPS target.Igor Kudrin2015-11-061-0/+2
| | | | | | | | | | | | | | | This patch implements R_MIPS_GOT16 relocation for global symbols in order to generate some entries in GOT. Only reserved and global entries are supported for now. For the detailed description about GOT in MIPS, see "Global Offset Table" in Chapter 5 in the followin document: ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf In addition, the platform specific symbol "_gp" is added, see "Global Data Symbols" in Chapter 6 in the aforementioned document. Differential revision: http://reviews.llvm.org/D14211 llvm-svn: 252275
* ELF2: Implement --gc-sections.Rui Ueyama2015-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Section garbage collection is a feature to remove unused sections from outputs. Unused sections are sections that cannot be reachable from known GC-root symbols or sections. Naturally the feature is implemented as a mark-sweep garbage collector. In this patch, I added Live bit to InputSectionBase. If and only if Live bit is on, the section will be written to the output. Starting from GC-root symbols or sections, a new function, markLive(), visits all reachable sections and sets their Live bits. Writer then ignores sections whose Live bit is off, so that such sections are excluded from the output. This change has small negative impact on performance if you use the feature because making sections means more work. The time to link Clang changes from 0.356s to 0.386s, or +8%. It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes. That is 4.3% reduction. http://reviews.llvm.org/D13950 llvm-svn: 251043
* ELF2: Use ELFT to template OutputSections.Rui Ueyama2015-10-151-3/+2
| | | | | | | | | | | | This patch is to use ELFT instead of Is64Bits to template OutputSection and its subclasses. This increases code size slightly because it creates two identical functions for some classes, but that's only 20 KB out of 33 MB, so it's negligible. This is as per discussion with Rafael. He's not fan of the idea but OK with this. We'll revisit later to this topic. llvm-svn: 250466
* ELF2: Implement __start_SECNAME and __stop_SECNAME.Rui Ueyama2015-10-151-0/+1
| | | | | | | | | | If a section name is valid as a C identifier (which is rare because of the leading '.'), linkers are expected to define __start_<secname> and __stop_<secname> symbols. They are at beginning and end of the section, respectively. This is not requested by the ELF standard, but GNU ld and gold provide this feature. llvm-svn: 250432
* Use OutputSectionBase in a few cases where we don't need a OutputSection.Rafael Espindola2015-10-151-1/+3
| | | | | | | NFC. This is just preparation for adding a new OutputSection dedicated to SHF_MERGE input sections. llvm-svn: 250419
* ELF2: Avoid using "finalize" as a function name.Rui Ueyama2015-10-131-1/+1
| | | | | | | | | "finalize" does not give a hint about what that function is actually going to do. This patch make it more specific by renaming scanShlibUndefined. Also add a comment that we basically ignore undefined symbols in DSOs except this function. llvm-svn: 250191
* ELF2: Fix BSD's __progname symbol issue.Rui Ueyama2015-10-131-0/+2
| | | | | | | | | | | | | BSD's DSO files have undefined symbol "__progname" which is defined in crt1.o. On that system, both user programs and system shared libraries depend on each other. In general, we need to put symbols defined by user programs which are referenced by shared libraries to user program's .dynsym. http://reviews.llvm.org/D13637 llvm-svn: 250176
* Removed undefined and unused member. NFC.George Rimar2015-10-131-1/+0
| | | | llvm-svn: 250163
* ELF2: Split SymbolTable::addFile(). NFC.Rui Ueyama2015-10-121-0/+1
| | | | llvm-svn: 250073
* Delete getFirstELF.Rafael Espindola2015-10-121-8/+0
| | | | llvm-svn: 250030
* Simplify the InputFile type hierarchy.Rafael Espindola2015-10-121-2/+2
| | | | | | | Now that the SymbolTable is templated, we don't need the ELFData class or multiple inheritance. llvm-svn: 250005
* ELF2: Move Target and entry initialization from SymbolTable to Driver.Rui Ueyama2015-10-091-11/+2
| | | | | | | | SymbolTable was not a right place for initialization. We had to do that because Driver didn't know what type of ELF objects are being handled. We taught Driver that, so we can now move this code to Driver. llvm-svn: 249904
* ELF2: Make SymbolTable a template class.Rui Ueyama2015-10-091-14/+9
| | | | | | | | | | | | | | | | | | | | | | | SymbolTable was not a template class. Instead we had switch-case-based type dispatch to call desired functions. We had to do that because SymbolTable was created before we know what ELF type objects had been passed. Every time I tried to add a new function to the symbol table, I had to define a dispatcher which consist of a single switch statement. It also brought an restriction what the driver can do. For example, we cannot add undefined symbols before any files are added to the symbol table. That's because no symbols can be added until the symbol table knows the ELF type, but when it knows about that, it's too late. In this patch, the driver makes a decision on what ELF type objects are being handled. Then the driver creates a SymbolTable object for an appropriate ELF type. http://reviews.llvm.org/D13544 llvm-svn: 249902
OpenPOWER on IntegriCloud