[lld] r262492 - LTO: Use the correct relocation model.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 2 09:21:07 PST 2016
Author: rafael
Date: Wed Mar 2 11:21:06 2016
New Revision: 262492
URL: http://llvm.org/viewvc/llvm-project?rev=262492&view=rev
Log:
LTO: Use the correct relocation model.
Added:
lld/trunk/test/ELF/lto/pic.ll
Modified:
lld/trunk/ELF/SymbolTable.cpp
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=262492&r1=262491&r2=262492&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Mar 2 11:21:06 2016
@@ -112,8 +112,9 @@ std::unique_ptr<InputFile> SymbolTable<E
fatal("Target not found: " + ErrMsg);
TargetOptions Options;
+ Reloc::Model R = Config->Shared ? Reloc::PIC_ : Reloc::Static;
std::unique_ptr<TargetMachine> TM(
- TheTarget->createTargetMachine(TripleStr, "", "", Options));
+ TheTarget->createTargetMachine(TripleStr, "", "", Options, R));
raw_svector_ostream OS(OwningLTOData);
legacy::PassManager CodeGenPasses;
Added: lld/trunk/test/ELF/lto/pic.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/pic.ll?rev=262492&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/pic.ll (added)
+++ lld/trunk/test/ELF/lto/pic.ll Wed Mar 2 11:21:06 2016
@@ -0,0 +1,20 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld %t.o -m elf_x86_64 -o %t.so -shared
+; RUN: llvm-readobj -r %t.so | FileCheck %s
+
+; CHECK: Relocations [
+; CHECK-NEXT: Section ({{.*}}) .rela.plt {
+; CHECK-NEXT: R_X86_64_JUMP_SLOT bar 0x0
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar()
+define void @foo() {
+ call void @bar()
+ ret void
+}
More information about the llvm-commits
mailing list