summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Symbols.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify dynamic relocation creation.Rafael Espindola2016-04-071-4/+21
| | | | | | | The position of a relocation can always be expressed as an offset in an output section. llvm-svn: 265682
* Use a bit in SymbolBody to store CanKeepUndefined.Rafael Espindola2016-04-061-6/+9
| | | | | | UndefinedElf for 64 bits goes from 72 to 64 bytes. llvm-svn: 265543
* Change the type hierarchy for undefined symbols.Rafael Espindola2016-04-061-21/+31
| | | | | | | | | | 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
* Fix use of uninitialized.Rafael Espindola2016-04-061-1/+1
| | | | | | | The names of undefined locals are not used, so I don't think it is possible to actually test this. llvm-svn: 265534
* Rename a few Visibility arguments to StOther.Rafael Espindola2016-04-061-14/+14
| | | | llvm-svn: 265533
* Remove redundant argument. NFC.Rafael Espindola2016-04-051-1/+1
| | | | llvm-svn: 265386
* ELF: Make SymbolBody::compare a non-template function.Peter Collingbourne2016-04-051-7/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D18781 llvm-svn: 265372
* ELF: Preserve MustBeInDynSym for bitcode symbols.Peter Collingbourne2016-04-051-1/+3
| | | | | | | | | | | Make sure to copy the MustBeInDynSym field when replacing shared symbols with bitcode symbols, and when replacing bitcode symbols with regular symbols in addCombinedLtoObject. Fixes interposition of DSO symbols with bitcode symbols in the main executable. Differential Revision: http://reviews.llvm.org/D18780 llvm-svn: 265371
* Rename Other -> StOther.Rui Ueyama2016-04-041-2/+3
| | | | | | "Other" as a name is too generic, so name it StOther. llvm-svn: 265332
* Don't store an Elf_Sym for most symbols.Rafael Espindola2016-04-041-43/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 DefinedElf class.Rui Ueyama2016-04-021-2/+17
| | | | | | | | | | | | | | | | | | DefinedElf was a superclass of DefinedRegular and SharedSymbol classes and represented the notion of defined symbols created for ELF symbols. It turned out that we didn't use that class often. We had only two occurrences of dyn_cast'ing to DefinedElf, and both were easily rewritten without it. The class was also a bit confusing. The concept of "created for ELF symbol" is orthogonal to defined/undefined types. However, we had two distinct classes, DefinedElf and UndefinedElf. This patch simply removes the class. Now the class hierarchy is one level shallower. llvm-svn: 265234
* [ELF] Implement infrastructure for thunk code creationSimon Atanasyan2016-03-311-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some targets might require creation of thunks. For example, MIPS targets require stubs to call PIC code from non-PIC one. The patch implements infrastructure for thunk code creation and provides support for MIPS LA25 stubs. Any MIPS PIC code function is invoked with its address in register $t9. So if we have a branch instruction from non-PIC code to the PIC one we cannot make the jump directly and need to create a small stub to save the target function address. See page 3-38 ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - In relocation scanning phase we ask target about thunk creation necessity by calling `TagetInfo::needsThunk` method. The `InputSection` class maintains list of Symbols requires thunk creation. - Reassigning offsets performed for each input sections after relocation scanning complete because position of each section might change due thunk creation. - The patch introduces new dedicated value for DefinedSynthetic symbols DefinedSynthetic::SectionEnd. Synthetic symbol with that value always points to the end of the corresponding output section. That allows to escape updating synthetic symbols if output sections sizes changes after relocation scanning due thunk creation. - In the `InputSection::writeTo` method we write thunks after corresponding input section. Each thunk is written by calling `TargetInfo::writeThunk` method. - The patch supports the only type of thunk code for each target. For now, it is enough. Differential Revision: http://reviews.llvm.org/D17934 llvm-svn: 265059
* Revert r264961. I didn't have asserts enable when testing.Davide Italiano2016-03-291-1/+1
| | | | llvm-svn: 264692
* [LTO] Include bitcode symbol name in unreachable messages.Davide Italiano2016-03-291-1/+1
| | | | llvm-svn: 264691
* Make needsPlt a plain function instead of a template.Rafael Espindola2016-03-241-11/+0
| | | | llvm-svn: 264267
* [ELF] Simplify code a bit. No functional change.Davide Italiano2016-03-211-3/+1
| | | | llvm-svn: 263999
* Make evaluation order explicit.Rafael Espindola2016-03-171-1/+2
| | | | llvm-svn: 263762
* Use ELFT instead of ELFFile<ELFT>.Rui Ueyama2016-03-141-17/+11
| | | | llvm-svn: 263510
* [ELF] implement --warn-common/--no-warn-commonGeorge Rimar2016-03-141-0/+4
| | | | | | | | | | | | | -warn-common Warn when a common symbol is combined with another common symbol or with a symbol definition. Unix linkers allow this somewhat sloppy practice, but linkers on some other operating systems do not. This option allows you to find potential problems from combining global symbols. Differential revision: http://reviews.llvm.org/D17998 llvm-svn: 263413
* Remove `else` after `return`.Rui Ueyama2016-03-131-2/+1
| | | | llvm-svn: 263392
* ELF: Redefine canBeDefined as a member function of SymbolBody.Rui Ueyama2016-03-131-0/+32
| | | | | | | | | We want to make SymbolBody the central place to query symbol information. This patch also renames canBePreempted to isPreemptible because I feel that the latter is slightly better (the former is three words and the latter is two words.) llvm-svn: 263386
* Redefine isGnuIfunc as a member function of SymbolBody.Rui Ueyama2016-03-131-0/+11
| | | | llvm-svn: 263365
* Recommit of r263252, [ELF] - Change all messages to lowercase to be consistent.George Rimar2016-03-121-3/+3
| | | | | | | | | | | | | | | | | | | | | which was reverted because included unrelative changes by mistake. Original commit message: [ELF] - Change all messages to lowercase to be consistent. That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263337
* Revert r263252: "[ELF] - Change all messages to lowercase to be consistent."Rui Ueyama2016-03-111-3/+3
| | | | | | This reverts commit r263252 because the change contained unrelated changes. llvm-svn: 263272
* [ELF] - Change all messages to lowercase to be consistent.George Rimar2016-03-111-3/+3
| | | | | | | | | | | | | | That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263252
* Represent local symbols with DefinedRegular.Rafael Espindola2016-03-111-33/+18
| | | | llvm-svn: 263237
* Compute value of local symbol with getVA.Rafael Espindola2016-03-111-31/+60
| | | | llvm-svn: 263225
* Create a SymbolBody for locals.Rafael Espindola2016-03-111-0/+2
| | | | | | pr26878 shows a case where locals have to be in the got. llvm-svn: 263222
* [ELF] - Move initSymbols() to Driver.cpp. NFC.George Rimar2016-03-111-13/+0
| | | | | | | That is followup for http://reviews.llvm.org/D18047 patch. initSymbols() moved to Driver.cpp and made static. llvm-svn: 263214
* Rename MaxAlignment -> Alignment.Rui Ueyama2016-03-101-6/+3
| | | | | | | | We can argue about a maximum alignment of a group of symbols, but for each symbol, there is only one alignment. So it is a bit weird that each symbol has a "maximum alignment". llvm-svn: 263151
* [ELF] - Refactor of SymbolBody::compare()George Rimar2016-03-101-18/+15
| | | | | | | | That makes it a bit shorter. Differential revision: http://reviews.llvm.org/D18004 llvm-svn: 263144
* [ELF] - Do not call doInitSymbols for all ELFTsGeorge Rimar2016-03-101-8/+6
| | | | | | | | | | It looks a bit wierd that we have to initialize symbols for all ELFT types when we use only one ELFT for link. We can only init those that we need. Patch fixes it. Differential revision: http://reviews.llvm.org/D18047 llvm-svn: 263133
* ELF: Remove non-standard ELF features from AMDGPU target.Rafael Espindola2016-03-091-6/+0
| | | | | | Patch by Tom Stellard! llvm-svn: 263063
* lto: Record visibility in defined symbols.Rafael Espindola2016-03-071-2/+2
| | | | llvm-svn: 262835
* [ELF] - Simplify a SymbolBody class interface a bit.George Rimar2016-03-061-1/+1
| | | | | | | | | Get rid of few accessors in that class, and replace them with direct fields access. Differential revision: http://reviews.llvm.org/D17879 llvm-svn: 262796
* [ELF] Generalize symbol type handling.Davide Italiano2016-03-041-11/+10
| | | | | | | | | | | | | | | SymbolBody constructor and friends take isFunc and isTLS boolean arguments. ELF symbols have already a type so than be easily passed as argument. If we want to support another type, this scheme is not good enough, that is, the current code logic would require passing another `bool isObject` around. Up to two argument, this stretching exercise was a little bit goofy but still acceptable, but with more types to support, is just too much, IMHO. Change the code so that the type is passed instead. Differential Revision: http://reviews.llvm.org/D17871 llvm-svn: 262684
* [ELF] - Create _DYNAMIC symbol for dynamic outputGeorge Rimar2016-03-011-2/+3
| | | | | | | | | | | 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-11/+11
| | | | llvm-svn: 262159
* Add comment on AMDGPU that the difference has no obvious reason.Rui Ueyama2016-02-261-2/+4
| | | | llvm-svn: 262026
* Description of symbols is avalable here:George Rimar2016-02-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | https://docs.oracle.com/cd/E53394_01/html/E54766/u-etext-3c.html It is said that: _etext - The address of _etext is the first location after the last read-only loadable segment. _edata - The address of _edata is the first location after the last read-write loadable segment. _end - If the address of _edata is greater than the address of _etext, the address of _end is same as the address of _edata. In real life _end and _edata has different values for that case. Both gold/bfd set _edata to the end of the last non SHT_NOBITS section. This patch do the same for consistency. It should fix the https://llvm.org/bugs/show_bug.cgi?id=26729. Differential revision: http://reviews.llvm.org/D17601 llvm-svn: 262019
* ELF: Implement ICF.Rui Ueyama2016-02-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements the same algorithm as LLD/COFF's ICF. I'm not going to repeat the same description about how it works, so you want to read the comment in ICF.cpp in this patch if you want to know the details. This algorithm should be more powerful than the ICF algorithm implemented in GNU gold. It can even merge mutually-recursive functions (which is harder than one might think). ICF is a fairly effective size optimization. Here are some examples. LLD: 37.14 MB -> 35.80 MB (-3.6%) Clang: 59.41 MB -> 57.80 MB (-2.7%) The lacking feature is "safe" version of ICF. This merges all identical sections. That is not compatible with a C/C++ language requirement that two distinct functions must have distinct addresses. But as long as your program do not rely on the pointer equality (which is in many cases true), your program should work with the feature. LLD works fine for example. GNU gold implements so-called "safe ICF" that identifies functions that are safe to merge by heuristics -- for example, gold thinks that constructors are safe to merge because there is no way to take an address of a constructor in C++. We have a different idea which David Majnemer suggested that we add NOPs at beginning of merged functions so that two or more pointers can have distinct values. We can do whichever we want, but this patch does not include neither. http://reviews.llvm.org/D17529 llvm-svn: 261912
* Add support for weak symbols in LTO.Rafael Espindola2016-02-251-2/+2
| | | | llvm-svn: 261881
* Handle bitcode files in archive files with --whole-archive.Rui Ueyama2016-02-231-7/+0
| | | | | | | | | | This patch moves BitcodeFile instantiation into createObjectFile. Previously, we handle bitcode files outside that function and did not handle for --whole-archive. http://reviews.llvm.org/D17527 llvm-svn: 261663
* Handle undef symbols in LTO.Rafael Espindola2016-02-191-0/+7
| | | | | | This also handles bc files is archives. llvm-svn: 261374
* Add initial LTO support.Rafael Espindola2016-02-121-0/+9
| | | | llvm-svn: 260726
* Use the plt entry as the address of some symbols.Rafael Espindola2016-02-091-2/+5
| | | | | | | | | | | | | | | This is the function equivalent of a copy relocation. Since functions are expected to change sizes, we cannot use copy relocations. In situations where one would be needed, what is done instead is: * Create a plt entry * Output an undefined symbol whose addr is the plt entry. The dynamic linker makes sure any shared library uses the plt entry as the function address. llvm-svn: 260224
* Rename IsUsedInDynamicReloc to MustBeInDynSym.Rafael Espindola2016-02-051-1/+1
| | | | | | | | The variable was marking various cases where a symbol must be included in the dynamic symbol table. Being used by a dynamic relocation was only one of them. llvm-svn: 259889
* Define SymbolBody::getSize instead of getSymSize(SymbolBody&). NFC.Rui Ueyama2016-02-031-0/+12
| | | | llvm-svn: 259613
* [ELF] Implemented -Bsymbolic-functions command line optionGeorge Rimar2016-02-021-5/+8
| | | | | | | | | | | | | -Bsymbolic-functions: When creating a shared library, bind references to global function symbols to the definition within the shared library, if any. This patch also fixed behavior of already existent -Bsymbolic: previously PLT entries were created even if -Bsymbolic was specified. Differential revision: http://reviews.llvm.org/D16411 llvm-svn: 259481
* ELF: Include archive names in error messages.Rui Ueyama2016-02-021-1/+1
| | | | | | | | If object files are drawn from archive files, the error message should be something like "conflict symbols in foo.a(bar.o) and baz.o" instead of "conflict symbols in bar.o and baz.o". This patch implements that. llvm-svn: 259475
OpenPOWER on IntegriCloud