Index: lld/trunk/ELF/Target.cpp =================================================================== --- lld/trunk/ELF/Target.cpp +++ lld/trunk/ELF/Target.cpp @@ -110,6 +110,7 @@ class X86_64TargetInfo final : public TargetInfo { public: X86_64TargetInfo(); + uint32_t getDynRel(uint32_t Type) const override; uint32_t getTlsGotRel(uint32_t Type) const override; bool pointsToLocalDynamicGotEntry(uint32_t Type) const override; bool isTlsLocalDynamicRel(uint32_t Type) const override; @@ -758,6 +759,14 @@ return refersToGotEntry(Type) || needsPlt(Type, S); } +uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const { + if (Type == R_X86_64_PC32 || Type == R_X86_64_32) + if (Config->Shared) + error(getELFRelocationTypeName(EM_X86_64, Type) + + " cannot be a dynamic relocation"); + return Type; +} + uint32_t X86_64TargetInfo::getTlsGotRel(uint32_t Type) const { // No other types of TLS relocations requiring GOT should // reach here. Index: lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s =================================================================== --- lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s +++ lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s @@ -1,3 +1,3 @@ .globl _shared _shared: - call _unresolved + callq _unresolved@PLT Index: lld/trunk/test/ELF/allow-shlib-undefined.s =================================================================== --- lld/trunk/test/ELF/allow-shlib-undefined.s +++ lld/trunk/test/ELF/allow-shlib-undefined.s @@ -22,4 +22,4 @@ .globl _start _start: - call _shared + callq _shared@PLT Index: lld/trunk/test/ELF/llvm33-rela-outside-group.s =================================================================== --- lld/trunk/test/ELF/llvm33-rela-outside-group.s +++ lld/trunk/test/ELF/llvm33-rela-outside-group.s @@ -8,4 +8,4 @@ .section .text._Z3fooIiEvv,"axG",@progbits,_Z3fooIiEvv,comdat _Z3fooIiEvv: - callq bar + callq bar@PLT Index: lld/trunk/test/ELF/lto/linkonce-odr.ll =================================================================== --- lld/trunk/test/ELF/lto/linkonce-odr.ll +++ lld/trunk/test/ELF/lto/linkonce-odr.ll @@ -1,6 +1,6 @@ ; REQUIRES: x86 ; RUN: llvm-as %p/Inputs/linkonce-odr.ll -o %t1.o -; RUN: llc %s -o %t2.o -filetype=obj +; RUN: llc -relocation-model=pic %s -o %t2.o -filetype=obj ; RUN: ld.lld %t1.o %t2.o -o %t.so -shared -save-temps ; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s Index: lld/trunk/test/ELF/lto/linkonce.ll =================================================================== --- lld/trunk/test/ELF/lto/linkonce.ll +++ lld/trunk/test/ELF/lto/linkonce.ll @@ -1,6 +1,6 @@ ; REQUIRES: x86 ; RUN: llvm-as %p/Inputs/linkonce.ll -o %t1.o -; RUN: llc %s -o %t2.o -filetype=obj +; RUN: llc -relocation-model=pic %s -o %t2.o -filetype=obj ; RUN: ld.lld %t1.o %t2.o -o %t.so -shared -save-temps ; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s Index: lld/trunk/test/ELF/no-undefined.s =================================================================== --- lld/trunk/test/ELF/no-undefined.s +++ lld/trunk/test/ELF/no-undefined.s @@ -4,4 +4,4 @@ .globl _shared _shared: - call _unresolved + callq _unresolved@PLT Index: lld/trunk/test/ELF/x86-64-reloc-32-fpic.s =================================================================== --- lld/trunk/test/ELF/x86-64-reloc-32-fpic.s +++ lld/trunk/test/ELF/x86-64-reloc-32-fpic.s @@ -0,0 +1,6 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s +# CHECK: R_X86_64_32 cannot be a dynamic relocation + +.long _shared Index: lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s =================================================================== --- lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s +++ lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s @@ -0,0 +1,6 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s +# CHECK: R_X86_64_PC32 cannot be a dynamic relocation + +call _shared