[lld] r267698 - Simplify handling of R_PPC64_TOC. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 04:54:07 PDT 2016
Author: rafael
Date: Wed Apr 27 06:54:07 2016
New Revision: 267698
URL: http://llvm.org/viewvc/llvm-project?rev=267698&view=rev
Log:
Simplify handling of R_PPC64_TOC. NFC.
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=267698&r1=267697&r2=267698&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Wed Apr 27 06:54:07 2016
@@ -843,6 +843,8 @@ RelExpr PPC64TargetInfo::getRelExpr(uint
switch (Type) {
default:
return R_ABS;
+ case R_PPC64_TOC:
+ return R_PPC_TOC;
case R_PPC64_REL24:
return R_PPC_PLT_OPD;
}
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=267698&r1=267697&r2=267698&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Apr 27 06:54:07 2016
@@ -424,8 +424,12 @@ static int32_t findMipsPairedAddend(cons
// the DSO is loaded.
template <class ELFT> static bool isAbsolute(const SymbolBody &Body) {
Symbol *Sym = Body.Backref;
- if (Body.isUndefined() && Sym->isWeak())
- return true; // always 0
+ if (Body.isUndefined()) {
+ if (!Sym)
+ return false; // undefined local. That is the dummy symbol 0.
+ if (Sym->isWeak())
+ return true; // always 0
+ }
if (const auto *DR = dyn_cast<DefinedRegular<ELFT>>(&Body))
return DR->Section == nullptr; // Absolute symbol.
return false;
@@ -687,13 +691,6 @@ void Writer<ELFT>::scanRelocs(InputSecti
continue;
}
- if (Config->EMachine == EM_PPC64 && RI.getType(false) == R_PPC64_TOC) {
- C.Relocations.push_back({R_PPC_TOC, Type, Offset, Addend, &Body});
- AddDyn({R_PPC64_RELATIVE, C.OutSec, Offset, false, nullptr,
- (uintX_t)getPPC64TocBase() + Addend});
- continue;
- }
-
// We know that this is the final symbol. If the program being produced
// is position independent, the final value is still not known.
// If the relocation depends on the symbol value (not the size or distances
@@ -710,8 +707,10 @@ void Writer<ELFT>::scanRelocs(InputSecti
continue;
}
+ if (Config->EMachine == EM_PPC64 && Type == R_PPC64_TOC)
+ Addend += getPPC64TocBase();
AddDyn({Target->RelativeRel, C.OutSec, Offset, true, &Body, Addend});
- C.Relocations.push_back({R_ABS, Type, Offset, Addend, &Body});
+ C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});
}
// Scan relocations for necessary thunks.
More information about the llvm-commits
mailing list