X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fdisassembler%2Fllvm%2FLLVMDisassembler.cxx;h=d2c68fdce4f4f48f803c90726a2707565007d8fc;hp=18cfe8065eefc0fb5e409d7978408e50dd47a1b2;hb=d5084161ca261d7fc0bd284621569440b6503eac;hpb=c862852c36741e1be13abff538e526114e3d828c diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 18cfe80..d2c68fd 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -1,6 +1,7 @@ #include "disassembler/llvm/LLVMDisassembler.hxx" #include "disassembler/llvm/LLVMBasicBlock.hxx" #include "disassembler/llvm/LLVMFunction.hxx" +#include "core/InformationManager.hxx" #include #include @@ -156,18 +157,19 @@ void LLVMDisassembler::start() { readSymbols(); readSections(); disassemble(); + readDynamicSymbols(); } template LLVMDisassembler::~LLVMDisassembler() { - std::for_each(functions.begin(), functions.end(), - [](std::pair it) { - delete it.second; - }); - std::for_each(blocks.begin(), blocks.end(), - [](std::pair it) { - delete it.second; - }); + // std::for_each(functions.begin(), functions.end(), + // [](std::pair it) { + // delete it.second; + // }); + // std::for_each(blocks.begin(), blocks.end(), + // [](std::pair it) { + // delete it.second; + // }); } template @@ -320,7 +322,6 @@ void LLVMDisassembler::disassemble() { } if (binary->isELF()) { - typedef ELFFile ELFO; const ELFO * elffile = o->getELFFile(); const typename ELFO::Elf_Ehdr * header = elffile->getHeader(); @@ -389,6 +390,25 @@ void LLVMDisassembler::splitBlocks(LLVMFunction* function) { } } +template +void LLVMDisassembler::readDynamicSymbols() { + const ELFO * elffile = o->getELFFile(); + for (typename ELFO::Elf_Sym_Iter + it = elffile->begin_dynamic_symbols(), + end = elffile->end_dynamic_symbols(); + it != end; + ++it) { + if (it->getType() == 2) { // Function + bool is_default; + // TODO: Error handling + std::string symbolname = *(elffile->getSymbolName(it)); + std::string symbolversion = *(elffile->getSymbolVersion(nullptr, &*it, is_default)); + manager->signal_new_dyn_symbol(symbolname + (is_default? "@@" : "@") + symbolversion); + LOG4CXX_DEBUG(logger, "Adding dynamic Symbol " << symbolname << (is_default? "@@" : "@") << symbolversion); + } + } +} + template void LLVMDisassembler::readSymbols() { error_code ec;