Don't confuse input and output section offsets.

llvm-svn: 273006
This commit is contained in:
Rafael Espindola 2016-06-17 15:42:36 +00:00
parent 7b998853ee
commit 678844e68a
3 changed files with 25 additions and 5 deletions

View File

@ -511,13 +511,13 @@ static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
uint32_t Type = RI.getType(Config->Mips64EL); uint32_t Type = RI.getType(Config->Mips64EL);
RelExpr Expr = Target->getRelExpr(Type, Body); RelExpr Expr = Target->getRelExpr(Type, Body);
uintX_t Offset = C.getOffset(RI.r_offset); bool Preemptible = isPreemptible(Body, Type);
if (Offset == (uintX_t)-1) Expr = adjustExpr(File, Body, IsWrite, Expr, Type, Buf + RI.r_offset);
if (HasError)
continue; continue;
bool Preemptible = isPreemptible(Body, Type); uintX_t Offset = C.getOffset(RI.r_offset);
Expr = adjustExpr(File, Body, IsWrite, Expr, Type, Buf + Offset); if (Offset == (uintX_t)-1)
if (HasError)
continue; continue;
// This relocation does not require got entry, but it is relative to got and // This relocation does not require got entry, but it is relative to got and

View File

@ -0,0 +1,7 @@
.global foo
.hidden foo
foo:
nop
nop
nop
nop

View File

@ -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@gotpcrel(%rip), %rax
nop
// CHECK: 1004: {{.*}} leaq -11(%rip), %rax
// CHECK-NEXT: 100b: {{.*}} nop