summaryrefslogtreecommitdiff
path: root/tools/lto/LTOModule.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2009-04-24 16:55:21 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2009-04-24 16:55:21 +0000
commit7431af050f287011fd52e64034ede6dd98193feb (patch)
treea6bc5dbc0d059f99cbfbfef6c94ecf0f4ad00ad7 /tools/lto/LTOModule.cpp
parent16ffa807fc93eee79f1775cffe94cef174755455 (diff)
downloadllvm-7431af050f287011fd52e64034ede6dd98193feb.tar.gz
llvm-7431af050f287011fd52e64034ede6dd98193feb.tar.bz2
llvm-7431af050f287011fd52e64034ede6dd98193feb.tar.xz
Add LTO_SYMBOL_DEFINITION_WEAKUNDEF, use that on the gold plugin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69972 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto/LTOModule.cpp')
-rw-r--r--tools/lto/LTOModule.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 71f3850e52..78c8cfe93d 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -258,9 +258,21 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
{
const char* name = mangler.getValueName(decl).c_str();
// ignore all llvm.* symbols
- if ( strncmp(name, "llvm.", 5) != 0 ) {
- _undefines[name] = 1;
- }
+ if ( strncmp(name, "llvm.", 5) == 0 )
+ return;
+
+ // we already have the symbol
+ if (_undefines.find(name) != _undefines.end())
+ return;
+
+ NameAndAttributes info;
+ // string is owned by _undefines
+ info.name = ::strdup(name);
+ if (decl->hasExternalWeakLinkage())
+ info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF;
+ else
+ info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
+ _undefines[name] = info;
}
@@ -339,16 +351,14 @@ void LTOModule::lazyParseSymbols()
}
// make symbols for all undefines
- for (StringSet::iterator it=_undefines.begin();
+ for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
it != _undefines.end(); ++it) {
// if this symbol also has a definition, then don't make an undefine
// because it is a tentative definition
if ( _defines.count(it->getKeyData(), it->getKeyData()+
it->getKeyLength()) == 0 ) {
- NameAndAttributes info;
- info.name = it->getKeyData();
- info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
- _symbols.push_back(info);
+ NameAndAttributes info = it->getValue();
+ _symbols.push_back(info);
}
}
}