From: Christoph Egger Date: Sun, 7 Dec 2014 16:54:04 +0000 (+0100) Subject: Fallbacks if we do not have symbols X-Git-Tag: v0.1~157 X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=commitdiff_plain;h=70d986e452c08aea59d947bfd5700f6c60b3f820 Fallbacks if we do not have symbols try to use the ELF entry address or start of .text --- diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 8837239..1ae024a 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -155,6 +155,40 @@ void LLVMDisassembler::disassemble() { } } + if (binary->isELF()) { + bool is64bit = (binary->getData()[4] == 0x02); + + uint64_t entry(0); + for (int i(0); i < (is64bit? 8 : 4); ++i) { + if (binary->isLittleEndian()) { + entry |= (unsigned int)((unsigned char)binary->getData()[0x18 + i]) << 8*i; + } else { + entry = entry << 8; + entry |= (unsigned char)binary->getData()[0x18 + i]; + } + } + if (functions.find(entry) == functions.end()) { + LOG4CXX_DEBUG(logger, "Adding entry at: " << std::hex << entry); + std::stringstream s; + s << "<_start 0x" << std::hex << entry << ">"; + LLVMFunction * fun = new LLVMFunction(s.str(), entry); + functions.insert(std::make_pair(entry, fun)); + remaining_functions.push(fun); + } + } + + if (functions.empty()) { + uint64_t text_entry; + text_section.getAddress(text_entry); + LOG4CXX_INFO(logger, "No Symbols found, starting at the beginning of the text segment"); + + std::stringstream s; + s << ""; + LLVMFunction * fun = new LLVMFunction(s.str(), text_entry); + functions.insert(std::make_pair(text_entry, fun)); + remaining_functions.push(fun); + } + StringRef bytes; text_section.getContents(bytes); StringRefMemoryObject ref(bytes);