summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-09-06 13:57:15 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-09-06 13:57:15 +0000
commit719f55d3790eeed2708ac4fc1bf438363caba42d (patch)
treee911d9aab42e33677a05cc8fa8c617eeb8481064
parentff1f29e0f69270a6607bb1d214979d1ed3f4be02 (diff)
downloadbcm5719-llvm-719f55d3790eeed2708ac4fc1bf438363caba42d.tar.gz
bcm5719-llvm-719f55d3790eeed2708ac4fc1bf438363caba42d.zip
Mark R_GOTREL_FROM_END as a relative expression.
Fixes pr30282. llvm-svn: 280709
-rw-r--r--lld/ELF/Relocations.cpp5
-rw-r--r--lld/test/ELF/i386-gotoff-shared.s23
2 files changed, 26 insertions, 2 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index d10b594a103..47c040607ca 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -283,8 +283,9 @@ static bool needsPlt(RelExpr Expr) {
// True if this expression is of the form Sym - X, where X is a position in the
// file (PC, or GOT for example).
static bool isRelExpr(RelExpr Expr) {
- return Expr == R_PC || Expr == R_GOTREL || Expr == R_PAGE_PC ||
- Expr == R_RELAX_GOT_PC || Expr == R_THUNK_PC || Expr == R_THUNK_PLT_PC;
+ return Expr == R_PC || Expr == R_GOTREL || Expr == R_GOTREL_FROM_END ||
+ Expr == R_PAGE_PC || Expr == R_RELAX_GOT_PC || Expr == R_THUNK_PC ||
+ Expr == R_THUNK_PLT_PC;
}
template <class ELFT>
diff --git a/lld/test/ELF/i386-gotoff-shared.s b/lld/test/ELF/i386-gotoff-shared.s
new file mode 100644
index 00000000000..01242ad01c3
--- /dev/null
+++ b/lld/test/ELF/i386-gotoff-shared.s
@@ -0,0 +1,23 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
+// RUN: ld.lld %t.o -o %t.so -shared
+// RUN: llvm-readobj -s %t.so | FileCheck %s
+// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s
+
+bar:
+ movl bar@GOTOFF(%ebx), %eax
+ mov bar@GOT, %eax
+
+// CHECK: Name: .got
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x2050
+// CHECK-NEXT: Offset: 0x2050
+// CHECK-NEXT: Size: 4
+
+// 0x1000 - (0x2050 + 4) = -4180
+
+// DISASM: 1000: {{.*}} movl -4180(%ebx), %eax
OpenPOWER on IntegriCloud