forked from OSchip/llvm-project
parent
75baf09be5
commit
f7ae359d2c
|
@ -218,7 +218,7 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd,
|
||||||
SymVA = Body->getGotVA<ELFT>();
|
SymVA = Body->getGotVA<ELFT>();
|
||||||
if (Body->IsTls)
|
if (Body->IsTls)
|
||||||
Type = Target->getTlsGotRel(Type);
|
Type = Target->getTlsGotRel(Type);
|
||||||
} else if (!Target->needsCopyRel(Type, *Body) &&
|
} else if (!Target->needsCopyRel<ELFT>(Type, *Body) &&
|
||||||
isa<SharedSymbol<ELFT>>(*Body)) {
|
isa<SharedSymbol<ELFT>>(*Body)) {
|
||||||
continue;
|
continue;
|
||||||
} else if (Target->isTlsDynRel(Type, *Body)) {
|
} else if (Target->isTlsDynRel(Type, *Body)) {
|
||||||
|
|
|
@ -275,25 +275,9 @@ template <typename ELFT> static bool mayNeedCopy(const SymbolBody &S) {
|
||||||
return SS->Sym.getType() == STT_OBJECT;
|
return SS->Sym.getType() == STT_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class ELFT>
|
||||||
bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const {
|
bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const {
|
||||||
bool MayNeed;
|
return mayNeedCopy<ELFT>(S) && needsCopyRelImpl(Type);
|
||||||
switch (Config->EKind) {
|
|
||||||
case ELF32LEKind:
|
|
||||||
MayNeed = mayNeedCopy<ELF32LE>(S);
|
|
||||||
break;
|
|
||||||
case ELF64LEKind:
|
|
||||||
MayNeed = mayNeedCopy<ELF64LE>(S);
|
|
||||||
break;
|
|
||||||
case ELF32BEKind:
|
|
||||||
MayNeed = mayNeedCopy<ELF32BE>(S);
|
|
||||||
break;
|
|
||||||
case ELF64BEKind:
|
|
||||||
MayNeed = mayNeedCopy<ELF64BE>(S);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Invalid ELF kind");
|
|
||||||
}
|
|
||||||
return MayNeed && needsCopyRelImpl(Type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
|
bool TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
|
||||||
|
@ -725,7 +709,7 @@ bool X86_64TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
|
||||||
|
|
||||||
TargetInfo::PltNeed X86_64TargetInfo::needsPlt(uint32_t Type,
|
TargetInfo::PltNeed X86_64TargetInfo::needsPlt(uint32_t Type,
|
||||||
const SymbolBody &S) const {
|
const SymbolBody &S) const {
|
||||||
if (needsCopyRel(Type, S))
|
if (needsCopyRel<ELF64LE>(Type, S))
|
||||||
return Plt_No;
|
return Plt_No;
|
||||||
if (isGnuIFunc<ELF64LE>(S))
|
if (isGnuIFunc<ELF64LE>(S))
|
||||||
return Plt_Explicit;
|
return Plt_Explicit;
|
||||||
|
@ -1714,7 +1698,7 @@ bool MipsTargetInfo<ELFT>::needsGot(uint32_t Type, SymbolBody &S) const {
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
TargetInfo::PltNeed MipsTargetInfo<ELFT>::needsPlt(uint32_t Type,
|
TargetInfo::PltNeed MipsTargetInfo<ELFT>::needsPlt(uint32_t Type,
|
||||||
const SymbolBody &S) const {
|
const SymbolBody &S) const {
|
||||||
if (needsCopyRel(Type, S))
|
if (needsCopyRel<ELFT>(Type, S))
|
||||||
return Plt_No;
|
return Plt_No;
|
||||||
if (Type == R_MIPS_26 && canBePreempted(&S, false))
|
if (Type == R_MIPS_26 && canBePreempted(&S, false))
|
||||||
return Plt_Explicit;
|
return Plt_Explicit;
|
||||||
|
@ -1859,5 +1843,14 @@ template uint32_t getMipsGpAddr<ELF32LE>();
|
||||||
template uint32_t getMipsGpAddr<ELF32BE>();
|
template uint32_t getMipsGpAddr<ELF32BE>();
|
||||||
template uint64_t getMipsGpAddr<ELF64LE>();
|
template uint64_t getMipsGpAddr<ELF64LE>();
|
||||||
template uint64_t getMipsGpAddr<ELF64BE>();
|
template uint64_t getMipsGpAddr<ELF64BE>();
|
||||||
|
|
||||||
|
template bool TargetInfo::needsCopyRel<ELF32LE>(uint32_t,
|
||||||
|
const SymbolBody &) const;
|
||||||
|
template bool TargetInfo::needsCopyRel<ELF32BE>(uint32_t,
|
||||||
|
const SymbolBody &) const;
|
||||||
|
template bool TargetInfo::needsCopyRel<ELF64LE>(uint32_t,
|
||||||
|
const SymbolBody &) const;
|
||||||
|
template bool TargetInfo::needsCopyRel<ELF64BE>(uint32_t,
|
||||||
|
const SymbolBody &) const;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
uint8_t *PairedLoc = nullptr) const = 0;
|
uint8_t *PairedLoc = nullptr) const = 0;
|
||||||
virtual bool isGotRelative(uint32_t Type) const;
|
virtual bool isGotRelative(uint32_t Type) const;
|
||||||
virtual bool canRelaxTls(unsigned Type, const SymbolBody *S) const;
|
virtual bool canRelaxTls(unsigned Type, const SymbolBody *S) const;
|
||||||
|
template <class ELFT>
|
||||||
bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
|
bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
|
||||||
virtual unsigned relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
|
virtual unsigned relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
|
||||||
uint64_t P, uint64_t SA, const SymbolBody *S) const;
|
uint64_t P, uint64_t SA, const SymbolBody *S) const;
|
||||||
|
|
|
@ -335,7 +335,7 @@ void Writer<ELFT>::scanRelocs(
|
||||||
if (auto *B = dyn_cast_or_null<SharedSymbol<ELFT>>(Body)) {
|
if (auto *B = dyn_cast_or_null<SharedSymbol<ELFT>>(Body)) {
|
||||||
if (B->needsCopy())
|
if (B->needsCopy())
|
||||||
continue;
|
continue;
|
||||||
if (Target->needsCopyRel(Type, *B)) {
|
if (Target->needsCopyRel<ELFT>(Type, *B)) {
|
||||||
B->NeedsCopyOrPltAddr = true;
|
B->NeedsCopyOrPltAddr = true;
|
||||||
Out<ELFT>::RelaDyn->addReloc(
|
Out<ELFT>::RelaDyn->addReloc(
|
||||||
{Target->CopyRel, DynamicReloc<ELFT>::Off_Bss, B});
|
{Target->CopyRel, DynamicReloc<ELFT>::Off_Bss, B});
|
||||||
|
|
Loading…
Reference in New Issue