parent
5657e7b667
commit
919660b2ed
|
|
@ -420,65 +420,66 @@ void LTOModule::findExternalRefs(Value *value, Mangler &mangler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTOModule::lazyParseSymbols() {
|
void LTOModule::lazyParseSymbols() {
|
||||||
if (!_symbolsParsed) {
|
if (_symbolsParsed)
|
||||||
_symbolsParsed = true;
|
return;
|
||||||
|
|
||||||
// Use mangler to add GlobalPrefix to names to match linker names.
|
_symbolsParsed = true;
|
||||||
MCContext Context(*_target->getMCAsmInfo());
|
|
||||||
Mangler mangler(Context, *_target->getTargetData());
|
|
||||||
|
|
||||||
// add functions
|
// Use mangler to add GlobalPrefix to names to match linker names.
|
||||||
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
|
MCContext Context(*_target->getMCAsmInfo());
|
||||||
if (f->isDeclaration())
|
Mangler mangler(Context, *_target->getTargetData());
|
||||||
addPotentialUndefinedSymbol(f, mangler);
|
|
||||||
else
|
|
||||||
addDefinedFunctionSymbol(f, mangler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add data
|
// add functions
|
||||||
for (Module::global_iterator v = _module->global_begin(),
|
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
|
||||||
e = _module->global_end(); v != e; ++v) {
|
if (f->isDeclaration())
|
||||||
if (v->isDeclaration())
|
addPotentialUndefinedSymbol(f, mangler);
|
||||||
addPotentialUndefinedSymbol(v, mangler);
|
else
|
||||||
else
|
addDefinedFunctionSymbol(f, mangler);
|
||||||
addDefinedDataSymbol(v, mangler);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// add asm globals
|
// add data
|
||||||
const std::string &inlineAsm = _module->getModuleInlineAsm();
|
for (Module::global_iterator v = _module->global_begin(),
|
||||||
const std::string glbl = ".globl";
|
e = _module->global_end(); v != e; ++v) {
|
||||||
std::string asmSymbolName;
|
if (v->isDeclaration())
|
||||||
std::string::size_type pos = inlineAsm.find(glbl, 0);
|
addPotentialUndefinedSymbol(v, mangler);
|
||||||
while (pos != std::string::npos) {
|
else
|
||||||
// eat .globl
|
addDefinedDataSymbol(v, mangler);
|
||||||
pos = pos + 6;
|
}
|
||||||
|
|
||||||
// skip white space between .globl and symbol name
|
// add asm globals
|
||||||
std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos);
|
const std::string &inlineAsm = _module->getModuleInlineAsm();
|
||||||
if (pbegin == std::string::npos)
|
const std::string glbl = ".globl";
|
||||||
break;
|
std::string asmSymbolName;
|
||||||
|
std::string::size_type pos = inlineAsm.find(glbl, 0);
|
||||||
|
while (pos != std::string::npos) {
|
||||||
|
// eat .globl
|
||||||
|
pos = pos + 6;
|
||||||
|
|
||||||
// find end-of-line
|
// skip white space between .globl and symbol name
|
||||||
std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin);
|
std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos);
|
||||||
if (pend == std::string::npos)
|
if (pbegin == std::string::npos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin);
|
// find end-of-line
|
||||||
addAsmGlobalSymbol(asmSymbolName.c_str());
|
std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin);
|
||||||
|
if (pend == std::string::npos)
|
||||||
|
break;
|
||||||
|
|
||||||
// search next .globl
|
asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin);
|
||||||
pos = inlineAsm.find(glbl, pend);
|
addAsmGlobalSymbol(asmSymbolName.c_str());
|
||||||
}
|
|
||||||
|
|
||||||
// make symbols for all undefines
|
// search next .globl
|
||||||
for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
|
pos = inlineAsm.find(glbl, pend);
|
||||||
it != _undefines.end(); ++it) {
|
}
|
||||||
// if this symbol also has a definition, then don't make an undefine
|
|
||||||
// because it is a tentative definition
|
// make symbols for all undefines
|
||||||
if (_defines.count(it->getKey()) == 0) {
|
for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
|
||||||
NameAndAttributes info = it->getValue();
|
it != _undefines.end(); ++it) {
|
||||||
_symbols.push_back(info);
|
// if this symbol also has a definition, then don't make an undefine
|
||||||
}
|
// because it is a tentative definition
|
||||||
|
if (_defines.count(it->getKey()) == 0) {
|
||||||
|
NameAndAttributes info = it->getValue();
|
||||||
|
_symbols.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue