mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
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
This commit is contained in:
@@ -30,6 +30,7 @@ typedef enum {
|
|||||||
LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200,
|
LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200,
|
||||||
LTO_SYMBOL_DEFINITION_WEAK = 0x00000300,
|
LTO_SYMBOL_DEFINITION_WEAK = 0x00000300,
|
||||||
LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400,
|
LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400,
|
||||||
|
LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500,
|
||||||
LTO_SYMBOL_SCOPE_MASK = 0x00003800,
|
LTO_SYMBOL_SCOPE_MASK = 0x00003800,
|
||||||
LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800,
|
LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800,
|
||||||
LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000,
|
LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000,
|
||||||
|
@@ -257,6 +257,9 @@ ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
|
|||||||
case LTO_SYMBOL_DEFINITION_WEAK:
|
case LTO_SYMBOL_DEFINITION_WEAK:
|
||||||
sym.def = LDPK_WEAKDEF;
|
sym.def = LDPK_WEAKDEF;
|
||||||
break;
|
break;
|
||||||
|
case LTO_SYMBOL_DEFINITION_WEAKUNDEF:
|
||||||
|
sym.def = LDPK_WEAKUNDEF;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
(*message)(LDPL_ERROR, "Unknown definition attribute: %d", definition);
|
(*message)(LDPL_ERROR, "Unknown definition attribute: %d", definition);
|
||||||
return LDPS_ERR;
|
return LDPS_ERR;
|
||||||
|
@@ -258,9 +258,21 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
|
|||||||
{
|
{
|
||||||
const char* name = mangler.getValueName(decl).c_str();
|
const char* name = mangler.getValueName(decl).c_str();
|
||||||
// ignore all llvm.* symbols
|
// ignore all llvm.* symbols
|
||||||
if ( strncmp(name, "llvm.", 5) != 0 ) {
|
if ( strncmp(name, "llvm.", 5) == 0 )
|
||||||
_undefines[name] = 1;
|
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
|
// make symbols for all undefines
|
||||||
for (StringSet::iterator it=_undefines.begin();
|
for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
|
||||||
it != _undefines.end(); ++it) {
|
it != _undefines.end(); ++it) {
|
||||||
// if this symbol also has a definition, then don't make an undefine
|
// if this symbol also has a definition, then don't make an undefine
|
||||||
// because it is a tentative definition
|
// because it is a tentative definition
|
||||||
if ( _defines.count(it->getKeyData(), it->getKeyData()+
|
if ( _defines.count(it->getKeyData(), it->getKeyData()+
|
||||||
it->getKeyLength()) == 0 ) {
|
it->getKeyLength()) == 0 ) {
|
||||||
NameAndAttributes info;
|
NameAndAttributes info = it->getValue();
|
||||||
info.name = it->getKeyData();
|
_symbols.push_back(info);
|
||||||
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
|
|
||||||
_symbols.push_back(info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ private:
|
|||||||
std::vector<NameAndAttributes> _symbols;
|
std::vector<NameAndAttributes> _symbols;
|
||||||
// _defines and _undefines only needed to disambiguate tentative definitions
|
// _defines and _undefines only needed to disambiguate tentative definitions
|
||||||
StringSet _defines;
|
StringSet _defines;
|
||||||
StringSet _undefines;
|
llvm::StringMap<NameAndAttributes> _undefines;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::string getFeatureString(const char *TargetTriple);
|
extern std::string getFeatureString(const char *TargetTriple);
|
||||||
|
Reference in New Issue
Block a user