summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Relocations.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify. No functionality change intended.Rui Ueyama2017-03-231-6/+6
| | | | | | | | | I honestly do not understand this part of code as it is too tangled. What I'm trying now is to carefully disentangle it by transforming code without changing meaining to see if I can improve overall readability. llvm-svn: 298576
* Remove unnecessary local variable.Rui Ueyama2017-03-231-7/+8
| | | | llvm-svn: 298575
* [ELF][MIPS] Calculate relocations agains _gp_disp / __gnu_local_gp using ↵Simon Atanasyan2017-03-201-12/+4
| | | | | | | | | | | | | | | | | | | | | | | dedicated 'expressions' The patch introduces two new relocations expressions R_MIPS_GOT_GP and R_MIPS_GOT_GP_PC. The first one represents a current value of `_gp` pointer and used to calculate relocations against the `__gnu_local_gp` symbol. The second one represents the offset between the beginning of the function and the `_gp` pointer's value. There are two motivations for introducing new expressions: - It's better to keep all non-trivial relocation calculations in the single place - `getRelocTargetVA` function. - Relocations against both `_gp_disp` and `__gnu_local_gp` symbols depend on the `_gp` value. It's a magical value points to the "middle" of GOT. Now all relocations use a common `_gp` value. But in fact, under some conditions each input file might require its own `_gp` value. I'm going to implement it in the future patches. So it's better to make `MipsGotSection` responsible for calculation of the `_gp` value. llvm-svn: 298306
* Compute Config member function return values only once.Rui Ueyama2017-03-171-17/+16
| | | | | | | | | | | We had a few Config member functions that returns configuration values. For example, we had is64() which returns true if the target is 64-bit. The return values of these functions are constant and never change. This patch is to compute them only once to make it clear that they'll never change. llvm-svn: 298168
* recommend using llvm-ar when finding undefined references and empty archivesBob Haarman2017-03-171-2/+13
| | | | | | | | | | | | | | | | | | | | | | Summary: When we perform LTO builds with a version of ar that does not understand LLVM bitcode objects, we end up with undefined references, because our archive files do not list the bitcode symbols in their indices. The error messages do not make it clear what the real problem is. This change adds a note that points out the likely problem and solution. It is similar in spirit to r282633, but aims to avoid false positives by only triggering when we see both undefined references and archives without symbols in their indices. Fixes PR32281. Reviewers: davide, ruiu, tejohnson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31011 llvm-svn: 298124
* [ELF] - Detemplate SymbolBody::getGotOffset(). NFC.George Rimar2017-03-171-5/+4
| | | | llvm-svn: 298091
* [ELF] - Detemplate DynamicReloc class. NFC.George Rimar2017-03-171-1/+1
| | | | llvm-svn: 298072
* [ELF] - Fix linux build bot.George Rimar2017-03-171-2/+2
| | | | | | | | Error was: Relocations.cpp:792:38: error: expected primary-expression before ‘>’ token In<ELFT>::Iplt->addEntry<ELFT>(Body); llvm-svn: 298070
* [ELF] - Detemplate PltSection. NFC.George Rimar2017-03-171-2/+2
| | | | | | | Alternative approach can be remove templated method either, like D31028 do. llvm-svn: 298065
* [ELF] - Recommit "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."George Rimar2017-03-171-8/+5
| | | | | | | | | | | | | | | | | | Was fixed, details on review page. Original commit message: That removes CopyRelSection class completely, making Bss/BssRelRo to be just regular synthetics. This is splitted from D30541 and polished. Difference from D30541 that all logic of SharedSymbol converting to DefinedRegular was removed for now and probably will be posted as separate patch. Differential revision: https://reviews.llvm.org/D30892 llvm-svn: 298062
* [ELF] - Detemplate SymbolBody::getGotPltVA and ↵George Rimar2017-03-161-3/+3
| | | | | | | | | SymbolBody::getGotPltOffset(). NFC. That opens road to detemplate PltSection<ELFT>, what allows then to detemplate all methods of SymbolBody. llvm-svn: 297950
* [ELF] - Removed unused template #3. NFC.George Rimar2017-03-161-2/+1
| | | | llvm-svn: 297942
* [ELF] - Removed unused template #2. NFC.George Rimar2017-03-161-2/+1
| | | | llvm-svn: 297941
* [ELF] Detemplate ThunkSection and Thunk classes. NFC.George Rimar2017-03-161-13/+13
| | | | llvm-svn: 297939
* [ELF] - Detemplate OutputSection::assignOffsets. NFC.George Rimar2017-03-161-1/+1
| | | | llvm-svn: 297937
* Revert r297813 "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."George Rimar2017-03-161-5/+8
| | | | | | | | | I suppose it is the reason of BB fail: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/921 https://bugs.llvm.org/show_bug.cgi?id=32167 llvm-svn: 297933
* [ELF] - Make Bss and BssRelRo sections to be synthetic (#3).George Rimar2017-03-151-8/+5
| | | | | | | | | | | | | | That removes CopyRelSection class completely, making Bss/BssRelRo to be just regular synthetics. This is splitted from D30541 and polished. Difference from D30541 that all logic of SharedSymbol converting to DefinedRegular was removed for now and probably will be posted as separate patch. Differential revision: https://reviews.llvm.org/D30892 llvm-svn: 297814
* Don't create copy relocs or dummy plt's if given -z notext.Rafael Espindola2017-03-141-6/+7
| | | | | | | | | Being passed -z notext is a pretty strong indication that the user is OK with text relocations. This is not the same behavior as bfd, but bfd defaults to -z notext, so it has to try to avoid text relocations and use them as a last resort. llvm-svn: 297789
* [ELF] - Implemented -znotextGeorge Rimar2017-03-091-5/+6
| | | | | | | | | | | | | gold linker manual describes them as: -z text Do not permit relocations in read-only segments -z notext Permit relocations in read-only segments (default) In LLD default is to not permit them. Patch implements -z notext. Differential revision: https://reviews.llvm.org/D30530 llvm-svn: 297366
* Revert r297008: [ELF] - Make Bss and BssRelRo sections to be synthetic (#2).Rui Ueyama2017-03-081-11/+16
| | | | | | | This reverts commit r297008 because it's reported that that change broke AArch64 bots. llvm-svn: 297297
* Remove unnecessary template. NFC.Rafael Espindola2017-03-081-1/+1
| | | | llvm-svn: 297287
* Finalize content of synthetic sections prior to Thunk CreationPeter Smith2017-03-081-5/+6
| | | | | | | | | | | | This change moves the calls to finalizeContent() for each synthetic section before createThunks(). This will allow us to assign addresses prior to calling createThunks(). As addition of thunks may add to the static symbol table and may affect the size of the mips got section we introduce a couple of additional member functions to update these values. Differential revision: https://reviews.llvm.org/D29983 llvm-svn: 297277
* Fix Mips LA25 Thunks where Caller and Callee in different OSPeter Smith2017-03-071-1/+1
| | | | | | | | | This change fixes a bug in which the Mips LA25 Thunks are always assigned to the same Output section as the caller and not the callee as expected. Differential Revision: https://reviews.llvm.org/D30637 llvm-svn: 297135
* Remove Config->Mips64EL and define Config->isMips64EL() instead.Rui Ueyama2017-03-071-8/+8
| | | | llvm-svn: 297107
* Detemplate EhInputSection. NFC.Rafael Espindola2017-03-061-1/+1
| | | | llvm-svn: 297077
* Fix -Wc++11-narrowing.Rui Ueyama2017-03-061-1/+1
| | | | llvm-svn: 297012
* [ELF] - Make Bss and BssRelRo sections to be synthetic (#2).George Rimar2017-03-061-16/+11
| | | | | | | | | | | | | | | In compare with D30458, this makes Bss/BssRelRo to be pure synthetic sections. That removes CopyRelSection class completely, making Bss/BssRelRo to be just regular synthetics. SharedSymbols involved in creating copy relocations are converted to DefinedRegular, what also simplifies things. Differential revision: https://reviews.llvm.org/D30541 llvm-svn: 297008
* [ELF] - Reset output section size when assigning offsets.George Rimar2017-03-011-1/+0
| | | | | | | | | | | | | | | | | In many places we reset Size to 0 before calling assignOffsets() manually. Sometimes we don't do that. It looks we can just always do that inside. Previous code had: template <class ELFT> void OutputSection::assignOffsets() { uint64_t Off = Size; And tests feels fine with Off = 0. I think Off = Size make no sence. Differential revision: https://reviews.llvm.org/D30463 llvm-svn: 296609
* De-template DefinedRegular.Rui Ueyama2017-02-281-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* Remove useless template so that Out<ELFT> becomes just Out.Rui Ueyama2017-02-271-1/+1
| | | | llvm-svn: 296307
* De-template SharedSymbol.Rui Ueyama2017-02-261-26/+20
| | | | | | Differential Revision: https://reviews.llvm.org/D30351 llvm-svn: 296303
* Merge OutputSectionBase and OutputSection. NFC.Rafael Espindola2017-02-241-15/+14
| | | | | | | Now that all special sections are SyntheticSections, we only need one OutputSection class. llvm-svn: 296127
* Make InputSection a class. NFC.Rafael Espindola2017-02-231-5/+5
| | | | | | | | | With the current design an InputSection is basically anything that goes directly in a OutputSection. That includes plain input section but also synthetic sections, so this should probably not be a template. llvm-svn: 295993
* [ELF] Ignore R_*_NONE relocs when relocating non-alloc sectionsPetr Hosek2017-02-231-3/+6
| | | | | | | | | We shouldn't report an error for R_*_NONE relocs since we're emitting them when writing relocations to discarded sections. Differential Revision: https://reviews.llvm.org/D30279 llvm-svn: 295936
* Convert InputSectionBase to a class.Rafael Espindola2017-02-231-33/+32
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
* Add `-z nocopyreloc` option.Rui Ueyama2017-02-211-1/+7
| | | | | | | This option disable creating copy relocations. ld.bfd and ld.gold have the same option. llvm-svn: 295772
* Add more comments about copy relocations.Rui Ueyama2017-02-201-4/+19
| | | | llvm-svn: 295632
* Add a comment about the copy relocation.Rui Ueyama2017-02-191-0/+26
| | | | llvm-svn: 295622
* Rename getAliases -> getSymbolsAt.Rui Ueyama2017-02-171-3/+3
| | | | | | | The previous name caused a little confusion because the function not only returns aliases but a given symbol itself too. llvm-svn: 295408
* Use isRelExprOneOf.Rui Ueyama2017-02-161-6/+6
| | | | llvm-svn: 295289
* Removes a trivial accessor.Rui Ueyama2017-02-161-1/+1
| | | | llvm-svn: 295288
* Do not overload a one-bit variable, NeedsCopyOrPltAddr.Rui Ueyama2017-02-161-3/+3
| | | | | | | | | This patch removes NeedsCopyOrPltAddr and instead add two variables, NeedsCopy and NeedsPltAddr. This uses one more bit in Symbol class, but the actual size doesn't increase because we had unused bits. This should improve code readability. llvm-svn: 295287
* Split a function and add comments.Rui Ueyama2017-02-161-8/+23
| | | | | | | This is slightly inefficient than the previous code, but that is really negligible as this function is usually called at most only a few times. llvm-svn: 295282
* Add CopyRelSection instances to BSS in the regular way.Rui Ueyama2017-02-161-17/+8
| | | | | | | | | | | | | | Previously, space in a BSS section for copy relocations are reserved in a special way. We directly manipulated size of the BSS section. r294577 changed the way of doing it. Now, we create an instance of CopyRelSection (which is a synthetic input section) for each copy relocation. This patch removes the remains of the old way and add CopyRelSections to BSS sections using `addSections` function, which is the usual way to add an input section to an output section. llvm-svn: 295278
* Addends should always be signed.Rafael Espindola2017-02-161-15/+13
| | | | | | | | | | In the target dependent code we already always return a int64_t. In the target independent code we carefully use uintX_t, which has the same result given 2 complement rules. This just simplifies the code to use int64_t everywhere. llvm-svn: 295263
* Do not store a computable attributes to Config.Rui Ueyama2017-02-141-8/+9
| | | | llvm-svn: 295031
* [ELF] Use synthetic section to hold copy relocationPeter Smith2017-02-091-3/+9
| | | | | | | | | | | | | | When we need a copy relocation we create a synthetic SHT_NOBITS section that contains the right amount of ZI and assign it to either .bss or .rel.ro.bss as appropriate. This allows the dynamic relocation to be placed on the InputSection, removing the last case where a dynamic relocation is stored as an offset from the OutputSection. This has the side effect that we can run assignOffsets() after scanRelocs() without losing the additional ZI needed for the copy relocations. Differential Revision: https://reviews.llvm.org/D29637 llvm-svn: 294577
* [ELF] Use SyntheticSections for ThunksPeter Smith2017-02-011-25/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-115/+25
| | | | | | This reverts commit r293283 because it broke MSVC build. llvm-svn: 293352
* Fix and simplify the reporting of undefined symbols.Rafael Espindola2017-01-271-6/+6
| | | | | | | | | | | | Now reportUndefined only has to look at Config->UnresolvedSymbols and the symbol. getUnresolvedSymbolOption does all the hard work of mapping options like -shared and -z defs to one of the UnresolvedPolicy enum entries. The critical fix is that now "-z defs --warn-unresolved-symbols" only warns. llvm-svn: 293290
OpenPOWER on IntegriCloud