// handling in to the separate function we can simplify the code and do not
// pollute `handleTlsRelocation` by ARM and MIPS `ifs` statements.
template <class ELFT, class GOT>
-static unsigned
-handleNoRelaxTlsRelocation(GOT *Got, uint32_t Type, SymbolBody &Body,
- InputSectionBase &C, typename ELFT::uint Offset,
- int64_t Addend, RelExpr Expr) {
+static unsigned handleNoRelaxTlsRelocation(GOT *Got, uint32_t Type,
+ SymbolBody &Body,
+ InputSectionBase &C, uint64_t Offset,
+ int64_t Addend, RelExpr Expr) {
auto addModuleReloc = [&](uint64_t Off, bool LD) {
// The Dynamic TLS Module Index Relocation can be statically resolved to 1
// if we know that we are linking an executable. For ARM we resolve the
static unsigned
handleTlsRelocation(uint32_t Type, SymbolBody &Body, InputSectionBase &C,
typename ELFT::uint Offset, int64_t Addend, RelExpr Expr) {
- typedef typename ELFT::uint uintX_t;
-
if (!(C.Flags & SHF_ALLOC))
return 0;
if (isRelExprOneOf<R_TLSDESC, R_TLSDESC_PAGE, R_TLSDESC_CALL>(Expr) &&
Config->Shared) {
if (In<ELFT>::Got->addDynTlsEntry(Body)) {
- uintX_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);
+ uint64_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);
In<ELFT>::RelaDyn->addReloc({Target->TlsDescRel, In<ELFT>::Got, Off,
!IsPreemptible, &Body, 0});
}
Target->isTlsGlobalDynamicRel(Type)) {
if (Config->Shared) {
if (In<ELFT>::Got->addDynTlsEntry(Body)) {
- uintX_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);
+ uint64_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);
In<ELFT>::RelaDyn->addReloc(
{Target->TlsModuleIndexRel, In<ELFT>::Got, Off, false, &Body, 0});
// If the symbol is preemptible we need the dynamic linker to write
// the offset too.
- uintX_t OffsetOff = Off + (uintX_t)sizeof(uintX_t);
+ uint64_t OffsetOff = Off + Config->Wordsize;
if (IsPreemptible)
In<ELFT>::RelaDyn->addReloc({Target->TlsOffsetRel, In<ELFT>::Got,
OffsetOff, false, &Body, 0});
return 0;
}
-template <endianness E> static int16_t readSignedLo16(const uint8_t *Loc) {
- return read32<E>(Loc) & 0xffff;
+static int16_t readSignedLo16(const uint8_t *Loc) {
+ return read32(Loc, Config->Endianness) & 0xffff;
}
template <class RelTy>
}
}
-template <class ELFT, class RelTy>
+template <class RelTy>
static int32_t findMipsPairedAddend(const uint8_t *Buf, const uint8_t *BufLoc,
SymbolBody &Sym, const RelTy *Rel,
const RelTy *End) {
continue;
if (RI->getSymbol(Config->IsMips64EL) != SymIndex)
continue;
- const endianness E = ELFT::TargetEndianness;
- return ((read32<E>(BufLoc) & 0xffff) << 16) +
- readSignedLo16<E>(Buf + RI->r_offset);
+ return ((read32(BufLoc, Config->Endianness) & 0xffff) << 16) +
+ readSignedLo16(Buf + RI->r_offset);
}
+
warn("can't find matching " + toString(Type) + " relocation for " +
toString(Rel->getType(Config->IsMips64EL)));
return 0;
// True if non-preemptable symbol always has the same value regardless of where
// the DSO is loaded.
-template <class ELFT> static bool isAbsolute(const SymbolBody &Body) {
+static bool isAbsolute(const SymbolBody &Body) {
if (Body.isUndefined())
return !Body.isLocal() && Body.symbol()->isWeak();
if (const auto *DR = dyn_cast<DefinedRegular>(&Body))
return false;
}
-template <class ELFT> static bool isAbsoluteValue(const SymbolBody &Body) {
- return isAbsolute<ELFT>(Body) || Body.isTls();
+static bool isAbsoluteValue(const SymbolBody &Body) {
+ return isAbsolute(Body) || Body.isTls();
}
static bool needsPlt(RelExpr Expr) {
// If this function returns false, that means we need to emit a
// dynamic relocation so that the relocation will be fixed at load-time.
template <class ELFT>
-static bool
-isStaticLinkTimeConstant(RelExpr E, uint32_t Type, const SymbolBody &Body,
- InputSectionBase &S, typename ELFT::uint RelOff) {
+static bool isStaticLinkTimeConstant(RelExpr E, uint32_t Type,
+ const SymbolBody &Body,
+ InputSectionBase &S, uint64_t RelOff) {
// These expressions always compute a constant
if (isRelExprOneOf<R_SIZE, R_GOT_FROM_END, R_GOT_OFF, R_MIPS_GOT_LOCAL_PAGE,
R_MIPS_GOT_OFF, R_MIPS_GOT_OFF32, R_MIPS_GOT_GP_PC,
// For the target and the relocation, we want to know if they are
// absolute or relative.
- bool AbsVal = isAbsoluteValue<ELFT>(Body);
+ bool AbsVal = isAbsoluteValue(Body);
bool RelE = isRelExpr(E);
if (AbsVal && !RelE)
return true;
} else if (!Preemptible) {
if (needsPlt(Expr))
Expr = fromPlt(Expr);
- if (Expr == R_GOT_PC && !isAbsoluteValue<ELFT>(Body))
+ if (Expr == R_GOT_PC && !isAbsoluteValue(Body))
Expr = Target->adjustRelaxExpr(Type, Data, Expr);
}
uint32_t Type = Rel.getType(Config->IsMips64EL);
int64_t Addend = getAddend<ELFT>(Rel);
const uint8_t *BufLoc = SectionData + Rel.r_offset;
+
if (!RelTy::IsRela)
Addend += Target->getImplicitAddend(BufLoc, Type);
+
if (Config->EMachine == EM_MIPS) {
- Addend += findMipsPairedAddend<ELFT>(SectionData, BufLoc, Body, &Rel, End);
+ Addend += findMipsPairedAddend(SectionData, BufLoc, Body, &Rel, End);
if (Expr == R_MIPS_GOTREL && Body.isLocal())
Addend += File.MipsGp0;
}
+
if (Config->Pic && Config->EMachine == EM_PPC64 && Type == R_PPC64_TOC)
Addend += getPPC64TocBase();
return Addend;
template <class ELFT>
static void reportUndefined(SymbolBody &Sym, InputSectionBase &S,
- typename ELFT::uint Offset) {
+ uint64_t Offset) {
if (Config->UnresolvedSymbols == UnresolvedPolicy::IgnoreAll)
return;
// space for the extra PT_LOAD even if we end up not using it.
template <class ELFT, class RelTy>
static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) {
- typedef typename ELFT::uint uintX_t;
-
OffsetGetter GetOffset(Sec);
for (auto I = Rels.begin(), E = Rels.end(); I != E; ++I) {
}
// Compute the offset of this section in the output section.
- uintX_t Offset = GetOffset.get(Rel.r_offset);
- if (Offset == uintX_t(-1))
+ uint64_t Offset = GetOffset.get(Rel.r_offset);
+ if (Offset == uint64_t(-1))
continue;
// Report undefined symbols. The fact that we report undefined
continue;
In<ELFT>::Got->addEntry(Body);
- uintX_t Off = Body.getGotOffset();
+ uint64_t Off = Body.getGotOffset();
uint32_t DynType;
RelExpr GotRE = R_ABS;
if (Body.isTls()) {
DynType = Target->TlsGotRel;
GotRE = R_TLS;
- } else if (!Preemptible && Config->Pic && !isAbsolute<ELFT>(Body))
+ } else if (!Preemptible && Config->Pic && !isAbsolute(Body))
DynType = Target->RelativeRel;
else
DynType = Target->GotRel;
// FIXME: this logic is almost duplicated above.
- bool Constant = !Preemptible && !(Config->Pic && !isAbsolute<ELFT>(Body));
+ bool Constant = !Preemptible && !(Config->Pic && !isAbsolute(Body));
if (!Constant)
In<ELFT>::RelaDyn->addReloc(
{DynType, In<ELFT>::Got, Off, !Preemptible, &Body, 0});