[lld] r262793 - [ELF] - Use the uint32_t instead of unsigned in Target class for relocations types
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 5 22:01:07 PST 2016
Author: grimar
Date: Sun Mar 6 00:01:07 2016
New Revision: 262793
URL: http://llvm.org/viewvc/llvm-project?rev=262793&view=rev
Log:
[ELF] - Use the uint32_t instead of unsigned in Target class for relocations types
Patch changes all relocations types to be uint32_t and also
fixes some dependent inconsistency in callers code.
Differential revision: http://reviews.llvm.org/D17882
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=262793&r1=262792&r2=262793&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Sun Mar 6 00:01:07 2016
@@ -81,19 +81,19 @@ class X86TargetInfo final : public Targe
public:
X86TargetInfo();
void writeGotPltHeader(uint8_t *Buf) const override;
- unsigned getDynRel(unsigned Type) const override;
- unsigned getTlsGotRel(unsigned Type) const override;
- bool pointsToLocalDynamicGotEntry(unsigned Type) const override;
- bool isTlsLocalDynamicRel(unsigned Type) const override;
- bool isTlsGlobalDynamicRel(unsigned Type) const override;
- bool isTlsInitialExecRel(unsigned Type) const override;
- bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
+ uint32_t getDynRel(uint32_t Type) const override;
+ uint32_t getTlsGotRel(uint32_t Type) const override;
+ bool pointsToLocalDynamicGotEntry(uint32_t Type) const override;
+ bool isTlsLocalDynamicRel(uint32_t Type) const override;
+ bool isTlsGlobalDynamicRel(uint32_t Type) const override;
+ bool isTlsInitialExecRel(uint32_t Type) const override;
+ bool isTlsDynRel(uint32_t Type, const SymbolBody &S) const override;
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
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;
bool needsCopyRelImpl(uint32_t Type) const override;
- bool needsDynRelative(unsigned Type) const override;
+ bool needsDynRelative(uint32_t Type) const override;
bool needsGot(uint32_t Type, SymbolBody &S) const override;
bool needsPltImpl(uint32_t Type) const override;
void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
@@ -111,19 +111,19 @@ private:
uint64_t SA) const;
void relocateTlsGdToLe(uint8_t *Loc, uint8_t *BufEnd, uint64_t P,
uint64_t SA) const;
- void relocateTlsIeToLe(unsigned Type, uint8_t *Loc, uint8_t *BufEnd,
+ void relocateTlsIeToLe(uint32_t Type, uint8_t *Loc, uint8_t *BufEnd,
uint64_t P, uint64_t SA) const;
};
class X86_64TargetInfo final : public TargetInfo {
public:
X86_64TargetInfo();
- unsigned getTlsGotRel(unsigned Type) const override;
- bool pointsToLocalDynamicGotEntry(unsigned Type) const override;
- bool isTlsLocalDynamicRel(unsigned Type) const override;
- bool isTlsGlobalDynamicRel(unsigned Type) const override;
- bool isTlsInitialExecRel(unsigned Type) const override;
- bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
+ uint32_t getTlsGotRel(uint32_t Type) const override;
+ bool pointsToLocalDynamicGotEntry(uint32_t Type) const override;
+ bool isTlsLocalDynamicRel(uint32_t Type) const override;
+ bool isTlsGlobalDynamicRel(uint32_t Type) const override;
+ bool isTlsInitialExecRel(uint32_t Type) const override;
+ bool isTlsDynRel(uint32_t Type, const SymbolBody &S) const override;
void writeGotPltHeader(uint8_t *Buf) const override;
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
void writePltZero(uint8_t *Buf) const override;
@@ -177,15 +177,15 @@ public:
class AArch64TargetInfo final : public TargetInfo {
public:
AArch64TargetInfo();
- unsigned getDynRel(unsigned Type) const override;
- bool isTlsGlobalDynamicRel(unsigned Type) const override;
- bool isTlsInitialExecRel(unsigned Type) const override;
+ uint32_t getDynRel(uint32_t Type) const override;
+ bool isTlsGlobalDynamicRel(uint32_t Type) const override;
+ bool isTlsInitialExecRel(uint32_t Type) const override;
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
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) const override;
- bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
+ uint32_t getTlsGotRel(uint32_t Type) const override;
+ bool isTlsDynRel(uint32_t Type, const SymbolBody &S) const override;
bool isRelRelative(uint32_t Type) const override;
bool needsCopyRelImpl(uint32_t Type) const override;
bool needsGot(uint32_t Type, SymbolBody &S) const override;
@@ -197,9 +197,9 @@ public:
uint64_t SA, const SymbolBody *S) const override;
private:
- void relocateTlsGdToLe(unsigned Type, uint8_t *Loc, uint8_t *BufEnd,
+ void relocateTlsGdToLe(uint32_t Type, uint8_t *Loc, uint8_t *BufEnd,
uint64_t P, uint64_t SA) const;
- void relocateTlsIeToLe(unsigned Type, uint8_t *Loc, uint8_t *BufEnd,
+ void relocateTlsIeToLe(uint32_t Type, uint8_t *Loc, uint8_t *BufEnd,
uint64_t P, uint64_t SA) const;
static const uint64_t TcbSize = 16;
@@ -216,7 +216,7 @@ public:
template <class ELFT> class MipsTargetInfo final : public TargetInfo {
public:
MipsTargetInfo();
- unsigned getDynRel(unsigned Type) const override;
+ uint32_t getDynRel(uint32_t Type) const override;
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
@@ -263,7 +263,7 @@ TargetInfo *createTarget() {
TargetInfo::~TargetInfo() {}
-bool TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const {
+bool TargetInfo::canRelaxTls(uint32_t Type, const SymbolBody *S) const {
if (Config->Shared || (S && !S->isTls()))
return false;
@@ -304,7 +304,7 @@ bool TargetInfo::needsCopyRel(uint32_t T
return mayNeedCopy<ELFT>(S) && needsCopyRelImpl(Type);
}
-bool TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
+bool TargetInfo::isTlsDynRel(uint32_t Type, const SymbolBody &S) const {
return false;
}
@@ -356,15 +356,15 @@ TargetInfo::PltNeed TargetInfo::needsPlt
return Plt_No;
}
-bool TargetInfo::isTlsInitialExecRel(unsigned Type) const { return false; }
+bool TargetInfo::isTlsInitialExecRel(uint32_t Type) const { return false; }
-bool TargetInfo::pointsToLocalDynamicGotEntry(unsigned Type) const {
+bool TargetInfo::pointsToLocalDynamicGotEntry(uint32_t Type) const {
return false;
}
-bool TargetInfo::isTlsLocalDynamicRel(unsigned Type) const { return false; }
+bool TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { return false; }
-bool TargetInfo::isTlsGlobalDynamicRel(unsigned Type) const {
+bool TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
return false;
}
@@ -398,7 +398,7 @@ void X86TargetInfo::writeGotPlt(uint8_t
write32le(Buf, Plt + 6);
}
-unsigned X86TargetInfo::getDynRel(unsigned Type) const {
+uint32_t X86TargetInfo::getDynRel(uint32_t Type) const {
if (Type == R_386_TLS_LE)
return R_386_TLS_TPOFF;
if (Type == R_386_TLS_LE_32)
@@ -406,29 +406,29 @@ unsigned X86TargetInfo::getDynRel(unsign
return Type;
}
-unsigned X86TargetInfo::getTlsGotRel(unsigned Type) const {
+uint32_t X86TargetInfo::getTlsGotRel(uint32_t Type) const {
if (Type == R_386_TLS_IE)
return Type;
return TlsGotRel;
}
-bool X86TargetInfo::isTlsGlobalDynamicRel(unsigned Type) const {
+bool X86TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
return Type == R_386_TLS_GD;
}
-bool X86TargetInfo::isTlsLocalDynamicRel(unsigned Type) const {
+bool X86TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const {
return Type == R_386_TLS_LDO_32 || Type == R_386_TLS_LDM;
}
-bool X86TargetInfo::pointsToLocalDynamicGotEntry(unsigned Type) const {
+bool X86TargetInfo::pointsToLocalDynamicGotEntry(uint32_t Type) const {
return Type == R_386_TLS_LDM;
}
-bool X86TargetInfo::isTlsInitialExecRel(unsigned Type) const {
+bool X86TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
return Type == R_386_TLS_IE || Type == R_386_TLS_GOTIE;
}
-bool X86TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
+bool X86TargetInfo::isTlsDynRel(uint32_t Type, const SymbolBody &S) const {
if (Type == R_386_TLS_LE || Type == R_386_TLS_LE_32 ||
Type == R_386_TLS_GOTIE)
return Config->Shared;
@@ -555,7 +555,7 @@ void X86TargetInfo::relocateOne(uint8_t
}
}
-bool X86TargetInfo::needsDynRelative(unsigned Type) const {
+bool X86TargetInfo::needsDynRelative(uint32_t Type) const {
return Config->Shared && Type == R_386_TLS_IE;
}
@@ -647,7 +647,7 @@ void X86TargetInfo::relocateTlsLdToLe(ui
// Read "ELF Handling For Thread-Local Storage, 5.1
// IA-32 Linker Optimizations" (http://www.akkadia.org/drepper/tls.pdf)
// by Ulrich Drepper for details.
-void X86TargetInfo::relocateTlsIeToLe(unsigned Type, uint8_t *Loc,
+void X86TargetInfo::relocateTlsIeToLe(uint32_t Type, uint8_t *Loc,
uint8_t *BufEnd, uint64_t P,
uint64_t SA) const {
// Ulrich's document section 6.2 says that @gotntpoff can
@@ -754,30 +754,30 @@ bool X86_64TargetInfo::needsGot(uint32_t
return refersToGotEntry(Type) || needsPlt<ELF64LE>(Type, S);
}
-unsigned X86_64TargetInfo::getTlsGotRel(unsigned Type) const {
+uint32_t X86_64TargetInfo::getTlsGotRel(uint32_t 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::isTlsInitialExecRel(unsigned Type) const {
+bool X86_64TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
return Type == R_X86_64_GOTTPOFF;
}
-bool X86_64TargetInfo::isTlsGlobalDynamicRel(unsigned Type) const {
+bool X86_64TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
return Type == R_X86_64_TLSGD;
}
-bool X86_64TargetInfo::pointsToLocalDynamicGotEntry(unsigned Type) const {
+bool X86_64TargetInfo::pointsToLocalDynamicGotEntry(uint32_t Type) const {
return Type == R_X86_64_TLSLD;
}
-bool X86_64TargetInfo::isTlsLocalDynamicRel(unsigned Type) const {
+bool X86_64TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const {
return Type == R_X86_64_DTPOFF32 || Type == R_X86_64_TLSLD;
}
-bool X86_64TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
+bool X86_64TargetInfo::isTlsDynRel(uint32_t Type, const SymbolBody &S) const {
return Type == R_X86_64_GOTTPOFF || Type == R_X86_64_TLSGD;
}
@@ -1236,19 +1236,19 @@ bool AArch64TargetInfo::isRelRelative(ui
Type == R_AARCH64_ADD_ABS_LO12_NC || Type == R_AARCH64_CALL26;
}
-bool AArch64TargetInfo::isTlsGlobalDynamicRel(unsigned Type) const {
+bool AArch64TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
return Type == R_AARCH64_TLSDESC_ADR_PAGE21 ||
Type == R_AARCH64_TLSDESC_LD64_LO12_NC ||
Type == R_AARCH64_TLSDESC_ADD_LO12_NC ||
Type == R_AARCH64_TLSDESC_CALL;
}
-bool AArch64TargetInfo::isTlsInitialExecRel(unsigned Type) const {
+bool AArch64TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
return Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
}
-unsigned AArch64TargetInfo::getDynRel(unsigned Type) const {
+uint32_t AArch64TargetInfo::getDynRel(uint32_t Type) const {
if (Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64)
return Type;
StringRef S = getELFRelocationTypeName(EM_AARCH64, Type);
@@ -1303,13 +1303,13 @@ void AArch64TargetInfo::writePlt(uint8_t
GotEntryAddr);
}
-unsigned AArch64TargetInfo::getTlsGotRel(unsigned Type) const {
+uint32_t AArch64TargetInfo::getTlsGotRel(uint32_t Type) const {
assert(Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC);
return Type;
}
-bool AArch64TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const {
+bool AArch64TargetInfo::isTlsDynRel(uint32_t Type, const SymbolBody &S) const {
return Type == R_AARCH64_TLSDESC_ADR_PAGE21 ||
Type == R_AARCH64_TLSDESC_LD64_LO12_NC ||
Type == R_AARCH64_TLSDESC_ADD_LO12_NC ||
@@ -1510,7 +1510,7 @@ unsigned AArch64TargetInfo::relaxTls(uin
// Global-Dynamic relocations can be relaxed to Local-Exec if both binary is
// an executable and target is final (can notbe preempted).
-void AArch64TargetInfo::relocateTlsGdToLe(unsigned Type, uint8_t *Loc,
+void AArch64TargetInfo::relocateTlsGdToLe(uint32_t Type, uint8_t *Loc,
uint8_t *BufEnd, uint64_t P,
uint64_t SA) const {
// TLSDESC Global-Dynamic relocation are in the form:
@@ -1551,7 +1551,7 @@ void AArch64TargetInfo::relocateTlsGdToL
// Initial-Exec relocations can be relaxed to Local-Exec if symbol is final
// (can not be preempted).
-void AArch64TargetInfo::relocateTlsIeToLe(unsigned Type, uint8_t *Loc,
+void AArch64TargetInfo::relocateTlsIeToLe(uint32_t Type, uint8_t *Loc,
uint8_t *BufEnd, uint64_t P,
uint64_t SA) const {
uint64_t TPOff = llvm::alignTo(TcbSize, Out<ELF64LE>::TlsPhdr->p_align);
@@ -1598,7 +1598,7 @@ template <class ELFT> MipsTargetInfo<ELF
}
template <class ELFT>
-unsigned MipsTargetInfo<ELFT>::getDynRel(unsigned Type) const {
+uint32_t MipsTargetInfo<ELFT>::getDynRel(uint32_t Type) const {
if (Type == R_MIPS_32 || Type == R_MIPS_64)
return R_MIPS_REL32;
StringRef S = getELFRelocationTypeName(EM_MIPS, Type);
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=262793&r1=262792&r2=262793&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Sun Mar 6 00:01:07 2016
@@ -22,13 +22,13 @@ class SymbolBody;
class TargetInfo {
public:
uint64_t getVAStart() const;
- virtual bool isTlsInitialExecRel(unsigned Type) const;
- virtual bool pointsToLocalDynamicGotEntry(unsigned Type) const;
- virtual bool isTlsLocalDynamicRel(unsigned Type) const;
- virtual 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) const { return TlsGotRel; }
+ virtual bool isTlsInitialExecRel(uint32_t Type) const;
+ virtual bool pointsToLocalDynamicGotEntry(uint32_t Type) const;
+ virtual bool isTlsLocalDynamicRel(uint32_t Type) const;
+ virtual bool isTlsGlobalDynamicRel(uint32_t Type) const;
+ virtual uint32_t getDynRel(uint32_t Type) const { return Type; }
+ virtual bool isTlsDynRel(uint32_t Type, const SymbolBody &S) const;
+ virtual uint32_t getTlsGotRel(uint32_t 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 {};
@@ -55,7 +55,7 @@ public:
virtual bool isRelRelative(uint32_t Type) const;
virtual bool isSizeRel(uint32_t Type) const;
- virtual bool needsDynRelative(unsigned Type) const { return false; }
+ virtual bool needsDynRelative(uint32_t Type) const { return false; }
virtual bool needsGot(uint32_t Type, SymbolBody &S) const;
virtual bool refersToGotEntry(uint32_t Type) const;
@@ -67,7 +67,7 @@ public:
uint64_t P, uint64_t SA, uint64_t ZA = 0,
uint8_t *PairedLoc = nullptr) const = 0;
virtual bool isGotRelative(uint32_t Type) const;
- bool canRelaxTls(unsigned Type, const SymbolBody *S) const;
+ bool canRelaxTls(uint32_t Type, const SymbolBody *S) const;
template <class ELFT>
bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
virtual unsigned relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
@@ -84,14 +84,14 @@ public:
// 0x200000, but it looks like every OS uses 4k pages for executables.
uint64_t VAStart = 0x10000;
- unsigned CopyRel;
- unsigned GotRel;
- unsigned PltRel;
- unsigned RelativeRel;
- unsigned IRelativeRel;
- unsigned TlsGotRel = 0;
- unsigned TlsModuleIndexRel;
- unsigned TlsOffsetRel;
+ uint32_t CopyRel;
+ uint32_t GotRel;
+ uint32_t PltRel;
+ uint32_t RelativeRel;
+ uint32_t IRelativeRel;
+ uint32_t TlsGotRel = 0;
+ uint32_t TlsModuleIndexRel;
+ uint32_t TlsOffsetRel;
unsigned PltEntrySize = 8;
unsigned PltZeroSize = 0;
unsigned GotHeaderEntriesNum = 0;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262793&r1=262792&r2=262793&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Mar 6 00:01:07 2016
@@ -256,7 +256,7 @@ template <bool Is64Bits> struct DenseMap
}
template <class ELFT, class RelT>
-static bool handleTlsRelocation(unsigned Type, SymbolBody *Body,
+static bool handleTlsRelocation(uint32_t Type, SymbolBody *Body,
InputSectionBase<ELFT> &C, RelT &RI) {
if (Target->pointsToLocalDynamicGotEntry(Type)) {
if (Target->canRelaxTls(Type, nullptr))
More information about the llvm-commits
mailing list