#include <boost/signals2.hpp>
#include <functional>
+#include <string>
class Disassembler;
class Function;
new_function_signal(f);
}
+ boost::signals2::connection
+ connect_new_dyn_symbol_signal(std::function<void(const std::string& name)> f) {
+ return new_dyn_symbol_signal.connect(f);
+ }
+
+ void signal_new_dyn_symbol(const std::string& f) {
+ new_dyn_symbol_signal(f);
+ }
+
boost::signals2::connection
connect_reset_signal(std::function<void ()> f) {
return reset_signal.connect(f);
private:
boost::signals2::signal<void ()> reset_signal;
boost::signals2::signal<void (Function*)> new_function_signal;
+ boost::signals2::signal<void (const std::string& name)> new_dyn_symbol_signal;
std::unique_ptr<Disassembler> disassembler;
};
readSymbols();
readSections();
disassemble();
+ readDynamicSymbols();
}
template <typename ELFT>
}
if (binary->isELF()) {
- typedef ELFFile<ELFT> ELFO;
const ELFO * elffile = o->getELFFile();
const typename ELFO::Elf_Ehdr * header = elffile->getHeader();
}
}
+template <typename ELFT>
+void LLVMDisassembler<ELFT>::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 <typename ELFT>
void LLVMDisassembler<ELFT>::readSymbols() {
error_code ec;
bool isJump(uint64_t address) {return false;}
private:
+ 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 readSymbols();
void readSections();
+ void readDynamicSymbols();
log4cxx::LoggerPtr logger;
std::map<uint64_t, LLVMBasicBlock*> blocks;
setWindowTitle(tr("FRIDA"));
mgr->connect_new_function_signal([&] (Function* fun) {addFunction(fun);});
+ mgr->connect_new_dyn_symbol_signal([&] (const std::string& name) {
+ auto item = new QListWidgetItem(name.c_str(), listWidget);
+ item->setBackground(QBrush(QColor(0xff, 0xdd, 0xdd)));
+ });
}
void Mainwindow::quit()