From 3704eba1d1a88187cdd3895da9440e95e188e9cc Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 11 Aug 2017 23:52:28 +0000 Subject: D36604: PR34148: Do not assume we can use a copy relocation for an `external_weak` global An `external_weak` global may be intended to resolve as a null pointer if it's not defined, so it doesn't make sense to use a copy relocation for it. Differential Revision: https://reviews.llvm.org/D36604 llvm-svn: 310773 --- llvm/lib/Target/TargetMachine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Target/TargetMachine.cpp') diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index e8fe0a2b218..b2578fb7a02 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -154,8 +154,9 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, return true; bool IsTLS = GV && GV->isThreadLocal(); - bool IsAccessViaCopyRelocs = - Options.MCOptions.MCPIECopyRelocations && GV && isa(GV); + bool IsAccessViaCopyRelocs = Options.MCOptions.MCPIECopyRelocations && GV && + isa(GV) && + !GV->hasExternalWeakLinkage(); Triple::ArchType Arch = TT.getArch(); bool IsPPC = Arch == Triple::ppc || Arch == Triple::ppc64 || Arch == Triple::ppc64le; -- cgit v1.2.3