aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock58
-rw-r--r--Cargo.toml5
-rw-r--r--src/main.rs94
3 files changed, 53 insertions, 104 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fdbb538..8b7f6c0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -357,12 +357,6 @@ dependencies = [
]
[[package]]
-name = "take_mut"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
-
-[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -431,31 +425,18 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
[[package]]
name = "yaxpeax-6502"
-version = "0.0.1"
+version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d53afe49cd799784eeefe7108efd48852ea83673d55d98389a563532f05c5ea3"
+checksum = "7e89d220a799f57094ad0a58c16b2c3b7730e8f1404665bee5f10e039e7c17c3"
dependencies = [
- "take_mut",
- "yaxpeax-arch 0.0.5",
+ "yaxpeax-arch",
]
[[package]]
name = "yaxpeax-arch"
-version = "0.0.5"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6d51fa58dc03a872cf25e864c5edeb57a00a0be1e99112fe9b620eed839f035"
-dependencies = [
- "crossterm",
- "num-traits",
- "serde",
- "serde_derive",
-]
-
-[[package]]
-name = "yaxpeax-arch"
-version = "0.2.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0c90868b68ae34284714134e827062757881ab642e5746ecdcd567ffd582ff7"
+checksum = "f1ba5c2f163fa2f866c36750c6c931566c6d93231ae9410083b0738953b609d5"
dependencies = [
"crossterm",
"num-traits",
@@ -472,7 +453,7 @@ dependencies = [
"bitvec",
"serde",
"serde_derive",
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -481,7 +462,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94153e4e363dd4b0bea761ce9615647f2a29a9c3d46d3467c776969eb2b4e91c"
dependencies = [
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -492,8 +473,7 @@ dependencies = [
"hex",
"num-traits",
"yaxpeax-6502",
- "yaxpeax-arch 0.0.5",
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
"yaxpeax-arm",
"yaxpeax-avr",
"yaxpeax-ia64",
@@ -514,7 +494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3ea0f2b5728fb7eb1861532cd755ff7dd993843778d548df70a4aca95f9914e"
dependencies = [
"bitvec",
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -523,7 +503,7 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cf556f365c2fa2104e4e9a36105d9a2f72085dfd7168c95abf4f0d7cdac0cff"
dependencies = [
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -535,7 +515,7 @@ dependencies = [
"num-traits",
"serde",
"serde_derive",
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -545,7 +525,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d83d243a75ff9312b78ef761596cf0bf3b625786176363d65e653a75042873a"
dependencies = [
"num_enum",
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -554,7 +534,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63962bd68624664aa3a3391785f95388001e9d6107cdf8557e962153e4a854c5"
dependencies = [
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -563,7 +543,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb717c23e96ce83de1569c512ab5508a6e39a194a73662e618608f0f1c41ada4"
dependencies = [
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -572,16 +552,16 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1fb0d482f0f7d23394e31e50bce78d8320760c790d86e324c1a1e49710097a"
dependencies = [
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
[[package]]
name = "yaxpeax-superh"
-version = "0.1.1"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c04d16d2b60e7961ace2b8624c12295e86babb3b8a6615a4238bbb823ba0936e"
+checksum = "8c8cc1c381ba557a8d7e9fdb1399c36e4d9ce5a517b3e2bb504b261012403f4f"
dependencies = [
- "yaxpeax-arch 0.0.5",
+ "yaxpeax-arch",
]
[[package]]
@@ -593,5 +573,5 @@ dependencies = [
"num-traits",
"serde",
"serde_derive",
- "yaxpeax-arch 0.2.5",
+ "yaxpeax-arch",
]
diff --git a/Cargo.toml b/Cargo.toml
index 1751d14..eea9e76 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,6 @@ num-traits = "0.2.10"
# common interfaces for all yaxpeax decoders
yaxpeax-arch-02 = { package = "yaxpeax-arch", version = "0.2.4" }
-yaxpeax-arch-01 = { package = "yaxpeax-arch", version = "0.0.5" }
yaxpeax-arm = { version = "0.1.1" }
yaxpeax-avr = { version = "0.1.0" }
@@ -32,5 +31,5 @@ yaxpeax-pic17 = { version = "0.1.0" }
yaxpeax-pic18 = { version = "0.1.0" }
yaxpeax-x86 = { version = "1.0.4" }
yaxpeax-ia64 = { version = "0.2.1" }
-yaxpeax-superh = { version = "0.1.0" }
-yaxpeax-6502 = { version = "0.0.1" }
+yaxpeax-superh = { version = "0.3.0" }
+yaxpeax-6502 = { version = "0.0.2", features = ["std"] }
diff --git a/src/main.rs b/src/main.rs
index fe531dd..02e0974 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -85,27 +85,27 @@ fn main() {
match arch_str {
"x86_64" |
- "x86:64" => crate::current_arch::decode_input::<yaxpeax_x86::long_mode::Arch>(&buf, &printer),
+ "x86:64" => arch_02::decode_input::<yaxpeax_x86::long_mode::Arch>(&buf, &printer),
"x86_32" |
- "x86:32" => crate::current_arch::decode_input::<yaxpeax_x86::protected_mode::Arch>(&buf, &printer),
+ "x86:32" => arch_02::decode_input::<yaxpeax_x86::protected_mode::Arch>(&buf, &printer),
"x86_16" |
- "x86:16" => crate::current_arch::decode_input::<yaxpeax_x86::real_mode::Arch>(&buf, &printer),
- "ia64" => crate::current_arch::decode_input::<yaxpeax_ia64::IA64>(&buf, &printer),
- "avr" => crate::current_arch::decode_input::<yaxpeax_avr::AVR>(&buf, &printer),
- "armv7" => crate::current_arch::decode_input::<yaxpeax_arm::armv7::ARMv7>(&buf, &printer),
- "armv8" => crate::current_arch::decode_input::<yaxpeax_arm::armv8::a64::ARMv8>(&buf, &printer),
- "mips" => crate::current_arch::decode_input::<yaxpeax_mips::MIPS>(&buf, &printer),
- "msp430" => crate::current_arch::decode_input::<yaxpeax_msp430::MSP430>(&buf, &printer),
- "pic17" => crate::current_arch::decode_input::<yaxpeax_pic17::PIC17>(&buf, &printer),
- "pic18" => crate::current_arch::decode_input::<yaxpeax_pic18::PIC18>(&buf, &printer),
- "m16c" => crate::current_arch::decode_input::<yaxpeax_m16c::M16C>(&buf, &printer),
- "6502" => crate::legacy_arch::decode_input::<yaxpeax_6502::N6502>(&buf, &printer),
- "lc87" => crate::current_arch::decode_input::<yaxpeax_lc87::LC87>(&buf, &printer),
+ "x86:16" => arch_02::decode_input::<yaxpeax_x86::real_mode::Arch>(&buf, &printer),
+ "ia64" => arch_02::decode_input::<yaxpeax_ia64::IA64>(&buf, &printer),
+ "avr" => arch_02::decode_input::<yaxpeax_avr::AVR>(&buf, &printer),
+ "armv7" => arch_02::decode_input::<yaxpeax_arm::armv7::ARMv7>(&buf, &printer),
+ "armv8" => arch_02::decode_input::<yaxpeax_arm::armv8::a64::ARMv8>(&buf, &printer),
+ "mips" => arch_02::decode_input::<yaxpeax_mips::MIPS>(&buf, &printer),
+ "msp430" => arch_02::decode_input::<yaxpeax_msp430::MSP430>(&buf, &printer),
+ "pic17" => arch_02::decode_input::<yaxpeax_pic17::PIC17>(&buf, &printer),
+ "pic18" => arch_02::decode_input::<yaxpeax_pic18::PIC18>(&buf, &printer),
+ "m16c" => arch_02::decode_input::<yaxpeax_m16c::M16C>(&buf, &printer),
+ "6502" => arch_02::decode_input::<yaxpeax_6502::N6502>(&buf, &printer),
+ "lc87" => arch_02::decode_input::<yaxpeax_lc87::LC87>(&buf, &printer),
// "pic24" => decode_input::<yaxpeax_pic24::PIC24>(buf),
other => {
let seg_idx = arch_str.find(|c| c == '+' || c == '-').unwrap_or(arch_str.len());
let wps = |base| with_parsed_superh(base, &arch_str[seg_idx..],
- |decoder| crate::legacy_arch::decode_input_with_decoder::<yaxpeax_superh::SuperH>(decoder, &buf, &printer));
+ |decoder| arch_02::decode_input_with_decoder::<yaxpeax_superh::SuperH>(decoder, &buf, &printer));
match &arch_str[0..seg_idx] {
"sh" => wps(yaxpeax_superh::SuperHDecoder::SH1),
"sh2" => wps(yaxpeax_superh::SuperHDecoder::SH2),
@@ -188,67 +188,37 @@ impl Printer {
}
}
-// yaxpeax-arch, implemented by all decoders here, is required at incompatible versions by
-// different decoders. implement the actual decode-and-print behavior on both versions of
-// yaxpeax-arch while older decoders are still being updated.
-mod current_arch {
- use yaxpeax_arch_02::{AddressBase, Arch, Decoder, Instruction, LengthedInstruction, Reader, U8Reader};
- use std::fmt;
- use num_traits::identities::Zero;
+// yaxpeax-arch, implemented by all decoders here, may be required at incompatible versions by
+// different decoders if/when a new version releases. implement the actual decode-and-print
+// behavior independent of yaxpeax-arch so decoders using different version can exist in parallel.
+mod arch_02 {
use super::Printer;
-
- pub(crate) fn decode_input<A: Arch>(buf: &[u8], printer: &Printer)
- where
- A::Instruction: fmt::Display, for<'data> U8Reader<'data>: Reader<A::Address, A::Word>,
- {
- decode_input_with_decoder::<A>(A::Decoder::default(), buf, printer);
- }
-
- pub(crate) fn decode_input_with_decoder<A: Arch>(decoder: A::Decoder, buf: &[u8], printer: &Printer)
- where
- A::Instruction: fmt::Display, for<'data> U8Reader<'data>: Reader<A::Address, A::Word>,
- {
- let mut addr = A::Address::zero();
- while let Some(rest) = buf.get(addr.to_linear()..).filter(|v| !v.is_empty()) {
- let mut reader = U8Reader::new(rest);
- let res = decoder.decode(&mut reader);
- let advance_addr = match &res {
- Ok(inst) => inst.len(),
- Err(_) => A::Instruction::min_size(),
- };
- let generic_res = res.map(|inst| {
- (
- A::Address::zero().wrapping_offset(inst.len()).to_linear(),
- inst.well_defined(),
- inst,
- )
- });
- printer.print_instr(rest, addr.to_linear(), generic_res);
- addr += advance_addr;
- }
- }
-}
-
-mod legacy_arch {
- use yaxpeax_arch_01::{AddressBase, Arch, Decoder, Instruction, LengthedInstruction};
- use std::fmt;
use num_traits::identities::Zero;
- use super::Printer;
+ use std::fmt;
+ use yaxpeax_arch_02::{
+ AddressBase, Arch, Decoder, Instruction, LengthedInstruction, Reader, U8Reader,
+ };
pub(crate) fn decode_input<A: Arch>(buf: &[u8], printer: &Printer)
where
A::Instruction: fmt::Display,
+ for<'data> U8Reader<'data>: Reader<A::Address, A::Word>,
{
decode_input_with_decoder::<A>(A::Decoder::default(), buf, printer);
}
- pub(crate) fn decode_input_with_decoder<A: Arch>(decoder: A::Decoder, buf: &[u8], printer: &Printer)
- where
+ pub(crate) fn decode_input_with_decoder<A: Arch>(
+ decoder: A::Decoder,
+ buf: &[u8],
+ printer: &Printer,
+ ) where
A::Instruction: fmt::Display,
+ for<'data> U8Reader<'data>: Reader<A::Address, A::Word>,
{
let mut addr = A::Address::zero();
while let Some(rest) = buf.get(addr.to_linear()..).filter(|v| !v.is_empty()) {
- let res = decoder.decode(rest.iter().copied());
+ let mut reader = U8Reader::new(rest);
+ let res = decoder.decode(&mut reader);
let advance_addr = match &res {
Ok(inst) => inst.len(),
Err(_) => A::Instruction::min_size(),