mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 10:58:11 +08:00
Simplify. NFCI.
llvm-svn: 315659
This commit is contained in:
@@ -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, bool Preemptible) {
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user