[lld] r295130 - Revert "Relax the restriction on what relocations can be in a non-alloc section."

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 16:27:48 PST 2017


Author: rafael
Date: Tue Feb 14 18:27:47 2017
New Revision: 295130

URL: http://llvm.org/viewvc/llvm-project?rev=295130&view=rev
Log:
Revert "Relax the restriction on what relocations can be in a non-alloc section."

This reverts commit r295102.

In the link of seabios the assumption seems to be that the section has
an actual address, so this is not sufficient. Changing the assembly
code to add a "a" flag seems like the correct thing to do instead of
extending this hack.

Sorry about the noise.

Original message:

    Relax the restriction on what relocations can be in a non-alloc section.

    The main thing that they can't have is relocations that require the
    creation of gots or plt.  For now also accept R_PC.

    Found while linking seabios.

Removed:
    lld/trunk/test/ELF/i386-reloc-non-alloc.s
Modified:
    lld/trunk/ELF/InputSection.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=295130&r1=295129&r2=295130&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Feb 14 18:27:47 2017
@@ -452,8 +452,7 @@ void InputSection<ELFT>::relocateNonAllo
       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<ELFT>::relocateNonAllo
     uint64_t SymVA = 0;
     if (!Sym.isTls() || Out<ELFT>::TlsPhdr)
       SymVA = SignExtend64<sizeof(uintX_t) * 8>(
-          getRelocTargetVA<ELFT>(Type, Addend, AddrLoc, Sym, E));
+          getRelocTargetVA<ELFT>(Type, Addend, AddrLoc, Sym, R_ABS));
     Target->relocateOne(BufLoc, Type, SymVA);
   }
 }

Removed: lld/trunk/test/ELF/i386-reloc-non-alloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-reloc-non-alloc.s?rev=295129&view=auto
==============================================================================
--- lld/trunk/test/ELF/i386-reloc-non-alloc.s (original)
+++ lld/trunk/test/ELF/i386-reloc-non-alloc.s (removed)
@@ -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 - .




More information about the llvm-commits mailing list