Revert "Revert "Add a test showing that lto produces relaxable relocations.""

This reverts commit r273247.

lld should always use the new relocations.

llvm-svn: 273266
This commit is contained in:
Rafael Espindola 2016-06-21 14:47:43 +00:00
parent 7e2fc3b702
commit 254b58dfe3
2 changed files with 19 additions and 0 deletions

View File

@ -279,6 +279,10 @@ std::vector<std::unique_ptr<InputFile>> BitcodeCompiler::compile() {
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 = [&]() {

View File

@ -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"
@foo = external global i32
define i32 @bar() {
%t = load i32, i32* @foo
ret i32 %t
}