summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix the aarch64 logic for dynamic relocations.Rafael Espindola2016-02-231-39/+8
| | | | | | | | | | | | | There is nothing aarch64 specific in here. If a symbol can be preempted, we need to copy the full relocation to the dynamic linker. If a symbol cannot be preempted, we can make the dynamic linker life easier and produce a relative relocation. This is directly equivalent to R_X86_64_64 to R_x86_64_RELATIVE conversion. llvm-svn: 261678
* [lld] [ELF/AArch64] Fix R_AARCH64_ABS64 in Shared modeAdhemerval Zanella2016-02-231-8/+39
| | | | | | | | | | | | | | This patch fixes the R_AARCH64_ABS64 relocation when used in shared mode, where it requires a dynamic R_AARCH64_RELATIVE relocation. To correct set the addend on the dynamic relocation (since it will be used by the dynamic linker), a new TargetInfo specific hook was created (getDynRelativeAddend) to get the correct addend based on relocation type. The patch fixes the issues when creating shared library code against {init,fini}_array, where it issues R_AARCH64_ABS64 relocation against local symbols. llvm-svn: 261651
* Add support for merging strings with alignment larger than one char.Rafael Espindola2016-02-191-2/+3
| | | | | | | | | | | This reduces the .rodata of scyladb from 4501932 to 4334639 bytes (1.038 times smaller). I don't think it is critical to support tail merging, just exact duplicates, but given the code organization it was actually a bit easier to support both. llvm-svn: 261327
* Fixed comments formatting. NFC.George Rimar2016-02-181-1/+1
| | | | llvm-svn: 261214
* Make getOffset a member function of DynamicReloc<ELFT>.Rui Ueyama2016-02-171-15/+11
| | | | | | | Logically it belongs to DynamicReloc, and it is more readable to be a member of the class. llvm-svn: 261069
* Use shorter names for the .gnu.hash class.Rui Ueyama2016-02-171-11/+11
| | | | llvm-svn: 261067
* Use stable_partition instead of erasing all elements and fill it again.Rui Ueyama2016-02-171-23/+24
| | | | llvm-svn: 261066
* Use an accurate type instead of unsigned.Rui Ueyama2016-02-171-11/+10
| | | | | | | These values are offsets in the string table (which must fit in host computer's memory space), so size_t is better than unsigned. llvm-svn: 261065
* Split SymbolTableSection::writeGlobalSymbols.Rui Ueyama2016-02-171-34/+31
| | | | | | | | Previously, we added garbage-collected symbols to the symbol table and filter them out when we were writing symbols to the file. In this patch, garbage-collected symbols are filtered out from beginning. llvm-svn: 261064
* ELF: silence -Wcast-qual warnings from GCCSaleem Abdulrasool2016-02-151-2/+2
| | | | | | Silence 4 -Wcast-qual warnings from GCC 5.1. NFC. llvm-svn: 260871
* Add initial LTO support.Rafael Espindola2016-02-121-0/+2
| | | | llvm-svn: 260726
* Make compCtors strict weak ordering.Rui Ueyama2016-02-121-2/+2
| | | | | | | | Previously, if both A and B are ".ctors", both compCtors(A, B) and compCtors(B, A) are true, which is a violation of the strict weak ordering because such function is not antisymmetric. llvm-svn: 260633
* ELF: Implement the correct semantics of .[cd]tors.Rui Ueyama2016-02-111-9/+77
| | | | | | | | | As I noted in the comment, the sorting order of .[cd]tors are different from .{init,fini}_array's. http://reviews.llvm.org/D17120 llvm-svn: 260620
* Reorder code to improve readability. NFC.Rui Ueyama2016-02-101-3/+3
| | | | llvm-svn: 260467
* ELF: Use stable sort to sort .{init,fini}_array sections.Rui Ueyama2016-02-101-2/+3
| | | | | | | | Global constructors and destructors are guaranteed to be called in the order as they appear in a translation unit. So we don't want to mess up the order if they have the same priority. llvm-svn: 260463
* ELF: Implement __attribute__((init_priority(N)) support.Rui Ueyama2016-02-101-0/+38
| | | | llvm-svn: 260460
* Use a SymbolBody to represent the personality.Rafael Espindola2016-02-101-4/+3
| | | | | | | | NFC, just more in line with the rest of lld. Thanks to Rui for the suggestion. llvm-svn: 260380
* Rangefy, and replace a switch with `if`s. NFC.Rui Ueyama2016-02-091-12/+11
| | | | llvm-svn: 260320
* Fix inverted comparison.Rafael Espindola2016-02-091-1/+1
| | | | llvm-svn: 260310
* ELF: Add 'using namespace llvm::dwarf'.Rui Ueyama2016-02-091-22/+23
| | | | | | | Most constants defined in llvm::dwarf namespace start with "DW_". We don't have to worry about name conflicts. llvm-svn: 260297
* ELF: Add .eh_frame 'P', 'R' and 'L' augmentation characters.Rui Ueyama2016-02-091-7/+48
| | | | | | | | This basically reverts commit r260073 because it is found that augmentation strings don't always start with "zR". It is reported as https://llvm.org/bugs/show_bug.cgi?id=26541. llvm-svn: 260294
* Use the plt entry as the address of some symbols.Rafael Espindola2016-02-091-1/+1
| | | | | | | | | | | | | | | 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
* ELF: Simplify getFdeEncoding.Rui Ueyama2016-02-081-58/+15
| | | | | | | | | | | | | | | | | | | I found that the handling of 'L' character in an augmentation string is wrong because 'L' means that the next byte is the length field. I could have fixed that by just skipping the next byte, but I decided to take a different approach. Teaching the linker about all the types of CIE internal records just to skip them is silly. And the code doing that is not actually executed now (that's why the bug did not cause any issue.) It is because the 'R' field, which we want to read, is always at beginning of the CIE. So I reduced the code dramatically by assuming that that's always the case. I want to see how it works in the wild. If it doesn't work, we can roll this back (with a fix for 'L'). http://reviews.llvm.org/D16939 llvm-svn: 260073
* ELF: Simplify readEntryLength.Rui Ueyama2016-02-051-14/+14
| | | | | | | | | I removed "CIE/FIE size is too large" error because that was not checking for correct error conditions. [UINT_MAX - 4, UINT_MAX) is a correct range as a size of a CIE/FDE record. It's just that the size cannot be larger than the section size. llvm-svn: 259951
* ELF: Make EHOutputSection::readEntryLength a non-member function.Rui Ueyama2016-02-051-27/+26
| | | | | | This function did not use any fields of the class. llvm-svn: 259946
* Simplify. NFC.Rui Ueyama2016-02-051-2/+1
| | | | llvm-svn: 259903
* 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
* Centralize most calls to setUsedInDynamicReloc.Rafael Espindola2016-02-051-0/+8
| | | | llvm-svn: 259887
* ELF: Make names for TLS module indices shorter.Rui Ueyama2016-02-051-4/+6
| | | | | | | | | | The previous names contained "Local" and "Current", but what we are handling is always local and current, so they were redundant. TlsIndex comes from "tls_index" struct that Ulrich Drepper is using in this document to describe this data structure in GOT. llvm-svn: 259852
* Simplify. NFC.Rui Ueyama2016-02-041-1/+1
| | | | llvm-svn: 259848
* Avoid code duplication when creating dynamic relocations.Rafael Espindola2016-02-041-105/+32
| | | | | | | | | | | | | | | | | Another case where we currently have almost duplicated code is the creation of dynamic relocations. First to decide if we need one, then to decide what to write. This patch fixes it by passing more information from the relocation scan to the section writing code. This is the same idea used for r258723. I actually think it should be possible to simplify this further by reordering things a bit in the writer. For example, we should be able to represent almost every position in the file with an OutputSeciton and offset. When writing it out we then just need to add the offset to the OutputSection VA. llvm-svn: 259829
* Fix addend computation for IRELATIVE relocations.Rafael Espindola2016-02-031-13/+12
| | | | llvm-svn: 259692
* Simplify. NFC.Rafael Espindola2016-02-031-5/+1
| | | | llvm-svn: 259660
* [ELF] Implemented -Bsymbolic-functions command line optionGeorge Rimar2016-02-021-1/+5
| | | | | | | | | | | | | -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] Remove redundant empty line. NFCSimon Atanasyan2016-02-021-1/+0
| | | | llvm-svn: 259479
* Update a comment.Rui Ueyama2016-02-021-1/+2
| | | | llvm-svn: 259458
* Replace auto with the real type.Rui Ueyama2016-02-021-1/+1
| | | | llvm-svn: 259455
* ELF: Teach SymbolBody about how to get its addresses.Rui Ueyama2016-02-011-80/+14
| | | | | | | | | | | | | Previously, the methods to get symbol addresses were somewhat scattered in many places. You can use getEntryAddr returns the address of the symbol, but if you want to get the GOT address for the symbol, you needed to call Out<ELFT>::Got->getEntryAddr(Sym). This change adds new functions, getVA, getGotVA, getGotPltVA, and getPltVA to SymbolBody, so that you can use SymbolBody as the central place to ask about symbols. http://reviews.llvm.org/D16710 llvm-svn: 259404
* Consistenly use sizeof(uintX_t) instead of ELFT::Is64Bits ? 8 : 4.Rui Ueyama2016-01-291-4/+4
| | | | llvm-svn: 259250
* Add comments.Rui Ueyama2016-01-291-6/+9
| | | | llvm-svn: 259249
* Replace code duplications with function calls.Rui Ueyama2016-01-291-9/+3
| | | | llvm-svn: 259238
* Remove a parameter from Target::writePlt.Rui Ueyama2016-01-291-8/+5
| | | | llvm-svn: 259158
* ELF: Do not pass addresses that can be obtained using Out.Rui Ueyama2016-01-291-1/+1
| | | | llvm-svn: 259154
* Rename PltZeroEntrySize -> PltZeroSize.Rui Ueyama2016-01-291-3/+3
| | | | | | | This patch also fixes parameter name. They points to the beginning of PLT or GOT tables, so GotAddr or PltAddr are better.) llvm-svn: 259150
* ELF: Make Target's member function names shorter.Rui Ueyama2016-01-291-10/+10
| | | | llvm-svn: 259147
* Rename includeInDynamicSymtab -> includeInDynsym.Rui Ueyama2016-01-291-1/+1
| | | | llvm-svn: 259144
* Rename DynamicSymbolTableIndex -> DynsymIndex.Rui Ueyama2016-01-291-11/+9
| | | | | | This is the index in .dynsym, so the new name should make sense. llvm-svn: 259142
* ELF: Remove accessors from Target.Rui Ueyama2016-01-291-32/+32
| | | | | | These accessors do not provide values. We can simply make the variables public. llvm-svn: 259141
* Merge identical strings.Rafael Espindola2016-01-291-74/+55
| | | | | | | | | | | This avoids the need to have reserve and addString in sync. We avoid hashing the global symbols again. This means that we don't merge a global symbol that has the same name as some other string, but that doesn't seem very common. The string table size is the same in clang an scylladb with or without hashing global symbols again. llvm-svn: 259136
* Rename isTlsOptimized -> canRelaxTls.Rui Ueyama2016-01-291-1/+1
| | | | | | | | This function is a predicate that a given relocation can be relaxed. The previous name implied that it returns true if a given relocation has already been optimized away. llvm-svn: 259128
OpenPOWER on IntegriCloud