Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ 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: test/ELF/Inputs/allow-shlib-undefined.s =================================================================== --- test/ELF/Inputs/allow-shlib-undefined.s +++ test/ELF/Inputs/allow-shlib-undefined.s @@ -1,3 +1,3 @@ .globl _shared _shared: - call _unresolved + callq _unresolved@PLT Index: test/ELF/Inputs/llvm33-rela-outside-group.o =================================================================== --- test/ELF/Inputs/llvm33-rela-outside-group.o +++ test/ELF/Inputs/llvm33-rela-outside-group.o @@ -1,2 +1,2 @@ ELF>˜@@ -è.rela.text._Z3fooIiEvv.text.bss.group.shstrtab.strtab.symtab.data#@HDHHHð*MJ<À 4Ø bar_Z3fooIiEvvüÿÿÿÿÿÿÿ \ No newline at end of file +è.rela.text._Z3fooIiEvv.text.bss.group.shstrtab.strtab.symtab.data#@HDHHH*MJ<Ø 4ð' bar_Z3fooIiEvv_GLOBAL_OFFSET_TABLE_üÿÿÿÿÿÿÿ \ No newline at end of file Index: test/ELF/allow-shlib-undefined.s =================================================================== --- test/ELF/allow-shlib-undefined.s +++ test/ELF/allow-shlib-undefined.s @@ -22,4 +22,4 @@ .globl _start _start: - call _shared + callq _shared@PLT Index: test/ELF/llvm33-rela-outside-group.s =================================================================== --- test/ELF/llvm33-rela-outside-group.s +++ 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: test/ELF/lto/linkonce-odr.ll =================================================================== --- test/ELF/lto/linkonce-odr.ll +++ 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: test/ELF/lto/linkonce.ll =================================================================== --- test/ELF/lto/linkonce.ll +++ 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: test/ELF/no-undefined.s =================================================================== --- test/ELF/no-undefined.s +++ test/ELF/no-undefined.s @@ -4,4 +4,4 @@ .globl _shared _shared: - call _unresolved + callq _unresolved@PLT Index: test/ELF/x86-64-reloc-32-fpic.s =================================================================== --- test/ELF/x86-64-reloc-32-fpic.s +++ 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: test/ELF/x86-64-reloc-pc32-fpic.s =================================================================== --- test/ELF/x86-64-reloc-pc32-fpic.s +++ 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