[ELF][MIPS] Handle R_MIPS_HI16/LO16 relocations against _gp_disp symbol
The `_gp_disp` is a magic symbol designates offset between start of
function and gp pointer into GOT. Only `R_MIPS_HI16` and `R_MIPS_LO16`
relocations are permitted with `_gp_disp`. The patch adds the `_gp_disp`
as an ignored symbol and adjusts symbol value before call the `relocateOne`
for `R_MIPS_HI16/LO16` relocations.
Differential Revision: http://reviews.llvm.org/D15480
llvm-svn: 255768
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f1e1abe..048ff10 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -263,6 +263,11 @@
Symtab.addIgnoredSym("_GLOBAL_OFFSET_TABLE_");
}
+ // On MIPS O32 ABI _gp_disp is a magic symbol designates offset between
+ // start of function and gp pointer into GOT.
+ if (Config->EMachine == EM_MIPS)
+ Config->MipsGpDisp = Symtab.addIgnoredSym("_gp_disp");
+
if (!Config->Entry.empty()) {
// Set either EntryAddr (if S is a number) or EntrySym (otherwise).
StringRef S = Config->Entry;