From: Christoph Egger Date: Wed, 21 Jan 2015 12:19:18 +0000 (+0100) Subject: Get entry address from llvm X-Git-Tag: v0.1~123 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=c862852c36741e1be13abff538e526114e3d828c;p=frida%2Ffrida.git Get entry address from llvm Replace magic offset + endianess-correction with proper LLVM functions now that we have the full typed ELF Object available --- diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 8dd5483..18cfe80 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -320,16 +320,11 @@ void LLVMDisassembler::disassemble() { } if (binary->isELF()) { - bool is64bit = (binary->getData()[4] == 0x02); + typedef ELFFile ELFO; + const ELFO * elffile = o->getELFFile(); + const typename ELFO::Elf_Ehdr * header = elffile->getHeader(); - for (int i(0); i < (is64bit? 8 : 4); ++i) { - if (binary->isLittleEndian()) { - _entryAddress |= (unsigned int)((unsigned char)binary->getData()[0x18 + i]) << 8*i; - } else { - _entryAddress = _entryAddress << 8; - _entryAddress |= (unsigned char)binary->getData()[0x18 + i]; - } - } + _entryAddress = header->e_entry; LOG4CXX_DEBUG(logger, "Adding entryAddress at: " << std::hex << _entryAddress); std::stringstream s; s << "<_start 0x" << std::hex << _entryAddress << ">";