Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Unified Diff: courgette/disassembler.h

Issue 2771753004: [Courgette] Refactor: Unify Disassembler::Disassemble() and instantiate AssemblyProgram there. (Closed)
Patch Set: Fix signed/unsigned comparison issue in test. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/assembly_program.cc ('k') | courgette/disassembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/disassembler.h
diff --git a/courgette/disassembler.h b/courgette/disassembler.h
index ff2dd692a08c467da00a90ba359ebc0f385f3204..379a75aa376a745fb0521a7a264145643fac09e2 100644
--- a/courgette/disassembler.h
+++ b/courgette/disassembler.h
@@ -7,11 +7,13 @@
#include <stdint.h>
+#include <memory>
#include <vector>
#include "base/macros.h"
#include "courgette/courgette.h"
#include "courgette/image_utils.h"
+#include "courgette/instruction_utils.h"
namespace courgette {
@@ -66,6 +68,12 @@ class Disassembler : public AddressTranslator {
// general case of 64-bit architectures.
virtual uint64_t image_base() const = 0;
+ // Extracts and stores locations of abs32 references from the image file.
+ virtual bool ExtractAbs32Locations() = 0;
+
+ // Extracts and stores locations of rel32 references from the image file.
+ virtual bool ExtractRel32Locations() = 0;
+
// Returns a caller-owned new RvaVisitor to iterate through abs32 target RVAs.
virtual RvaVisitor* CreateAbs32TargetRvaVisitor() = 0;
@@ -74,16 +82,18 @@ class Disassembler : public AddressTranslator {
// Removes unused rel32 locations (architecture-specific). This is needed
// because we may remove rel32 Labels along the way. As a result the matching
- // matching rel32 addresses become unused. Removing them saves space.
+ // rel32 addresses become unused. Removing them saves space.
virtual void RemoveUnusedRel32Locations(AssemblyProgram* program) = 0;
- // Returns true if the buffer appears to be a valid executable of the expected
- // type, and false otherwise. This needs not be called before Disassemble().
+ // Extracts structural data from the main image. Returns true if the image
+ // appears to be a valid executable of the expected type, or false otherwise.
+ // This needs to be called before Disassemble().
virtual bool ParseHeader() = 0;
- // Disassembles the item passed to the factory method into the output
- // parameter 'program'.
- virtual bool Disassemble(AssemblyProgram* program) = 0;
+ // Extracts and stores references from the main image. Returns a new
+ // AssemblyProgram initialized using data parsed from the main image, or null
+ // on failure.
+ std::unique_ptr<AssemblyProgram> Disassemble();
// ok() may always be called but returns true only after ParseHeader()
// succeeds.
@@ -112,6 +122,11 @@ class Disassembler : public AddressTranslator {
// (or realloc) any memory. Usually only called via ParseHeader().
void ReduceLength(size_t reduced_length);
+ // Returns a generator that emits instructions to a given receptor. |program|
+ // is required as helper.
+ virtual InstructionGenerator GetInstructionGenerator(
+ AssemblyProgram* program) = 0;
+
private:
const char* failure_reason_;
« no previous file with comments | « courgette/assembly_program.cc ('k') | courgette/disassembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698