#include "disassembler/llvm/LLVMDisassembler.hxx"
#include "disassembler/llvm/LLVMBasicBlock.hxx"
-#include "disassembler/llvm/LLVMFunction.hxx"
#include "core/InformationManager.hxx"
+#include "core/Function.hxx"
#include <stack>
#include <algorithm>
return functions[address];
}
- LLVMFunction * function;
+ Function * function;
if (name == "") {
std::stringstream s;
s << "<Unnamed 0x" << std::hex << address << ">";
- function = new LLVMFunction(s.str(), address);
+ function = new Function(s.str(), address);
} else {
- function = new LLVMFunction(name, address);
+ function = new Function(name, address);
}
functions.insert(std::make_pair(address, function));
}
template <typename ELFT>
-void LLVMDisassembler<ELFT>::disassembleFunction(LLVMFunction* function) {
+void LLVMDisassembler<ELFT>::disassembleFunction(Function* function) {
std::stack<LLVMBasicBlock*> remaining_blocks;
SectionRef text_section = sections[".text"];
StringRef bytes;
template <typename ELFT>
void LLVMDisassembler<ELFT>::disassemble() {
SectionRef text_section = sections[".text"];
- std::vector<LLVMFunction*> remaining_functions;
+ std::vector<Function*> remaining_functions;
// Assume all function symbols actually start a real function
for (auto x = symbols.begin(); x != symbols.end(); ++x) {
continue;
if (!x->second.getAddress(result)) {
- LLVMFunction * fun = new LLVMFunction(x->first, result);
+ Function * fun = new Function(x->first, result);
remaining_functions.push_back(fun);
functions.insert(std::make_pair(result, fun));
LOG4CXX_DEBUG(logger, "Disasembling " << x->first);
}
}
- for (LLVMFunction* function : remaining_functions) {
+ for (Function* function : remaining_functions) {
disassembleFunction(function);
}
}
template <typename ELFT>
-void LLVMDisassembler<ELFT>::splitBlocks(LLVMFunction* function) {
+void LLVMDisassembler<ELFT>::splitBlocks(Function* function) {
SectionRef text_section = sections[".text"];
StringRef bytes;
text_section.getContents(bytes);
template <typename ELFT>
void LLVMDisassembler<ELFT>::forEachFunction(std::function<void (uint64_t, Function*)> callback) {
std::for_each(functions.begin(), functions.end(),
- [&](std::pair<uint64_t, LLVMFunction*> x) {
+ [&](std::pair<uint64_t, Function*> x) {
callback(x.first, x.second);
});
}
class Function;
class BasicBlock;
-class LLVMFunction;
class LLVMBasicBlock;
Disassembler * createLLVMDisassembler(const std::string& filename, InformationManager* manager);
typedef llvm::object::ELFFile<ELFT> ELFO;
// http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197
- void disassembleFunction(LLVMFunction* function);
- void splitBlocks(LLVMFunction* fun);
+ void disassembleFunction(Function* function);
+ void splitBlocks(Function* fun);
void disassemble();
void readSymbols();
log4cxx::LoggerPtr logger;
std::map<uint64_t, LLVMBasicBlock*> blocks;
- std::map<uint64_t, LLVMFunction*> functions;
+ std::map<uint64_t, Function*> functions;
llvm::Triple triple;
std::shared_ptr<llvm::object::Binary> binary;