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;
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.
.globl _shared
_shared:
- call _unresolved
+ callq _unresolved@PLT
.globl _start
_start:
- call _shared
+ callq _shared@PLT
.section .text._Z3fooIiEvv,"axG",@progbits,_Z3fooIiEvv,comdat
_Z3fooIiEvv:
- callq bar
+ callq bar@PLT
; 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
; 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
.globl _shared
_shared:
- call _unresolved
+ callq _unresolved@PLT
--- /dev/null
+# 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
--- /dev/null
+# 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