diff options
-rw-r--r-- | CHANGELOG | 7 | ||||
-rw-r--r-- | Cargo.toml | 7 | ||||
-rw-r--r-- | src/armv7.rs | 15 | ||||
-rw-r--r-- | src/armv8/a64.rs | 17 | ||||
-rw-r--r-- | src/lib.rs | 2 |
5 files changed, 39 insertions, 9 deletions
@@ -1,3 +1,10 @@ +## 0.1.1 +* fix incorrect `yaxpeax_arch::Arch` impl for `std`-enabled builds + (DecodeError did not implement `std::error::Error` in those build environments) + +## 0.1.0 +* target yaxpeax-arch 0.2.0 + ## 0.0.6 * fix incorrect markdown in README.md @@ -1,7 +1,7 @@ [package] name = "yaxpeax-arm" -version = "0.1.0" +version = "0.1.1" authors = [ "iximeow <me@iximeow.net>" ] license = "0BSD" repository = "http://git.iximeow.net/yaxpeax-arm/" @@ -19,6 +19,9 @@ name = "test" path = "test/test.rs" [features] -default = ["use-serde"] +default = ["std", "use-serde"] + +# opt-in for std-related Error impl - necessary to `?`-unwrap `DecodeError`. +std = [] use-serde = ["yaxpeax-arch/use-serde", "serde", "serde_derive"] diff --git a/src/armv7.rs b/src/armv7.rs index 82b7732..60c09d0 100644 --- a/src/armv7.rs +++ b/src/armv7.rs @@ -5,7 +5,7 @@ //#[cfg(feature="use-serde")] //use serde::{Serialize, Deserialize}; -use std::fmt::{self, Display, Formatter}; +use core::fmt::{self, Display, Formatter}; use yaxpeax_arch::{Arch, AddressDiff, Colorize, Decoder, LengthedInstruction, Reader, ReadError, NoColors, ShowContextual, YaxColors}; @@ -1583,6 +1583,15 @@ impl fmt::Display for DecodeError { } } +#[cfg(feature = "std")] +extern crate std; +#[cfg(feature = "std")] +impl std::error::Error for DecodeError { + fn description(&self) -> &str { + <Self as yaxpeax_arch::DecodeError>::description(self) + } +} + impl From<ReadError> for DecodeError { fn from(_e: ReadError) -> DecodeError { DecodeError::ExhaustedInput @@ -2399,7 +2408,7 @@ impl Decoder<ARMv7> for InstDecoder { Operand::Reg(Reg::from_u8(R[1])), ]; } - _ => { unreachable!(format!("mul upcode: {:x}", op)) } + _ => { unreachable!("mul upcode: {:x}", op) } } } else { // |c o n d|0 0 0 u|x x x x x x x x x x x x x x x x|1 u u 1|x x x x| @@ -2539,7 +2548,7 @@ impl Decoder<ARMv7> for InstDecoder { * high bit and mid-bits of op all being 0 was checked * before reaching here. */ - unreachable!(format!("load/store flags: {:x}", flags)); + unreachable!("load/store flags: {:x}", flags); } } } diff --git a/src/armv8/a64.rs b/src/armv8/a64.rs index 2ef75d8..16ed9c5 100644 --- a/src/armv8/a64.rs +++ b/src/armv8/a64.rs @@ -1,7 +1,7 @@ //#[cfg(feature="use-serde")] //use serde::{Serialize, Deserialize}; -use std::fmt::{self, Display, Formatter}; +use core::fmt::{self, Display, Formatter}; use yaxpeax_arch::{Arch, AddressDiff, Decoder, LengthedInstruction, Reader, ReadError, ShowContextual, YaxColors}; @@ -140,6 +140,15 @@ impl fmt::Display for DecodeError { } } +#[cfg(feature = "std")] +extern crate std; +#[cfg(feature = "std")] +impl std::error::Error for DecodeError { + fn description(&self) -> &str { + <Self as yaxpeax_arch::DecodeError>::description(self) + } +} + impl From<ReadError> for DecodeError { fn from(_e: ReadError) -> DecodeError { DecodeError::ExhaustedInput @@ -1075,7 +1084,7 @@ impl Decoder<ARMv8> for InstDecoder { Section::DataProcessingSimd2, // 1111 ][(section_bits & 0x0f) as usize]; - println!("word: {:#x}, bits: {:#b}", word, section_bits & 0xf); + // println!("word: {:#x}, bits: {:#b}", word, section_bits & 0xf); match section { Section::DataProcessingSimd | @@ -1741,7 +1750,7 @@ impl Decoder<ARMv8> for InstDecoder { let group_byte = word >> 23; let group_bits = (group_byte & 0x03) | ((group_byte >> 1) & 0x04) | ((group_byte >> 2) & 0x18); - println!("Group byte: {:#b}, bits: {:#b}", group_byte, group_bits); + // println!("Group byte: {:#b}, bits: {:#b}", group_byte, group_bits); match group_bits { 0b00000 => { let Rt = (word & 0x1f) as u16; @@ -2178,7 +2187,7 @@ impl Decoder<ARMv8> for InstDecoder { let Rn = ((word >> 5) & 0x1f) as u16; let size_opc = ((word >> 22) & 0x03) | ((word >> 28) & 0x0c); let category = (word >> 10) & 0x03; - println!("load/store: size_opc: {:#b}, category: {:#b}", size_opc, category); + // println!("load/store: size_opc: {:#b}, category: {:#b}", size_opc, category); if word & 0x200000 != 0 { if category != 0b10 { inst.opcode = Opcode::Invalid; @@ -1,3 +1,5 @@ +#![no_std] + #[cfg(feature="use-serde")] #[macro_use] extern crate serde_derive; #[cfg(feature="use-serde")] |