diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2016-04-20 21:40:33 +0000 |
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2016-04-20 21:40:33 +0000 |
| commit | ca58a8ff5ba77a2018e8e80014cfe7a71b746b37 (patch) | |
| tree | 325a572997d47fbac9d9d60de21f4c5f7b667d21 /lld/ELF | |
| parent | dd98c91e08318e50c3fb08cc3196dd6cfa1c3c92 (diff) | |
| download | bcm5719-llvm-ca58a8ff5ba77a2018e8e80014cfe7a71b746b37.tar.gz bcm5719-llvm-ca58a8ff5ba77a2018e8e80014cfe7a71b746b37.zip | |
[ELF][MIPS] Create GOT entries for R_MIPS_REL32 dynamic relocations
MIPS ABI turns using of GOT and dynamic relocations inside out. While
regular ABI uses dynamic relocations to fill up GOT entries MIPS ABI
requires dynamic linker to fills up GOT entries using specially sorted
dynamic symbol table. This affects even dynamic relocations against
symbols which do not require GOT entries creation explicitly, i.e. do
not have any GOT-relocations. So if a preemptible symbol has a dynamic
relocation we anyway have to create a GOT entry for it.
If a non-preemptible symbol has a dynamic relocation against it, dynamic
linker takes it st_value, adds offset and writes down result of the
dynamic relocation. In case of preemptible symbol dynamic linker
performs symbol resolution, writes the symbol value to the GOT entry and
reads the GOT entry when it needs to perform a dynamic relocation.
Differential Revision: http://reviews.llvm.org/D18948
llvm-svn: 266921
Diffstat (limited to 'lld/ELF')
| -rw-r--r-- | lld/ELF/Writer.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 8fb71c53d6d..e0ed5264afe 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -608,6 +608,23 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) { // We don't know anything about the finaly symbol. Just ask the dynamic // linker to handle the relocation for us. AddDyn({Target->getDynRel(Type), C.OutSec, Offset, false, &Body, Addend}); + // MIPS ABI turns using of GOT and dynamic relocations inside out. + // While regular ABI uses dynamic relocations to fill up GOT entries + // MIPS ABI requires dynamic linker to fills up GOT entries using + // specially sorted dynamic symbol table. This affects even dynamic + // relocations against symbols which do not require GOT entries + // creation explicitly, i.e. do not have any GOT-relocations. So if + // a preemptible symbol has a dynamic relocation we anyway have + // to create a GOT entry for it. + // If a non-preemptible symbol has a dynamic relocation against it, + // dynamic linker takes it st_value, adds offset and writes down + // result of the dynamic relocation. In case of preemptible symbol + // dynamic linker performs symbol resolution, writes the symbol value + // to the GOT entry and reads the GOT entry when it needs to perform + // a dynamic relocation. + // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf p.4-19 + if (Config->EMachine == EM_MIPS && !Body.isInGot()) + Out<ELFT>::Got->addEntry(Body); continue; } |

