mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
Implement the GetBytecodeSymbols interface function to extract just the
externally visible defined symbols from a bytecode file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17503 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2394fa99bd
commit
2bcfcbe795
@ -336,6 +336,7 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
|
|||||||
try {
|
try {
|
||||||
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fname));
|
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fname));
|
||||||
Module* M = AMP->releaseModule();
|
Module* M = AMP->releaseModule();
|
||||||
|
|
||||||
deplibs = M->getLibraries();
|
deplibs = M->getLibraries();
|
||||||
delete M;
|
delete M;
|
||||||
return true;
|
return true;
|
||||||
@ -345,4 +346,42 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get just the externally visible defined symbols from the bytecode
|
||||||
|
bool llvm::GetBytecodeSymbols(const sys::Path& fName,
|
||||||
|
std::vector<std::string>& symbols) {
|
||||||
|
try {
|
||||||
|
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fName.get()));
|
||||||
|
|
||||||
|
// Get the module from the provider
|
||||||
|
Module* M = AMP->releaseModule();
|
||||||
|
|
||||||
|
// Loop over global variables
|
||||||
|
for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) {
|
||||||
|
if (GI->hasInitializer()) {
|
||||||
|
std::string name ( GI->getName() );
|
||||||
|
if (!name.empty()) {
|
||||||
|
symbols.push_back(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Loop over functions
|
||||||
|
for (Module::iterator FI = M->begin(), FE=M->end(); FI != FE; ++FI) {
|
||||||
|
if (!FI->isExternal()) {
|
||||||
|
std::string name ( FI->getName() );
|
||||||
|
if (!name.empty()) {
|
||||||
|
symbols.push_back(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done with the module
|
||||||
|
delete M;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// vim: sw=2 ai
|
// vim: sw=2 ai
|
||||||
|
Loading…
Reference in New Issue
Block a user