[lld] r273006 - Don't confuse input and output section offsets.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 08:42:36 PDT 2016
Author: rafael
Date: Fri Jun 17 10:42:36 2016
New Revision: 273006
URL: http://llvm.org/viewvc/llvm-project?rev=273006&view=rev
Log:
Don't confuse input and output section offsets.
Added:
lld/trunk/test/ELF/Inputs/x86-64-relax-offset.s
lld/trunk/test/ELF/x86-64-relax-offset.s
Modified:
lld/trunk/ELF/Relocations.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=273006&r1=273005&r2=273006&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Fri Jun 17 10:42:36 2016
@@ -511,15 +511,15 @@ static void scanRelocs(InputSectionBase<
uint32_t Type = RI.getType(Config->Mips64EL);
RelExpr Expr = Target->getRelExpr(Type, Body);
- uintX_t Offset = C.getOffset(RI.r_offset);
- if (Offset == (uintX_t)-1)
- continue;
-
bool Preemptible = isPreemptible(Body, Type);
- Expr = adjustExpr(File, Body, IsWrite, Expr, Type, Buf + Offset);
+ Expr = adjustExpr(File, Body, IsWrite, Expr, Type, Buf + RI.r_offset);
if (HasError)
continue;
+ uintX_t Offset = C.getOffset(RI.r_offset);
+ if (Offset == (uintX_t)-1)
+ continue;
+
// This relocation does not require got entry, but it is relative to got and
// needs it to be created. Here we request for that.
if (Expr == R_GOTONLY_PC || Expr == R_GOTREL || Expr == R_PPC_TOC)
Added: lld/trunk/test/ELF/Inputs/x86-64-relax-offset.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/x86-64-relax-offset.s?rev=273006&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/x86-64-relax-offset.s (added)
+++ lld/trunk/test/ELF/Inputs/x86-64-relax-offset.s Fri Jun 17 10:42:36 2016
@@ -0,0 +1,7 @@
+.global foo
+.hidden foo
+foo:
+ nop
+ nop
+ nop
+ nop
Added: lld/trunk/test/ELF/x86-64-relax-offset.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-relax-offset.s?rev=273006&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-relax-offset.s (added)
+++ lld/trunk/test/ELF/x86-64-relax-offset.s Fri Jun 17 10:42:36 2016
@@ -0,0 +1,13 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %s \
+// RUN: -o %t.o
+// RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux \
+// RUN: %p/Inputs/x86-64-relax-offset.s -o %t2.o
+// RUN: ld.lld %t2.o %t.o -o %t.so -shared
+// RUN: llvm-objdump -d %t.so | FileCheck %s
+
+ mov foo at gotpcrel(%rip), %rax
+ nop
+
+// CHECK: 1004: {{.*}} leaq -11(%rip), %rax
+// CHECK-NEXT: 100b: {{.*}} nop
More information about the llvm-commits
mailing list