]> git.siccegge.de Git - frida/frida.git/commitdiff
Fallbacks if we do not have symbols
authorChristoph Egger <christoph@anonymous.siccegge.de>
Sun, 7 Dec 2014 16:54:04 +0000 (17:54 +0100)
committerChristoph Egger <christoph@anonymous.siccegge.de>
Sun, 7 Dec 2014 16:54:04 +0000 (17:54 +0100)
try to use the ELF entry address or start of .text

src/disassembler/llvm/LLVMDisassembler.cxx

index 8837239ca74d6b671613cfa1240a94c7f0fd71f2..1ae024a5aea39f9ef6dd786e3933768e8cc6cf5c 100644 (file)
@@ -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 << "<Unnamed 0x" << std::hex << text_entry << ">";
+        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);