diff options
author | Samuel Huang <huangs@chromium.org> | 2021-06-01 18:29:53 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-07-25 21:31:30 -0700 |
commit | 1cec5a775590551e3c9f950afad3d95a6f6d950f (patch) | |
tree | 477daf9630e47b99f77dfe41fc357d6a0a940118 /address_translator.h | |
parent | 77468dc8869df3f7f7d56081c0c661f66554f9b2 (diff) | |
download | zucchini-1cec5a775590551e3c9f950afad3d95a6f6d950f.tar.gz |
[Zucchini] Simplify Abs32GapFinder and Rel32Finder.
Previously, using Abs32GapFinder / Rel32Finder to visit gaps / rel32
references involves calling a getter that returns an optional<> value
whose emptiness indicates end of iteration. The code to use this looks
like:
for (auto value = finder.GetNext(); value; value = finder.GetNext()) {
...
}
This CL abandons optional<> usage and caches the results in Finders,
thereby removing repetition in iteration code:
while (finder.FindNext() {
auto value = finder.GetValue();
...
}
Additional changes:
* Incorporate AddressTranslator into Rel32Finder to offload translation
work from callers.
* Add tests to integrate Abs32GapFinder with Rel32Finder.
* Stylize test data to better show overlap between abs32 references
with disassembled test data.
Bug: 918867
Change-Id: Id044b67550f81c3f46ab383c5b6200906f56ca4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2918113
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#888049}
NOKEYCHECK=True
GitOrigin-RevId: 89023e1c511e599e6aeaf0b8d80e3efa2e730b5b
Diffstat (limited to 'address_translator.h')
-rw-r--r-- | address_translator.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/address_translator.h b/address_translator.h index 5666b99..a517a2c 100644 --- a/address_translator.h +++ b/address_translator.h @@ -10,7 +10,6 @@ #include <tuple> #include <vector> -#include "base/macros.h" #include "components/zucchini/algorithm.h" #include "components/zucchini/image_utils.h" @@ -114,14 +113,14 @@ class AddressTranslator { // Embeds |translator| for use. Now object lifetime is tied to |translator| // lifetime. explicit OffsetToRvaCache(const AddressTranslator& translator); + OffsetToRvaCache(const OffsetToRvaCache&) = delete; + const OffsetToRvaCache& operator=(const OffsetToRvaCache&) = delete; rva_t Convert(offset_t offset) const; private: const AddressTranslator& translator_; mutable const AddressTranslator::Unit* cached_unit_ = nullptr; - - DISALLOW_COPY_AND_ASSIGN(OffsetToRvaCache); }; // An adaptor for AddressTranslator::RvaToOffset() that caches the last Unit @@ -131,6 +130,8 @@ class AddressTranslator { // Embeds |translator| for use. Now object lifetime is tied to |translator| // lifetime. explicit RvaToOffsetCache(const AddressTranslator& translator); + RvaToOffsetCache(const RvaToOffsetCache&) = delete; + const RvaToOffsetCache& operator=(const RvaToOffsetCache&) = delete; bool IsValid(rva_t rva) const; @@ -139,8 +140,6 @@ class AddressTranslator { private: const AddressTranslator& translator_; mutable const AddressTranslator::Unit* cached_unit_ = nullptr; - - DISALLOW_COPY_AND_ASSIGN(RvaToOffsetCache); }; enum Status { @@ -152,6 +151,9 @@ class AddressTranslator { }; AddressTranslator(); + AddressTranslator(AddressTranslator&&); + AddressTranslator(const AddressTranslator&) = delete; + const AddressTranslator& operator=(const AddressTranslator&) = delete; ~AddressTranslator(); // Consumes |units| to populate data in this class. Performs consistency @@ -190,8 +192,6 @@ class AddressTranslator { // Conversion factor to translate between dangling RVAs and fake offsets. offset_t fake_offset_begin_; - - DISALLOW_COPY_AND_ASSIGN(AddressTranslator); }; } // namespace zucchini |