[lld] r273266 - Revert "Revert "Add a test showing that lto produces relaxable relocations.""

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 07:47:43 PDT 2016


Author: rafael
Date: Tue Jun 21 09:47:43 2016
New Revision: 273266

URL: http://llvm.org/viewvc/llvm-project?rev=273266&view=rev
Log:
Revert "Revert "Add a test showing that lto produces relaxable relocations.""

This reverts commit r273247.

lld should always use the new relocations.

Added:
    lld/trunk/test/ELF/lto/relax-relocs.ll
Modified:
    lld/trunk/ELF/LTO.cpp

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=273266&r1=273265&r2=273266&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Tue Jun 21 09:47:43 2016
@@ -279,6 +279,10 @@ std::vector<std::unique_ptr<InputFile>>
   if (!T)
     fatal("target not found: " + Msg);
   TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+
+  // lld supports the new relocations.
+  Options.RelaxELFRelocations = true;
+
   Reloc::Model R = Config->Pic ? Reloc::PIC_ : Reloc::Static;
 
   auto CreateTargetMachine = [&]() {

Added: lld/trunk/test/ELF/lto/relax-relocs.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/relax-relocs.ll?rev=273266&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/relax-relocs.ll (added)
+++ lld/trunk/test/ELF/lto/relax-relocs.ll Tue Jun 21 09:47:43 2016
@@ -0,0 +1,15 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld -m elf_x86_64 -save-temps -shared %t.o -o %t.so
+; RUN: llvm-readobj -r %t.so.lto.o | FileCheck %s
+
+; Test that we produce R_X86_64_REX_GOTPCRELX instead of R_X86_64_GOTPCREL
+; CHECK: R_X86_64_REX_GOTPCRELX foo
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at foo = external global i32
+define i32 @bar() {
+  %t = load i32, i32* @foo
+  ret i32 %t
+}




More information about the llvm-commits mailing list