diff options
Diffstat (limited to 'lld/ELF/Writer.cpp')
| -rw-r--r-- | lld/ELF/Writer.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index b46b0786d3ea..483c069bb9db 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -454,8 +454,8 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) { // pointer into GOT. __gnu_local_gp is equal to the current value of // the 'gp'. Therefore any relocations against them do not require // dynamic relocation. - if (Config->EMachine == EM_MIPS && - (&Body == Config->MipsGpDisp || &Body == Config->MipsLocalGp)) + if (Config->EMachine == EM_MIPS && (&Body == ElfSym<ELFT>::MipsGpDisp || + &Body == ElfSym<ELFT>::MipsLocalGp)) continue; if (Preemptible) { @@ -930,12 +930,12 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() { if (Config->EMachine == EM_MIPS) { // On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between // start of function and 'gp' pointer into GOT. - Config->MipsGpDisp = Symtab.addIgnored("_gp_disp"); + ElfSym<ELFT>::MipsGpDisp = Symtab.addIgnored("_gp_disp"); // The __gnu_local_gp is a magic symbol equal to the current value of 'gp' // pointer. This symbol is used in the code generated by .cpload pseudo-op // in case of using -mno-shared option. // https://sourceware.org/ml/binutils/2004-12/msg00094.html - Config->MipsLocalGp = Symtab.addIgnored("__gnu_local_gp"); + ElfSym<ELFT>::MipsLocalGp = Symtab.addIgnored("__gnu_local_gp"); } // In the assembly for 32 bit x86 the _GLOBAL_OFFSET_TABLE_ symbol @@ -1510,8 +1510,14 @@ static uint16_t getELFType() { // symbol values that depend on section address and size. template <class ELFT> void Writer<ELFT>::fixAbsoluteSymbols() { // Update MIPS _gp absolute symbol so that it points to the static data. - if (Config->EMachine == EM_MIPS) + + if (Config->EMachine == EM_MIPS) { ElfSym<ELFT>::MipsGp->Value = getMipsGpAddr<ELFT>(); + if (ElfSym<ELFT>::MipsLocalGp) + ElfSym<ELFT>::MipsLocalGp->Value = getMipsGpAddr<ELFT>(); + if (ElfSym<ELFT>::MipsGpDisp) + ElfSym<ELFT>::MipsGpDisp->Value = getMipsGpAddr<ELFT>(); + } // _etext is the first location after the last read-only loadable segment. // _edata is the first location after the last read-write loadable segment. |
