mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-24 08:33:39 +00:00
Add wrappers to get defined symbols from bytecode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17770 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d3539b8a5e
commit
565ff3d448
@ -346,15 +346,8 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get just the externally visible defined symbols from the bytecode
|
namespace {
|
||||||
bool llvm::GetBytecodeSymbols(const sys::Path& fName,
|
void getSymbols(Module*M, std::vector<std::string>& symbols) {
|
||||||
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
|
// Loop over global variables
|
||||||
for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) {
|
for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) {
|
||||||
if (GI->hasInitializer()) {
|
if (GI->hasInitializer()) {
|
||||||
@ -374,6 +367,20 @@ bool llvm::GetBytecodeSymbols(const sys::Path& 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();
|
||||||
|
|
||||||
|
// Get the symbols
|
||||||
|
getSymbols(M, symbols);
|
||||||
|
|
||||||
// Done with the module
|
// Done with the module
|
||||||
delete M;
|
delete M;
|
||||||
@ -384,4 +391,26 @@ bool llvm::GetBytecodeSymbols(const sys::Path& fName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length,
|
||||||
|
const std::string& ModuleID,
|
||||||
|
std::vector<std::string>& symbols) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
std::auto_ptr<ModuleProvider>
|
||||||
|
AMP(getBytecodeBufferModuleProvider(Buffer, Length, ModuleID));
|
||||||
|
|
||||||
|
// Get the module from the provider
|
||||||
|
Module* M = AMP->releaseModule();
|
||||||
|
|
||||||
|
// Get the symbols
|
||||||
|
getSymbols(M, symbols);
|
||||||
|
|
||||||
|
// Done with the module
|
||||||
|
delete M;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// vim: sw=2 ai
|
// vim: sw=2 ai
|
||||||
|
Loading…
x
Reference in New Issue
Block a user