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

Unified Diff: courgette/disassembler_elf_32.h

Issue 1935203002: [Courgette] Using LabelManager to reduce Courgette-apply peak RAM by 25%. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: courgette/disassembler_elf_32.h
diff --git a/courgette/disassembler_elf_32.h b/courgette/disassembler_elf_32.h
index 8793106957283890b19a70da4ba061410f4d6478..a5f580060247240841632e4d9b78fffbfab1bfd5 100644
--- a/courgette/disassembler_elf_32.h
+++ b/courgette/disassembler_elf_32.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <string>
#include <vector>
#include "base/macros.h"
@@ -53,9 +54,9 @@ class DisassemblerElf32 : public Disassembler {
// Computes the relative jump's offset from the op in p.
virtual CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) = 0;
- // Emits the courgette instruction corresponding to the RVA type.
+ // Emits the assembly instruction corresponding to |label|.
virtual CheckBool EmitInstruction(AssemblyProgram* program,
- RVA target_rva) = 0;
+ Label* label) = 0;
// Returns the size of the instruction containing the RVA.
virtual uint16_t op_size() const = 0;
@@ -76,6 +77,20 @@ class DisassemblerElf32 : public Disassembler {
FileOffset file_offset_ = kNoFileOffset;
};
+ // Visitor/adaptor to translate RVA to target RVA. This is the ELF
+ // counterpart to RvaVisitor_Rel32 that uses TypedRVA.
+ class Elf32RvaVisitor_Rel32 : public VectorRvaVisitor<TypedRVA*> {
+ public:
+ Elf32RvaVisitor_Rel32(const std::vector<TypedRVA*>& rva_locations);
+ ~Elf32RvaVisitor_Rel32() override { }
+
+ // VectorRvaVisitor<TypedRVA*> interfaces.
+ RVA Get() const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Elf32RvaVisitor_Rel32);
+ };
+
public:
DisassemblerElf32(const void* start, size_t length);
@@ -91,6 +106,12 @@ class DisassemblerElf32 : public Disassembler {
virtual e_machine_values ElfEM() const = 0;
+ CheckBool IsValidTargetRVA(RVA rva) const WARN_UNUSED_RESULT;
+
+ // Converts an ELF relocation instruction into an RVA.
+ virtual CheckBool RelToRVA(Elf32_Rel rel, RVA* result)
+ const WARN_UNUSED_RESULT = 0;
+
// Public for unittests only
std::vector<RVA> &Abs32Locations() { return abs32_locations_; }
ScopedVector<TypedRVA> &Rel32Locations() { return rel32_locations_; }
@@ -130,12 +151,6 @@ class DisassemblerElf32 : public Disassembler {
// Misc address space helpers
- CheckBool IsValidTargetRVA(RVA rva) const WARN_UNUSED_RESULT;
-
- // Converts an ELF relocation instruction into an RVA.
- virtual CheckBool RelToRVA(Elf32_Rel rel, RVA* result)
- const WARN_UNUSED_RESULT = 0;
-
CheckBool RVAsToFileOffsets(const std::vector<RVA>& rvas,
std::vector<FileOffset>* file_offsets);
@@ -150,6 +165,11 @@ class DisassemblerElf32 : public Disassembler {
virtual CheckBool ParseRel32RelocsFromSection(const Elf32_Shdr* section)
WARN_UNUSED_RESULT = 0;
+ // Disassembler interfaces.
+ RvaVisitor* CreateAbs32TargetRvaVisitor() override;
+ RvaVisitor* CreateRel32TargetRvaVisitor() override;
+ void RemoveUnusedRel32Locations(AssemblyProgram* program) override;
+
CheckBool ParseFile(AssemblyProgram* target) WARN_UNUSED_RESULT;
CheckBool ParseProgbitsSection(

Powered by Google App Engine
This is Rietveld 408576698