-
huangs authored
This is the main CL of the AssemblyProgram reduction effort, which makes Disassembler emit instructions directly to EncodedProgram, and bypass AssemblyProgram, which becomes a holder of LabelManager and Label Annotation. Another big change is that Disassembler usage is exposed to high-level flows (rather than having it hidden inside ParseDetectedExecutable*()). Details: - Remove ParseDetectedExecutable*() and expose DetectDisassembler(). - AssemblyProgram: Remove: - Entire Instruction class hierarchy. - Allocated instruction in the heap (including preallocated DEFBYTE instances). - enum OP {}, which duplicates EncodedProgram::OP. - InstructionVector of pointers, which takes 100's of MB on disk. - Encode() interface. - AssemblyProgram: Add: - AnnotateLabels() to generate Label Annotation directly from a generator (injected by Disassembler), using LabelReceptor template class for counting and storage. - PrepareEncodedProgram() to inject data needed (e.g., Label) to EncodedProgram. - Disassembler: Disassemble() is split into CreateProgram() and DisassembleAndEncode(). - EncodedProgram: Old AssemblyProgram::Encode() code now moved to InstructionStoreReceptor. New GenerateInstruction() is added to receive generator from Disassemblyprogram. - CourgetteFlow: Disassembler explicitly managed: - Remove ReadAssemblyProgramFromBuffer(). - Add ReadDisassemblerFromBuffer(). - Add CreateEncodedProgramFromDisassemblerAndAssemblyProgram(). - High-level flows in courgette_tool.cc, patch_generator_x86_32.h, patcher_x86_32.h: Using new more complex flow that involves Disassembler; using ASCII graphics in comment to illustrate. - Unit tests updates. Documentation update will be done in a follow-up. BUG=660980 Review-Url: https://codereview.chromium.org/2854113002 Cr-Commit-Position: refs/heads/master@{#472907}
88451332