aboutsummaryrefslogtreecommitdiff
path: root/ensemble_matcher.cc
diff options
context:
space:
mode:
authorEtienne Pierre-Doray <etiennep@chromium.org>2018-03-29 13:33:46 +0000
committerEdward Lesmes <ehmaldonado@google.com>2021-07-23 22:01:43 +0000
commitfff1ca312c453481375168c8b0d40a42c45a47cb (patch)
tree23179def1757048931d08e8b820d1139736cc249 /ensemble_matcher.cc
parent1a73d78bea5b940a8f5499e31ad9794d9aa7d475 (diff)
downloadzucchini-fff1ca312c453481375168c8b0d40a42c45a47cb.tar.gz
[Zucchini] Create dex disassembler.
Creates Disassembler that recognises and parses DEX format. For now, it doesn't extract any type reference, so it is equivalent to DisassemblerNoOp. Extraction of various types of reference will be added in a follow-up CL. BufferView::covers_array() and unittests were also added. Change-Id: I08756244e9af899cf0f40dabd2b0059e1749328e Reviewed-on: https://chromium-review.googlesource.com/967603 Reviewed-by: Samuel Huang <huangs@chromium.org> Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Cr-Commit-Position: refs/heads/master@{#546807} NOKEYCHECK=True GitOrigin-RevId: d214e2cf9e23bf055f0e0655e9564761d50206ad
Diffstat (limited to 'ensemble_matcher.cc')
-rw-r--r--ensemble_matcher.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/ensemble_matcher.cc b/ensemble_matcher.cc
index eebbae9..37a7af9 100644
--- a/ensemble_matcher.cc
+++ b/ensemble_matcher.cc
@@ -4,6 +4,7 @@
#include "components/zucchini/ensemble_matcher.h"
+#include <algorithm>
#include <limits>
#include "base/logging.h"
@@ -18,7 +19,21 @@ EnsembleMatcher::EnsembleMatcher() = default;
EnsembleMatcher::~EnsembleMatcher() = default;
void EnsembleMatcher::Trim() {
- // TODO(huangs): Add MultiDex handling logic when we add DEX support.
+ // Trim rule: If > 1 DEX files are found then ignore all DEX. This is done
+ // because we do not yet support MultiDex, under which contents can move
+ // across file boundary between "old" and "new" archives. When this occurs,
+ // forcing matches of DEX files and patching them separately can result in
+ // larger patches than naive patching.
+ auto is_match_dex = [](const ElementMatch& match) {
+ return match.exe_type() == kExeTypeDex;
+ };
+ auto num_dex = std::count_if(matches_.begin(), matches_.end(), is_match_dex);
+ if (num_dex > 1) {
+ LOG(WARNING) << "Found " << num_dex << " DEX: Ignoring all.";
+ matches_.erase(
+ std::remove_if(matches_.begin(), matches_.end(), is_match_dex),
+ matches_.end());
+ }
}
} // namespace zucchini