From: Christoph Egger Date: Sun, 8 Dec 2013 20:57:00 +0000 (+0100) Subject: Handle case with no known functions properl X-Git-Tag: v0.1~229 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=e32adfb77bd16a36a4baae8b38c32fd94b61572e;p=frida%2Ffrida.git Handle case with no known functions properl --- diff --git a/src/Binary.cxx b/src/Binary.cxx index 83909a0..1fcd908 100644 --- a/src/Binary.cxx +++ b/src/Binary.cxx @@ -187,22 +187,36 @@ namespace qtlldb { void Binary::for_each_instruction(const std::string& function, std::function callback) { StringRef bytes; - SymbolRef ref = symbols[function]; - section_iterator sec(o->begin_sections()); uint64_t base_address, address, ssize, size(0), index, end; + StringRefMemoryObject memoryObject(""); - // outs() << "Start for_each_instruction " << function << "\n"; + if (symbols.end() != symbols.find(function)) { + SymbolRef ref; + section_iterator sec(o->begin_sections()); + + ref = symbols.at(function); + if (error(ref.getSection(sec))) return; + if (error(ref.getAddress(address))) return; + if (address == UnknownAddressOrSize) return; + if (error(ref.getSize(ssize))) return; + if (error(sec->getAddress(base_address))) return; + if (error(sec->getContents(bytes))) return; + memoryObject = bytes; + + } + else if (sections.end() != sections.find(function)) { + SectionRef sref = sections.at(function); + if (error(sref.getAddress(address))) return; + if (address == UnknownAddressOrSize) return; + if (error(sref.getSize(ssize))) return; + if (error(sref.getContents(bytes))) return; + base_address = address; + memoryObject = bytes; + } - if (error(ref.getSection(sec))) return; - if (error(ref.getAddress(address))) return; - if (address == UnknownAddressOrSize) return; - if (error(ref.getSize(ssize))) return; - if (error(sec->getAddress(base_address))) return; - if (error(sec->getContents(bytes))) return; - // outs() << "Middle for_each_instruction " << function << " Size: " << ssize << "\n"; + // outs() << "Start for_each_instruction " << function << "\n"; - StringRefMemoryObject memoryObject(bytes); for (end = address + ssize - base_address, index = address - base_address; index < end; index += size) { MCInst Inst;