From c862852c36741e1be13abff538e526114e3d828c Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Wed, 21 Jan 2015 13:19:18 +0100 Subject: [PATCH] Get entry address from llvm Replace magic offset + endianess-correction with proper LLVM functions now that we have the full typed ELF Object available --- src/disassembler/llvm/LLVMDisassembler.cxx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 << ">"; -- 2.39.5