[lld] r267394 - Delete needsCopyRelImpl. It is redundant with getRelExpr.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 25 05:06:00 PDT 2016
Author: rafael
Date: Mon Apr 25 07:05:56 2016
New Revision: 267394
URL: http://llvm.org/viewvc/llvm-project?rev=267394&view=rev
Log:
Delete needsCopyRelImpl. It is redundant with getRelExpr.
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=267394&r1=267393&r2=267394&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Apr 25 07:05:56 2016
@@ -92,7 +92,6 @@ public:
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
bool isRelRelative(uint32_t Type) const override;
- bool needsCopyRelImpl(uint32_t Type) const override;
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
void relaxTlsGdToIe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -115,7 +114,6 @@ 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;
- bool needsCopyRelImpl(uint32_t Type) const override;
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
bool isRelRelative(uint32_t Type) const override;
@@ -156,7 +154,6 @@ public:
int32_t Index, unsigned RelOff) const override;
uint32_t getTlsGotRel(uint32_t Type) const override;
bool isRelRelative(uint32_t Type) const override;
- bool needsCopyRelImpl(uint32_t Type) const override;
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
void relaxTlsIeToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -184,7 +181,6 @@ public:
int32_t Index, unsigned RelOff) const override;
void writeGotHeader(uint8_t *Buf) const override;
void writeThunk(uint8_t *Buf, uint64_t S) const override;
- bool needsCopyRelImpl(uint32_t Type) const override;
bool needsThunk(uint32_t Type, const InputFile &File,
const SymbolBody &S) const override;
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -229,20 +225,6 @@ uint64_t TargetInfo::getImplicitAddend(c
uint64_t TargetInfo::getVAStart() const { return Config->Pic ? 0 : VAStart; }
-bool TargetInfo::needsCopyRelImpl(uint32_t Type) const { return false; }
-
-static bool mayNeedCopy(const SymbolBody &S) {
- if (Config->Shared)
- return false;
- if (!S.isShared())
- return false;
- return S.isObject();
-}
-
-bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const {
- return mayNeedCopy(S) && needsCopyRelImpl(Type);
-}
-
bool TargetInfo::isHintRel(uint32_t Type) const { return false; }
bool TargetInfo::isRelRelative(uint32_t Type) const { return true; }
@@ -412,10 +394,6 @@ void X86TargetInfo::writePlt(uint8_t *Bu
write32le(Buf + 12, -Index * PltEntrySize - PltZeroSize - 16);
}
-bool X86TargetInfo::needsCopyRelImpl(uint32_t Type) const {
- return Type == R_386_32 || Type == R_386_16 || Type == R_386_8;
-}
-
uint64_t X86TargetInfo::getImplicitAddend(const uint8_t *Buf,
uint32_t Type) const {
switch (Type) {
@@ -611,11 +589,6 @@ void X86_64TargetInfo::writePlt(uint8_t
write32le(Buf + 12, -Index * PltEntrySize - PltZeroSize - 16);
}
-bool X86_64TargetInfo::needsCopyRelImpl(uint32_t Type) const {
- return Type == R_X86_64_32S || Type == R_X86_64_32 || Type == R_X86_64_PC32 ||
- Type == R_X86_64_64;
-}
-
uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {
if (Type == R_X86_64_PC32 || Type == R_X86_64_32)
if (Config->Shared)
@@ -1141,25 +1114,6 @@ uint32_t AArch64TargetInfo::getTlsGotRel
return Type;
}
-bool AArch64TargetInfo::needsCopyRelImpl(uint32_t Type) const {
- switch (Type) {
- default:
- return false;
- case R_AARCH64_ABS16:
- case R_AARCH64_ABS32:
- case R_AARCH64_ABS64:
- case R_AARCH64_ADD_ABS_LO12_NC:
- case R_AARCH64_ADR_PREL_LO21:
- case R_AARCH64_ADR_PREL_PG_HI21:
- case R_AARCH64_LDST8_ABS_LO12_NC:
- case R_AARCH64_LDST16_ABS_LO12_NC:
- case R_AARCH64_LDST32_ABS_LO12_NC:
- case R_AARCH64_LDST64_ABS_LO12_NC:
- case R_AARCH64_LDST128_ABS_LO12_NC:
- return true;
- }
-}
-
static void updateAArch64Addr(uint8_t *L, uint64_t Imm) {
uint32_t ImmLo = (Imm & 0x3) << 29;
uint32_t ImmHi = ((Imm & 0x1FFFFC) >> 2) << 5;
@@ -1517,11 +1471,6 @@ void MipsTargetInfo<ELFT>::writeThunk(ui
}
template <class ELFT>
-bool MipsTargetInfo<ELFT>::needsCopyRelImpl(uint32_t Type) const {
- return !isRelRelative(Type) || Type == R_MIPS_LO16;
-}
-
-template <class ELFT>
bool MipsTargetInfo<ELFT>::needsThunk(uint32_t Type, const InputFile &File,
const SymbolBody &S) const {
// Any MIPS PIC code function is invoked with its address in register $t9.
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=267394&r1=267393&r2=267394&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Mon Apr 25 07:05:56 2016
@@ -62,7 +62,6 @@ public:
virtual RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const = 0;
virtual void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const = 0;
- bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
virtual ~TargetInfo();
unsigned TlsGdToLeSkip = 1;
@@ -95,9 +94,6 @@ public:
virtual void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
virtual void relaxTlsIeToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
virtual void relaxTlsLdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
-
-private:
- virtual bool needsCopyRelImpl(uint32_t Type) const;
};
uint64_t getPPC64TocBase();
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=267394&r1=267393&r2=267394&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Apr 25 07:05:56 2016
@@ -473,6 +473,22 @@ static PltNeed needsPlt(RelExpr Expr, ui
return Plt_No;
}
+static bool needsCopyRel(RelExpr E, const SymbolBody &S) {
+ if (Config->Shared)
+ return false;
+ if (!S.isShared())
+ return false;
+ if (!S.isObject())
+ return false;
+ if (refersToGotEntry(E))
+ return false;
+ if (needsPlt(E))
+ return false;
+ if (E == R_SIZE)
+ return false;
+ return true;
+}
+
// The reason we have to do this early scan is as follows
// * To mmap the output file, we need to know the size
// * For that, we need to know how many dynamic relocs we will have.
@@ -557,7 +573,7 @@ void Writer<ELFT>::scanRelocs(InputSecti
// in a read-only section, we need to create a copy relocation for the
// symbol.
if (auto *B = dyn_cast<SharedSymbol<ELFT>>(&Body)) {
- if (IsAlloc && !IsWrite && Target->needsCopyRel(Type, *B)) {
+ if (IsAlloc && !IsWrite && needsCopyRel(Expr, *B)) {
if (!B->needsCopy())
addCopyRelSymbol(B);
C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});
More information about the llvm-commits
mailing list