]> git.siccegge.de Git - frida/frida.git/commitdiff
Get entry address from llvm
authorChristoph Egger <Christoph.Egger@fau.de>
Wed, 21 Jan 2015 12:19:18 +0000 (13:19 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Wed, 21 Jan 2015 12:26:42 +0000 (13:26 +0100)
Replace magic offset + endianess-correction with proper LLVM functions
now that we have the full typed ELF Object available

src/disassembler/llvm/LLVMDisassembler.cxx

index 8dd548332bf4f1f01106cd2020db3b137e13b626..18cfe8065eefc0fb5e409d7978408e50dd47a1b2 100644 (file)
@@ -320,16 +320,11 @@ void LLVMDisassembler<ELFT>::disassemble() {
        }
 
        if (binary->isELF()) {
-               bool is64bit = (binary->getData()[4] == 0x02);
+               typedef ELFFile<ELFT> 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 << ">";