Create a SymbolBody for locals.
pr26878 shows a case where locals have to be in the got.
llvm-svn: 263222
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index e61a072..ffe980a 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -99,7 +99,7 @@
uint64_t SA, uint64_t ZA = 0,
uint8_t *PairedLoc = nullptr) const override;
size_t relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
- uint64_t SA, const SymbolBody *S) const override;
+ uint64_t SA, const SymbolBody &S) const override;
bool isGotRelative(uint32_t Type) const override;
bool refersToGotEntry(uint32_t Type) const override;
@@ -137,7 +137,7 @@
bool isRelRelative(uint32_t Type) const override;
bool isSizeRel(uint32_t Type) const override;
size_t relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
- uint64_t SA, const SymbolBody *S) const override;
+ uint64_t SA, const SymbolBody &S) const override;
private:
void relocateTlsLdToLe(uint8_t *Loc, uint8_t *BufEnd, uint64_t P,
@@ -191,7 +191,7 @@
uint64_t SA, uint64_t ZA = 0,
uint8_t *PairedLoc = nullptr) const override;
size_t relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
- uint64_t SA, const SymbolBody *S) const override;
+ uint64_t SA, const SymbolBody &S) const override;
private:
void relocateTlsGdToLe(uint32_t Type, uint8_t *Loc, uint8_t *BufEnd,
@@ -278,7 +278,7 @@
// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
// defined.
if (isTlsInitialExecRel(Type))
- return !canBePreempted(S);
+ return !canBePreempted(*S);
return false;
}
@@ -317,7 +317,7 @@
const SymbolBody &S) const {
if (isGnuIFunc<ELFT>(S))
return Plt_Explicit;
- if (canBePreempted(&S) && needsPltImpl(Type))
+ if (canBePreempted(S) && needsPltImpl(Type))
return Plt_Explicit;
// This handles a non PIC program call to function in a shared library.
@@ -363,7 +363,7 @@
size_t TargetInfo::relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
uint64_t P, uint64_t SA,
- const SymbolBody *S) const {
+ const SymbolBody &S) const {
return 0;
}
@@ -470,7 +470,7 @@
bool X86TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
if (S.IsTls && Type == R_386_TLS_GD)
- return Target->canRelaxTls(Type, &S) && canBePreempted(&S);
+ return Target->canRelaxTls(Type, &S) && canBePreempted(S);
if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
return !canRelaxTls(Type, &S);
return Type == R_386_GOT32 || needsPlt<ELF32LE>(Type, S);
@@ -545,7 +545,7 @@
size_t X86TargetInfo::relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
uint64_t P, uint64_t SA,
- const SymbolBody *S) const {
+ const SymbolBody &S) const {
switch (Type) {
case R_386_TLS_GD:
if (canBePreempted(S))
@@ -732,7 +732,7 @@
bool X86_64TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
if (Type == R_X86_64_TLSGD)
- return Target->canRelaxTls(Type, &S) && canBePreempted(&S);
+ return Target->canRelaxTls(Type, &S) && canBePreempted(S);
if (Type == R_X86_64_GOTTPOFF)
return !canRelaxTls(Type, &S);
return refersToGotEntry(Type) || needsPlt<ELF64LE>(Type, S);
@@ -890,7 +890,7 @@
// This function returns a number of relocations that need to be skipped.
size_t X86_64TargetInfo::relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
uint64_t P, uint64_t SA,
- const SymbolBody *S) const {
+ const SymbolBody &S) const {
switch (Type) {
case R_X86_64_DTPOFF32:
relocateOne(Loc, BufEnd, R_X86_64_TPOFF32, P, SA);
@@ -1463,7 +1463,7 @@
size_t AArch64TargetInfo::relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
uint64_t P, uint64_t SA,
- const SymbolBody *S) const {
+ const SymbolBody &S) const {
switch (Type) {
case R_AARCH64_TLSDESC_ADR_PAGE21:
case R_AARCH64_TLSDESC_LD64_LO12_NC:
@@ -1471,13 +1471,13 @@
case R_AARCH64_TLSDESC_CALL: {
if (canBePreempted(S))
fatal("Unsupported TLS optimization");
- uint64_t X = S ? S->getVA<ELF64LE>() : SA;
+ uint64_t X = S.getVA<ELF64LE>();
relocateTlsGdToLe(Type, Loc, BufEnd, P, X);
return 0;
}
case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
- relocateTlsIeToLe(Type, Loc, BufEnd, P, S->getVA<ELF64LE>());
+ relocateTlsIeToLe(Type, Loc, BufEnd, P, S.getVA<ELF64LE>());
return 0;
}
llvm_unreachable("Unknown TLS optimization");