summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-04-21 17:30:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-04-21 17:30:24 +0000
commitb312a740aea5dc9254b513d31e6495def9fb0083 (patch)
tree3e5783119cdfa923b11d01d28af7e079d2cf24fa /lld/ELF/Writer.cpp
parent1dbd582387a577ee416d22d9cc2dc957926f8035 (diff)
downloadbcm5719-llvm-b312a740aea5dc9254b513d31e6495def9fb0083.tar.gz
bcm5719-llvm-b312a740aea5dc9254b513d31e6495def9fb0083.zip
Delete the needsPlt target hook.
It can be made redundant with getRelExpr. llvm-svn: 267012
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 322e1b17a0d..13afd8027dd 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -435,10 +435,14 @@ namespace {
enum PltNeed { Plt_No, Plt_Explicit, Plt_Implicit };
}
+static bool needsPlt(RelExpr Expr) {
+ return Expr == R_PLT_PC || Expr == R_PPC_PLT_OPD || Expr == R_PLT;
+}
+
static PltNeed needsPlt(RelExpr Expr, uint32_t Type, const SymbolBody &S) {
if (S.isGnuIFunc())
return Plt_Explicit;
- if (S.isPreemptible() && Target->needsPlt(Type))
+ if (S.isPreemptible() && needsPlt(Expr))
return Plt_Explicit;
// This handles a non PIC program call to function in a shared library.
@@ -570,12 +574,12 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
if (NeedPlt) {
if (NeedPlt == Plt_Implicit)
Body.NeedsCopyOrPltAddr = true;
- RelExpr E;
+ RelExpr E = Expr;
if (Expr == R_PPC_OPD)
E = R_PPC_PLT_OPD;
else if (Expr == R_PC)
E = R_PLT_PC;
- else
+ else if (Expr == R_ABS)
E = R_PLT;
C.Relocations.push_back({E, Type, Offset, Addend, &Body});
@@ -605,6 +609,15 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
continue;
}
+ // We decided not to use a plt. Optimize a reference to the plt to a
+ // reference to the symbol itself.
+ if (Expr == R_PLT_PC)
+ Expr = R_PC;
+ if (Expr == R_PPC_PLT_OPD)
+ Expr = R_PPC_OPD;
+ if (Expr == R_PLT)
+ Expr = R_ABS;
+
if (Target->needsThunk(Type, File, Body)) {
C.Relocations.push_back({R_THUNK, Type, Offset, Addend, &Body});
continue;
OpenPOWER on IntegriCloud