diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 40f95daaf3d1..9b21a3271902 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -452,8 +452,7 @@ void InputSection::relocateNonAlloc(uint8_t *Buf, ArrayRef Rels) { Addend += Target->getImplicitAddend(BufLoc, Type); SymbolBody &Sym = this->File->getRelocTargetSym(Rel); - RelExpr E = Target->getRelExpr(Type, Sym); - if (E != R_ABS && E != R_PC) { + if (Target->getRelExpr(Type, Sym) != R_ABS) { error(this->getLocation(Offset) + ": has non-ABS reloc"); return; } @@ -462,7 +461,7 @@ void InputSection::relocateNonAlloc(uint8_t *Buf, ArrayRef Rels) { uint64_t SymVA = 0; if (!Sym.isTls() || Out::TlsPhdr) SymVA = SignExtend64( - getRelocTargetVA(Type, Addend, AddrLoc, Sym, E)); + getRelocTargetVA(Type, Addend, AddrLoc, Sym, R_ABS)); Target->relocateOne(BufLoc, Type, SymVA); } } diff --git a/lld/test/ELF/i386-reloc-non-alloc.s b/lld/test/ELF/i386-reloc-non-alloc.s deleted file mode 100644 index 98612fe57f74..000000000000 --- a/lld/test/ELF/i386-reloc-non-alloc.s +++ /dev/null @@ -1,18 +0,0 @@ -// REQUIRES: x86 - -// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t.so -// RUN: llvm-objdump -s %t.so | FileCheck %s - -// CHECK: Contents of section .text: -// CHECK-NEXT: 1000 00000000 00000000 - -// CHECK: Contents of section .bar: -// CHECK-NEXT: 0000 00100000 fc0f0000 - -foo: -.quad 0 - -.section .bar -.long foo - . -.long foo - .