summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-04-27 11:54:07 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-04-27 11:54:07 +0000
commit365e5f69c9bdb9bd49c4f269f81344f676e0d830 (patch)
tree65c6fafb63cf986d5b17a4c8bab9cc70b8b1c7f5 /lld/ELF/Writer.cpp
parent493db093be5212c345bf16599a1012cb17a07c93 (diff)
downloadbcm5719-llvm-365e5f69c9bdb9bd49c4f269f81344f676e0d830.tar.gz
bcm5719-llvm-365e5f69c9bdb9bd49c4f269f81344f676e0d830.zip
Simplify handling of R_PPC64_TOC. NFC.
llvm-svn: 267698
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 8967f2c202d..553057f0ece 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -424,8 +424,12 @@ static int32_t findMipsPairedAddend(const uint8_t *Buf, const uint8_t *BufLoc,
// 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(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
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(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
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.
OpenPOWER on IntegriCloud