summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Relocations.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Delete getSectionHdr.Rafael Espindola2016-10-251-2/+2
| | | | | | | | | | | We were fairly inconsistent as to what information should be accessed with getSectionHdr and what information (like alignment) was stored elsewhere. Now all section info has a dedicated getter. The code is also a bit more compact. llvm-svn: 285079
* [ELF][MIPS] Put local GOT entries accessed via a 16-bit index firstSimon Atanasyan2016-10-211-9/+10
| | | | | | | | | | | | | | | | | | | | | | Some MIPS relocations used to access GOT entries are able to manipulate 16-bit index. The other ones like R_MIPS_CALL_HI16/LO16 can handle 32-bit indexes. 16-bit relocations are generated by default. The 32-bit relocations are generated by -mxgot flag passed to compiler. Usually these relocation are not mixed in the same code but files like crt*.o contain 16-bit relocations so even if all "user's" code compiled with -mxgot flag a few 16-bit relocations might come to the linking phase. Now LLD does not differentiate local GOT entries accessed via a 16-bit and 32-bit indexes. That might lead to relocation's overflow if 16-bit entries are allocated to far from the beginning of the GOT. The patch introduces new "part" of MIPS GOT dedicated to the local GOT entries accessed by 32-bit relocations. That allows to put local GOT entries accessed via a 16-bit index first and escape relocation's overflow. Differential revision: https://reviews.llvm.org/D25833 llvm-svn: 284809
* Compact SectionPiece.Rafael Espindola2016-10-201-1/+1
| | | | | | | We allocate a lot of these when linking debug info. This speeds up the link of debug programs by 1% to 2%. llvm-svn: 284716
* [ELF] Allow relative exceptions relocations in shared librariesPeter Smith2016-10-201-8/+10
| | | | | | | | | | | | | The R_ARM_PREL31 and R_ARM_NONE relocations should not be faulted in shared libraries. In the case of R_ARM_NONE, we have moved the TLS relaxation hint instruction to R_TLSDESC_CALL so that R_HINT can be used without side-effects. In the case of R_ARM_PREL31 we permit it to be used against PLT entries as the personality routines are imported when used in shared libraries. Differential Revision: https://reviews.llvm.org/D25721 llvm-svn: 284710
* [ELF] - Applied clang format. NFC.George Rimar2016-10-201-4/+5
| | | | llvm-svn: 284705
* [ELF] Don't fail if undefined symbol is not usedEugene Leviant2016-10-061-0/+24
| | | | | | Differential revision: https://reviews.llvm.org/D25240 llvm-svn: 283431
* Rename warning -> warn.Rui Ueyama2016-09-291-1/+1
| | | | | | It's better because it's a verb. llvm-svn: 282763
* [ARM] ARM TLS shouldn't use relaxationsPeter Smith2016-09-231-17/+26
| | | | | | | | | | | | | | | | | The ARM TLS relocations are placed on literal data and not the code-sequence, it is therefore not possible to implement the relaxTls* functions. This change updates handleMipsTlsRelocation() to handleNoRelaxTlsRelocation() and incorporates ARM as well as Mips. The ARM support in handleNoRelaxTlsRelocation() currently needs to ouput the module index dynamic relocation in all cases as it is relying on the dynamic linker to set the module index in the got. Should address PR30218 Differential Revision: https://reviews.llvm.org/D24827 llvm-svn: 282250
* Store an ArrayRef for Data in InputSectionData.Rafael Espindola2016-09-121-1/+1
| | | | llvm-svn: 281210
* [ELF][MIPS] Fix initialization of TLS-related GOT entriesSimon Atanasyan2016-09-081-4/+4
| | | | | | | | | | | | | | This patch allows static linking of TLS code. To do that it fixes GOT entries initialization. If TLS-related GOT entry created for a preemptible symbol i.e. has a corresponding dynamic relocation, leave the entry initialized by zero. Write down adjusted TLS symbol's values otherwise. For the adjustments calculation use offsets for thread-local storage. https://www.linux-mips.org/wiki/NPTL llvm-svn: 280914
* [ELF][MIPS] Update the commentSimon Atanasyan2016-09-081-2/+4
| | | | llvm-svn: 280913
* Delete dead field. NFC.Rafael Espindola2016-09-071-11/+11
| | | | llvm-svn: 280856
* Mark R_GOTREL_FROM_END as a relative expression.Rafael Espindola2016-09-061-2/+3
| | | | | | Fixes pr30282. llvm-svn: 280709
* Fix the implementation of R_386_GOTPC and R_386_GOTOFF.Rafael Espindola2016-08-311-1/+2
| | | | | | | | They were both pointing to the start of the got, not the end. Fixes pr28924. llvm-svn: 280310
* [ELF] Only print symbol name when it is availablePetr Hosek2016-08-221-6/+9
| | | | | | | | | | | Not only symbols (like sections) have names, in case where we fail to create relocation against such symbol, we should not print out an empty string, instead we should print a generic message. Differential Revision: https://reviews.llvm.org/D23731 llvm-svn: 279459
* [ELF] - Fix for PR28976 - Corrupted section contents when using linker scriptsGeorge Rimar2016-08-191-1/+1
| | | | | | | | | | | | This is fix for PR28976. Problem was that in scanRelocs, we computed relocation offset too early for case when linkerscript was used. Patch fixes the issue delaying the calculation. Differential revision: https://reviews.llvm.org/D23655 llvm-svn: 279264
* [ELF] Improve error reporting for relocationsPetr Hosek2016-08-181-4/+12
| | | | | | | | | | | | We should always include symbol name when reporting relocations error to simplify debugging of these issues. Without symbol names users have to manually investigate which of the libraries contain invalid relocations which can be cumbersome when linking multiple libraries. Differential Revision: https://reviews.llvm.org/D23690 llvm-svn: 279162
* Really fix invalid EhSectionPiece access.Rafael Espindola2016-07-211-6/+6
| | | | | | I wonder what is the most idiomatic way to write this. llvm-svn: 276338
* [ELF] - Fixed 3 testases failtures on win32 configuration.George Rimar2016-07-211-1/+1
| | | | | | | | | | | | | | | | Had 3 testcases failtures: ELF/eh-frame-merge.s ELF/gc-sections-eh.s ELF/gc-sections-lsda.s​ Problem was that OutputOff is size_t, which is 32 for this configuration and next condition never was checked correctly: if (PieceI->OutputOff == (uintX_t)-1) continue; llvm-svn: 276296
* Delete EhInputSection::getOffset.Rafael Espindola2016-07-201-1/+0
| | | | | | | | | | | | | We no longer need it for relocations in .eh_frame. The only relocations that point to .eh_frame are the ones trying to find the output .eh_frame. This actually fixes a bug in the symbol value code. It was not handling -1 as an indicator for a piece not being included in the output. llvm-svn: 276175
* Avoid use of uninitialized iterators.Rafael Espindola2016-07-201-4/+4
| | | | llvm-svn: 276157
* Create thunks before regular relocation scan.Rafael Espindola2016-07-201-33/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We will need to do something like this to support range extension thunks since that process is iterative. Doing this also has the advantage that when doing the regular relocation scan the offset in the output section is known and we can just store that. This reduces the number of times we have to run getOffset and I think will allow a more specialized .eh_frame representation. By itself this is already a performance win. firefox master 7.295045737 patch 7.209466989 0.98826892235 chromium master 4.531254468 patch 4.509221804 0.995137623774 chromium fast master 1.836928973 patch 1.823805241 0.992855612714 the gold plugin master 0.379768791 patch 0.380043405 1.00072310839 clang master 0.642698284 patch 0.642215663 0.999249070657 llvm-as master 0.036665467 patch 0.036456225 0.994293213284 the gold plugin fsds master 0.40395817 patch 0.404384555 1.0010555177 clang fsds master 0.722045545 patch 0.720946135 0.998477367518 llvm-as fsds master 0.03292646 patch 0.032759965 0.994943428477 scylla master 3.427376378 patch 3.368316181 0.98276810292 llvm-svn: 276146
* Use iterators to avoid dereferencing end().Rafael Espindola2016-07-201-4/+4
| | | | | | Thanks to George Rimar for finding the problem. llvm-svn: 276144
* Avoid some binary searches.Rafael Espindola2016-07-201-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In here we are iterating relocations in order, so we can do the same with the pieces of .eh_frame and avoid a binary search. The link times I got with this patch were: firefox master 7.22977811 patch 7.141041442 0.987726225252 chromium master 4.478966851 patch 4.506602207 1.00617002914 chromium fast master 1.894713371 patch 1.866446889 0.98508139414 the gold plugin master 0.386193907 patch 0.382374918 0.990111213743 clang master 0.654849589 patch 0.647899815 0.989387220949 llvm-as master 0.037212718 patch 0.036858172 0.990472450843 the gold plugin fsds master 0.410876711 patch 0.407418613 0.991583611562 clang fsds master 0.734623069 patch 0.728237526 0.991307728726 llvm-as fsds master 0.033446197 patch 0.03302833 0.987506292569 scylla master 3.38134402 patch 3.414188846 1.00971354166 llvm-svn: 276108
* Add a pointer to a source file to SymbolBody.Rui Ueyama2016-07-171-3/+3
| | | | | | | | | | | | 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
* Recommit R274836 Add Thunk support framework for ARM and MipsPeter Smith2016-07-081-14/+12
| | | | | | | | | | | The TinyPtrVector of const Thunk<ELFT>* in InputSections.h can cause build failures on certain compiler/library combinations when Thunk<ELFT> is not a complete type or is an abstract class. Fixed by making Thunk<ELFT> non Abstract. type or is an abstract class llvm-svn: 274863
* Revert R274836 Add Thunk support framework for ARM and MipsPeter Smith2016-07-081-12/+14
| | | | | | | This seems to be causing a buildbot failure on lld-x86_64-freebsd. Will reproduce locally and fix. llvm-svn: 274841
* Add Thunk support framework for ARM and MipsPeter Smith2016-07-081-14/+12
| | | | | | | | | | | | | | | | | | | | | | | Generalise the Mips LA25 Thunk code and implement ARM and Thumb interworking Thunks. - Introduce a new module Thunks.cpp to store the Target Specific Thunk implementations. - DefinedRegular and Shared have a ThunkData field to record Thunk. - A Target can have more than one type of Thunk. - Support PC-relative calls to Thunks. - Support Thunks to PLT entries. - Existing Mips LA25 Thunk code integrated. - Support for ARMv7A interworking Thunks. Limitations: - Only one Thunk per SymbolBody, this is sufficient for all currently implemented Thunks. - ARM thunks assume presence of V6T2 MOVT and MOVW instructions. Differential revision: http://reviews.llvm.org/D21891 llvm-svn: 274836
* [ELF][MIPS] Support MIPS TLS relocationsSimon Atanasyan2016-06-231-4/+44
| | | | | | | | | | | | | | | | | | | | | | | The patch adds one more partition to the MIPS GOT. This time it is for TLS related GOT entries. Such entries are located after 'local' and 'global' ones. We cannot get a final offset for these entries at the time of creation because we do not know size of 'local' and 'global' partitions. So we have to adjust the offset later using `getMipsTlsOffset()` method. All MIPS TLS relocations which need GOT entries operates MIPS style GOT offset - 'offset from the GOT's beginning' - MipsGPOffset constant. That is why I add new types of relocation expressions. One more difference from othe ABIs is that the MIPS ABI does not support any TLS relocation relaxations. I decided to make a separate function `handleMipsTlsRelocation` and put MIPS TLS relocation handling code there. It is similar to `handleTlsRelocation` routine and duplicates its code. But it allows to make the code cleaner and prevent pollution of the `handleTlsRelocation` by MIPS 'if' statements. Differential Revision: http://reviews.llvm.org/D21606 llvm-svn: 273569
* Fix a bug that MIPS thunks can overwrite other section contents.Rui Ueyama2016-06-231-15/+16
| | | | | | | | | | | | | | | Peter Smith found while trying to support thunk creation for ARM that LLD sometimes creates broken thunks for MIPS. The cause of the bug is that we assign file offsets to input sections too early. We need to create all sections and then assign section offsets because appending thunks changes file offsets for all following sections. This patch separates the pass to assign file offsets from thunk creation pass. This effectively reverts r265673. Differential Revision: http://reviews.llvm.org/D21598 llvm-svn: 273532
* Do not scan relocations twice for MIPS.Rui Ueyama2016-06-221-22/+10
| | | | | | | | | | | Previously, relocations for MIPS were scanned twice; once in regular scanRelocs() and the other is in scanRelocsForThunks. In the former function, we computed types of relocations and skipped R_THUNK relocations. In the latter function, we computed the same value again and skipped all but R_THUNK relocations. It was wasteful. This patch fixes that. Now R_THUNK relocations are handled in the regular manner. llvm-svn: 273346
* [ELF] - Lowercase the error messages text. NFC.George Rimar2016-06-201-2/+2
| | | | llvm-svn: 273156
* Fix comment.Rui Ueyama2016-06-201-1/+1
| | | | llvm-svn: 273140
* [ELF][MIPS] Support GOT entries for non-preemptible symbols with different ↵Simon Atanasyan2016-06-191-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | addends There are two motivations for this patch. The first one is a preparation for support MIPS TLS relocations. It might sound like a joke but for GOT entries related to TLS relocations MIPS ABI uses almost regular approach with creation of dynamic relocations for each GOT enty etc. But we need to separate these 'regular' TLS related entries from MIPS specific local and global parts of GOT. ABI declare simple solution - all TLS related entries allocated at the end of GOT after local/global parts. The second motivation it to support GOT relocations for non-preemptible symbols with addends. If we have more than one GOT relocations against symbol S with different addends we need to create GOT entries for each unique Symbol/Addend pairs. So we store all MIPS GOT entries in separate containers. For non-preemptible symbols we have to maintain two data structures. The first one is MipsLocal vector. Each entry corresponds to the GOT entry from the 'local' part of the GOT contains the symbol's address plus addend. The second one is MipsLocalMap. It is a map from Symbol/Addend pair to the GOT index. Differential Revision: http://reviews.llvm.org/D21297 llvm-svn: 273127
* Don't confuse input and output section offsets.Rafael Espindola2016-06-171-5/+5
| | | | llvm-svn: 273006
* Simplify. NFC.Rafael Espindola2016-06-171-3/+3
| | | | llvm-svn: 273004
* Rename Align -> Alignment.Rui Ueyama2016-06-171-3/+3
| | | | | | | | I think it is me who named these variables, but I always find that they are slightly confusing because align is a verb. Adding four letters is worth it. llvm-svn: 272984
* [ELF] Use static function isPreemptible instead of ↵Simon Atanasyan2016-06-101-1/+1
| | | | | | | | SymbolBody::isPreemptible. NFC Just for consistency with other parts of the code. llvm-svn: 272390
* [ELF][MIPS] Fix mask used to parse MIPS 3-in-1 relocation packetSimon Atanasyan2016-06-101-2/+2
| | | | | | | | In isPreemptible routine we interested in R_MIPS_GPREL16 relocation only. This relocation fits 0xf. So the new mask 0xff is just to conform the ABI specification. llvm-svn: 272388
* [ELF] - Inform user that we do not support dynamic relocations against text ↵George Rimar2016-06-101-2/+2
| | | | | | | | | | | | | | | | segment. It was reported in PR28020, that lld does not link code which gold do. But in fact that is expected behavior as we do not support DT_TEXTREL. This patch changes error message as it can report about relocations against text segments exclusively, other dynamic relocations errors can be handled separately. Differential revision: http://reviews.llvm.org/D21133 llvm-svn: 272377
* [ELF] - Removed excessive variable. NFC.George Rimar2016-06-091-2/+1
| | | | llvm-svn: 272265
* Handle gd tls relocs pointing to local symbols.Rafael Espindola2016-06-081-3/+7
| | | | | | | | | If the symbol is local we don't need to create a R_X86_64_DTPOFF64, we can just write the correct value in the got. Should fix pr28018. llvm-svn: 272205
* Move a function declaration to a header.Rui Ueyama2016-06-081-2/+0
| | | | llvm-svn: 272146
* [ELF] - Fixed mistype in comment. NFC.George Rimar2016-06-081-1/+1
| | | | llvm-svn: 272134
* [ELF] Replace getELFRelocationTypeName() calls with getRelName(). NFC.George Rimar2016-06-081-10/+8
| | | | | | That made few places in code a bit shorter. llvm-svn: 272133
* Implement gd to ie relaxation for aarch64.Rafael Espindola2016-06-041-1/+1
| | | | llvm-svn: 271815
* Use adjustRelaxExpr for tls relaxations too.Rafael Espindola2016-06-041-2/+4
| | | | | | | This remove some EM_386 specific code from InputSection.cpp and opens the way for more relaxations. llvm-svn: 271814
* Rename TlsGdToLeSkip.Rafael Espindola2016-06-041-1/+1
| | | | | | It will also be used for GT_TO_IE relaxations. llvm-svn: 271813
* Rename adjustRelaxGotExpr.Rafael Espindola2016-06-041-1/+1
| | | | | | It will be used for more than just gots. llvm-svn: 271812
* Fix implicit plt creation on aarch64.Rafael Espindola2016-06-041-1/+4
| | | | | | We were not handling page relative relocations. llvm-svn: 271798
OpenPOWER on IntegriCloud