diff options
author | Reid Kleckner <rnk@google.com> | 2019-05-07 23:06:21 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-05-07 23:06:21 +0000 |
commit | 6bf108d77a3c15f2bd47a8fa21e8e9357f873a70 (patch) | |
tree | c82b45b5c081bbbe0a7620afba033c111c17c165 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | e088d03b9c8b25589bbf35545399ae28a34df182 (diff) | |
download | bcm5719-llvm-6bf108d77a3c15f2bd47a8fa21e8e9357f873a70.tar.gz bcm5719-llvm-6bf108d77a3c15f2bd47a8fa21e8e9357f873a70.zip |
[COFF] Use COFF stubs for extern_weak functions
Summary:
A COFF stub indirects the reference to a symbol through memory. A
.refptr.$sym global variable pointer is created to refer to $sym.
Typically mingw uses these for external global variable declarations,
but we can use them for weak function declarations as well.
Updates the dso_local classification to add a special case for
extern_weak symbols on COFF in both clang and LLVM.
Fixes PR37598
Reviewers: smeenai, mstorsjo
Subscribers: hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D61615
llvm-svn: 360207
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b490fa0faf2..40e18e6e350 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -763,6 +763,13 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, !GV->isThreadLocal()) return false; } + + // On COFF, don't mark 'extern_weak' symbols as DSO local. If these symbols + // remain unresolved in the link, they can be resolved to zero, which is + // outside the current DSO. + if (TT.isOSBinFormatCOFF() && GV->hasExternalWeakLinkage()) + return false; + // Every other GV is local on COFF. // Make an exception for windows OS in the triple: Some firmware builds use // *-win32-macho triples. This (accidentally?) produced windows relocations |