From abc9a1292916cf52fede195664f962c4107c0c40 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 30 Mar 2016 12:45:58 +0000 Subject: [PATCH] Simplify mips addend processing. It is now added to the addend in the same way as a regular Elf_Rel addend. llvm-svn: 264864 --- lld/ELF/InputSection.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 119367a..4929e03 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -202,14 +202,12 @@ static uintX_t adjustMipsSymVA(uint32_t Type, const elf::ObjectFile &File, template static uintX_t getMipsGotVA(const SymbolBody &Body, uintX_t SymVA, - uint8_t *BufLoc, uint64_t AHL) { + uint8_t *BufLoc) { if (Body.isLocal()) // If relocation against MIPS local symbol requires GOT entry, this entry // should be initialized by 'page address'. This address is high 16-bits - // of sum the symbol's value and the addend. The addend in that case is - // calculated using addends from R_MIPS_GOT16 and paired R_MIPS_LO16 - // relocations. - return Out::Got->getMipsLocalPageAddr(SymVA + AHL); + // of sum the symbol's value and the addend. + return Out::Got->getMipsLocalPageAddr(SymVA); if (!Body.isPreemptible()) // For non-local symbols GOT entries should contain their full // addresses. But if such symbol cannot be preempted, we do not @@ -276,15 +274,15 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, if (!RelTy::IsRela) A += Target->getImplicitAddend(BufLoc, Type); - uintX_t SymVA = Body.getVA(A); if (Config->EMachine == EM_MIPS) A += findMipsPairedAddend(Buf, BufLoc, Body, &RI, Rels.end()); + uintX_t SymVA = Body.getVA(A); if (Target->needsPlt(Type, Body)) { SymVA = Body.getPltVA() + A; } else if (Target->needsGot(Type, Body)) { if (Config->EMachine == EM_MIPS) - SymVA = getMipsGotVA(Body, SymVA, BufLoc, A); + SymVA = getMipsGotVA(Body, SymVA, BufLoc); else SymVA = Body.getGotVA() + A; if (Body.IsTls) @@ -296,7 +294,7 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, // with a possibly incorrect value. continue; } else if (Config->EMachine == EM_MIPS) { - SymVA = adjustMipsSymVA(Type, *File, Body, AddrLoc, SymVA) + A; + SymVA = adjustMipsSymVA(Type, *File, Body, AddrLoc, SymVA); } else if (!Target->needsCopyRel(Type, Body) && Body.isPreemptible()) { continue; -- 2.7.4