return false;
}
+template <class ELFT> static bool isAbsoluteValue(const SymbolBody &Body) {
+ return isAbsolute<ELFT>(Body) || Body.isTls();
+}
+
static bool needsPlt(RelExpr Expr) {
return Expr == R_PLT_PC || Expr == R_PPC_PLT_OPD || Expr == R_PLT ||
Expr == R_PLT_PAGE_PC || Expr == R_THUNK_PLT_PC;
if (!Config->Pic)
return true;
- bool AbsVal = isAbsolute<ELFT>(Body) || Body.isTls();
+ bool AbsVal = isAbsoluteValue<ELFT>(Body);
bool RelE = isRelExpr(E);
if (AbsVal && !RelE)
return true;
} else if (!Preemptible) {
if (needsPlt(Expr))
Expr = fromPlt(Expr);
- if (Expr == R_GOT_PC)
+ if (Expr == R_GOT_PC && !isAbsoluteValue<ELFT>(Body))
Expr = Target->adjustRelaxExpr(Type, Data, Expr);
}
Expr = Target->getThunkExpr(Expr, Type, File, Body);
--- /dev/null
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %s \
+// RUN: -o %t.o
+// RUN: ld.lld %t.o -o %t.so -shared
+// RUN: llvm-objdump -d %t.so | FileCheck %s
+
+// We used to fail trying to relax this into a pc relocation to an absolute
+// value.
+
+// CHECK: movq 4185(%rip), %rax
+
+ movq bar@GOTPCREL(%rip), %rax
+ .data
+ .global bar
+ .hidden bar
+ bar = 42