[lld] r315659 - Simplify. NFCI.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 18:42:27 PDT 2017
Author: ruiu
Date: Thu Oct 12 18:42:27 2017
New Revision: 315659
URL: http://llvm.org/viewvc/llvm-project?rev=315659&view=rev
Log:
Simplify. NFCI.
Modified:
lld/trunk/ELF/Relocations.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=315659&r1=315658&r2=315659&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Thu Oct 12 18:42:27 2017
@@ -802,18 +802,8 @@ template <class ELFT>
static void addGotEntry(SymbolBody &Sym, bool Preemptible) {
InX::Got->addEntry(Sym);
+ RelExpr Expr = Sym.isTls() ? R_TLS : R_ABS;
uint64_t Off = Sym.getGotOffset();
- RelExpr Expr = R_ABS;
- RelType DynType;
-
- if (Sym.isTls()) {
- DynType = Target->TlsGotRel;
- Expr = R_TLS;
- } else if (!Preemptible && Config->Pic && !isAbsolute(Sym)) {
- DynType = Target->RelativeRel;
- } else {
- DynType = Target->GotRel;
- }
// If a GOT slot value can be calculated at link-time, which is now,
// we can just fill that out.
@@ -824,22 +814,29 @@ static void addGotEntry(SymbolBody &Sym,
// to just write a value now, but it is a TODO.)
bool IsLinkTimeConstant = !Preemptible && (!Config->Pic || isAbsolute(Sym));
if (IsLinkTimeConstant) {
- InX::Got->Relocations.push_back({Expr, DynType, Off, 0, &Sym});
- } else {
- // Otherwise, we emit a dynamic relocation to .rel[a].dyn so that
- // the GOT slot will be fixed at load-time.
- In<ELFT>::RelaDyn->addReloc(
- {DynType, InX::Got, Off, !Preemptible, &Sym, 0});
-
- // REL type relocations don't have addend fields unlike RELAs, and
- // their addends are stored to the section to which they are applied.
- // So, store addends if we need to.
- //
- // This is ugly -- the difference between REL and RELA should be
- // handled in a better way. It's a TODO.
- if (!Config->IsRela)
- InX::Got->Relocations.push_back({R_ABS, Target->GotRel, Off, 0, &Sym});
+ InX::Got->Relocations.push_back({Expr, Target->GotRel, Off, 0, &Sym});
+ return;
}
+
+ // Otherwise, we emit a dynamic relocation to .rel[a].dyn so that
+ // the GOT slot will be fixed at load-time.
+ RelType Type;
+ if (Sym.isTls())
+ Type = Target->TlsGotRel;
+ else if (!Preemptible && Config->Pic && !isAbsolute(Sym))
+ Type = Target->RelativeRel;
+ else
+ Type = Target->GotRel;
+ In<ELFT>::RelaDyn->addReloc({Type, InX::Got, Off, !Preemptible, &Sym, 0});
+
+ // REL type relocations don't have addend fields unlike RELAs, and
+ // their addends are stored to the section to which they are applied.
+ // So, store addends if we need to.
+ //
+ // This is ugly -- the difference between REL and RELA should be
+ // handled in a better way. It's a TODO.
+ if (!Config->IsRela)
+ InX::Got->Relocations.push_back({R_ABS, Target->GotRel, Off, 0, &Sym});
}
// The reason we have to do this early scan is as follows
More information about the llvm-commits
mailing list