aboutsummaryrefslogtreecommitdiff
path: root/reference_bytes_mixer.cc
diff options
context:
space:
mode:
authorSamuel Huang <huangs@chromium.org>2018-04-20 17:40:00 +0000
committerEdward Lesmes <ehmaldonado@google.com>2021-07-23 22:08:14 +0000
commit451ff5de400706acdfcfdb9bf28ca6d4c0670b81 (patch)
tree59b8f9de7d363363412a8215166a66f4035c8daa /reference_bytes_mixer.cc
parent07c31a327fc75fd62023d1774e900f85ce982ee7 (diff)
downloadzucchini-451ff5de400706acdfcfdb9bf28ca6d4c0670b81.tar.gz
[Zucchini] Introduce ReferenceBytesMixer.
Some architectures (e.g., ARM) have references that mix operation bits with payload bits. ReferenceBytesMixer is a class to isloate operation bit changes to Layer 1 patching. This CL introduces only the stub for ReferenceBytesMixer (the remainder would require ARM support). Having this now brings Zucchini-gen closer to trunk code, and sets up upcoming work for a mock disassembler. Change-Id: I2e1aa56bf265e4b61b33d323be2ed9a456e14f3b Reviewed-on: https://chromium-review.googlesource.com/1021650 Commit-Queue: Samuel Huang <huangs@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/master@{#552373} NOKEYCHECK=True GitOrigin-RevId: fdb4806d8d03c52ffe4ca7b14076f483384eedfb
Diffstat (limited to 'reference_bytes_mixer.cc')
-rw-r--r--reference_bytes_mixer.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/reference_bytes_mixer.cc b/reference_bytes_mixer.cc
new file mode 100644
index 0000000..c0d5ca3
--- /dev/null
+++ b/reference_bytes_mixer.cc
@@ -0,0 +1,48 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/zucchini/reference_bytes_mixer.h"
+
+#include "base/logging.h"
+#include "components/zucchini/disassembler.h"
+
+namespace zucchini {
+
+/******** ReferenceBytesMixer ********/
+
+// Default implementation is a stub, i.e., for architectures whose references
+// have operation bits and payload bits stored in separate bytes. So during
+// patch application, payload bits are copied for matched blocks, ignored by
+// bytewise corrections, and fixed by reference target corrections.
+ReferenceBytesMixer::ReferenceBytesMixer() {}
+
+ReferenceBytesMixer::~ReferenceBytesMixer() = default;
+
+// static.
+std::unique_ptr<ReferenceBytesMixer> ReferenceBytesMixer::Create(
+ const Disassembler& src_dis,
+ const Disassembler& dst_dis) {
+ ExecutableType exe_type = src_dis.GetExeType();
+ DCHECK_EQ(exe_type, dst_dis.GetExeType());
+ // TODO(huangs): Add ARM handling code when ARM is ready.
+ return std::make_unique<ReferenceBytesMixer>();
+}
+
+// Stub implementation.
+int ReferenceBytesMixer::NumBytes(uint8_t type) const {
+ return 0;
+}
+
+// Base class implementation is a stub that should not be called.
+ConstBufferView ReferenceBytesMixer::Mix(
+ uint8_t type,
+ ConstBufferView::const_iterator old_base,
+ offset_t old_offset,
+ ConstBufferView::const_iterator new_base,
+ offset_t new_offset) {
+ NOTREACHED() << "Stub.";
+ return ConstBufferView();
+}
+
+} // namespace zucchini