summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2017-12-24 23:15:17 +0000
committerpatrick <patrick@openbsd.org>2017-12-24 23:15:17 +0000
commit34091ed6d5747c7d4acdc1ef6af75ce9b7a8adba (patch)
tree53479f738fa2c63ce6cf95113985510e3653de23 /gnu/llvm/lib/Linker/LinkModules.cpp
parentConsolidate printf(3) calls at the end of main(). (diff)
downloadwireguard-openbsd-34091ed6d5747c7d4acdc1ef6af75ce9b7a8adba.tar.xz
wireguard-openbsd-34091ed6d5747c7d4acdc1ef6af75ce9b7a8adba.zip
Import LLVM 5.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lib/Linker/LinkModules.cpp')
-rw-r--r--gnu/llvm/lib/Linker/LinkModules.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/gnu/llvm/lib/Linker/LinkModules.cpp b/gnu/llvm/lib/Linker/LinkModules.cpp
index c0ce4bf76b9..25f31a3401a 100644
--- a/gnu/llvm/lib/Linker/LinkModules.cpp
+++ b/gnu/llvm/lib/Linker/LinkModules.cpp
@@ -329,8 +329,18 @@ bool ModuleLinker::shouldLinkFromSource(bool &LinkFromSrc,
bool ModuleLinker::linkIfNeeded(GlobalValue &GV) {
GlobalValue *DGV = getLinkedToGlobal(&GV);
- if (shouldLinkOnlyNeeded() && !(DGV && DGV->isDeclaration()))
- return false;
+ if (shouldLinkOnlyNeeded()) {
+ // Always import variables with appending linkage.
+ if (!GV.hasAppendingLinkage()) {
+ // Don't import globals unless they are referenced by the destination
+ // module.
+ if (!DGV)
+ return false;
+ // Don't import globals that are already defined in the destination module
+ if (!DGV->isDeclaration())
+ return false;
+ }
+ }
if (DGV && !GV.hasLocalLinkage() && !GV.hasAppendingLinkage()) {
auto *DGVar = dyn_cast<GlobalVariable>(DGV);