[lld] r260508 - [ELF] - Remove R_X86_64_GOTTPOFF from static relocation processing
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 03:14:46 PST 2016
Author: grimar
Date: Thu Feb 11 05:14:46 2016
New Revision: 260508
URL: http://llvm.org/viewvc/llvm-project?rev=260508&view=rev
Log:
[ELF] - Remove R_X86_64_GOTTPOFF from static relocation processing
R_X86_64_TPOFF64 is a dynamic relocation,
it should not appear in static relocation processing.
Patch fixes it.
Differential revision: http://reviews.llvm.org/D16880
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=260508&r1=260507&r2=260508&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Feb 11 05:14:46 2016
@@ -114,6 +114,7 @@ private:
class X86_64TargetInfo final : public TargetInfo {
public:
X86_64TargetInfo();
+ unsigned getTlsGotRel(unsigned Type) const override;
bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
void writeGotPltHeader(uint8_t *Buf) const override;
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
@@ -173,7 +174,7 @@ public:
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
- unsigned getTlsGotRel(unsigned Type = -1) const override;
+ unsigned getTlsGotRel(unsigned Type) const override;
bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
bool needsCopyRel(uint32_t Type, const SymbolBody &S) const override;
bool needsGot(uint32_t Type, SymbolBody &S) const override;
@@ -654,6 +655,13 @@ bool X86_64TargetInfo::needsGot(uint32_t
return Type == R_X86_64_GOTPCREL || needsPlt(Type, S);
}
+unsigned X86_64TargetInfo::getTlsGotRel(unsigned Type) const {
+ // No other types of TLS relocations requiring GOT should
+ // reach here.
+ assert(Type == R_X86_64_GOTTPOFF);
+ return R_X86_64_PC32;
+}
+
bool X86_64TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
return Type == R_X86_64_GOTTPOFF || Type == R_X86_64_TLSGD;
}
@@ -789,7 +797,7 @@ void X86_64TargetInfo::relocateTlsGdToIe
0x48, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00 // addq x at tpoff,%rax
};
memcpy(Loc - 4, Inst, sizeof(Inst));
- relocateOne(Loc + 8, BufEnd, R_X86_64_TPOFF64, P + 12, SA);
+ relocateOne(Loc + 8, BufEnd, R_X86_64_PC32, P + 12, SA);
}
// In some conditions, R_X86_64_GOTTPOFF relocation can be optimized to
@@ -896,9 +904,6 @@ void X86_64TargetInfo::relocateOne(uint8
write32le(Loc, Val);
break;
}
- case R_X86_64_TPOFF64:
- write32le(Loc, SA - P);
- break;
default:
fatal("unrecognized reloc " + Twine(Type));
}
@@ -1209,10 +1214,9 @@ void AArch64TargetInfo::writePlt(uint8_t
}
unsigned AArch64TargetInfo::getTlsGotRel(unsigned Type) const {
- if (Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
- Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC)
+ assert(Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
+ Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC);
return Type;
- return TlsGotRel;
}
bool AArch64TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=260508&r1=260507&r2=260508&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Feb 11 05:14:46 2016
@@ -26,7 +26,7 @@ public:
bool isTlsGlobalDynamicRel(unsigned Type) const;
virtual unsigned getDynRel(unsigned Type) const { return Type; }
virtual bool isTlsDynRel(unsigned Type, const SymbolBody &S) const;
- virtual unsigned getTlsGotRel(unsigned Type = -1) const { return TlsGotRel; }
+ virtual unsigned getTlsGotRel(unsigned Type) const { return TlsGotRel; }
virtual void writeGotHeader(uint8_t *Buf) const {}
virtual void writeGotPltHeader(uint8_t *Buf) const {}
virtual void writeGotPlt(uint8_t *Buf, uint64_t Plt) const {};
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=260508&r1=260507&r2=260508&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Feb 11 05:14:46 2016
@@ -403,7 +403,7 @@ void Writer<ELFT>::scanRelocs(
if (CBP || Dynrel) {
uint32_t DynType;
if (CBP)
- DynType = Body->isTls() ? Target->getTlsGotRel() : Target->GotRel;
+ DynType = Body->isTls() ? Target->TlsGotRel : Target->GotRel;
else
DynType = Target->RelativeRel;
Out<ELFT>::RelaDyn->addReloc(
More information about the llvm-commits
mailing list