aboutsummaryrefslogtreecommitdiff
path: root/reference_bytes_mixer.h
diff options
context:
space:
mode:
Diffstat (limited to 'reference_bytes_mixer.h')
-rw-r--r--reference_bytes_mixer.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/reference_bytes_mixer.h b/reference_bytes_mixer.h
index 3cbf187..f20b0ef 100644
--- a/reference_bytes_mixer.h
+++ b/reference_bytes_mixer.h
@@ -11,6 +11,7 @@
#include "components/zucchini/buffer_view.h"
#include "components/zucchini/image_utils.h"
+#include "components/zucchini/rel32_utils.h"
namespace zucchini {
@@ -83,6 +84,35 @@ class ReferenceBytesMixer {
offset_t new_offset);
};
+// In AArch32 and AArch64, instructions mix operation bits and payload bits in
+// complex ways. This is the main use case of ReferenceBytesMixer.
+class ReferenceBytesMixerElfArm : public ReferenceBytesMixer {
+ public:
+ // |exe_type| must be EXE_TYPE_ELF_ARM or EXE_TYPE_ELF_AARCH64.
+ explicit ReferenceBytesMixerElfArm(ExecutableType exe_type);
+ ReferenceBytesMixerElfArm(const ReferenceBytesMixerElfArm&) = delete;
+ const ReferenceBytesMixerElfArm& operator=(const ReferenceBytesMixerElfArm&) =
+ delete;
+ ~ReferenceBytesMixerElfArm() override;
+
+ // ReferenceBytesMixer:
+ int NumBytes(uint8_t type) const override;
+ ConstBufferView Mix(uint8_t type,
+ ConstBufferView old_view,
+ offset_t old_offset,
+ ConstBufferView new_view,
+ offset_t new_offset) override;
+
+ private:
+ ArmCopyDispFun GetCopier(uint8_t type) const;
+
+ // For simplicity, 32-bit vs. 64-bit distinction is represented by state
+ // |exe_type_|, instead of creating derived classes.
+ const ExecutableType exe_type_;
+
+ std::vector<uint8_t> out_buffer_;
+};
+
} // namespace zucchini
#endif // COMPONENTS_ZUCCHINI_REFERENCE_BYTES_MIXER_H_