diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/armv8/a64.rs | 73 | ||||
| -rw-r--r-- | tests/no_std_check/.gitignore | 1 | ||||
| -rw-r--r-- | tests/no_std_check/Cargo.toml | 24 | ||||
| -rw-r--r-- | tests/no_std_check/src/main.rs | 11 |
4 files changed, 109 insertions, 0 deletions
diff --git a/tests/armv8/a64.rs b/tests/armv8/a64.rs index ae0f108..81d4a2e 100644 --- a/tests/armv8/a64.rs +++ b/tests/armv8/a64.rs @@ -83,6 +83,21 @@ fn test_barrier() { test_display([0xbf, 0x3f, 0x03, 0xd5], "dmb sy"); // only with FEAT_SB test_display([0xff, 0x30, 0x03, 0xd5], "sb"); + + test_display([0x9f, 0x34, 0x03, 0xd5], "pssbb"); + + // when printing the instruction the third operand defaults to xzr if omitted, so yax probably + // could/should omit it. but it's not *wrong*.. + test_display([0x00, 0x10, 0xdf, 0x9a], "irg x0, x0, xzr"); + test_display([0x90, 0x10, 0xdf, 0x9a], "irg x16, x4, xzr"); + test_display([0x90, 0x10, 0xcf, 0x9a], "irg x16, x4, x15"); + + test_display([0x00, 0x10, 0x60, 0xd9], "ldg x0, [x0, #0x10]"); + test_display([0x90, 0x10, 0x60, 0xd9], "ldg x16, [x4, #0x10]"); + test_display([0x90, 0x90, 0x60, 0xd9], "ldg x16, [x4, #0x90]"); + // the immediate offfset in tag instructions is a signed offset in the range of -4096 to 4096. + // yax decodes it as signed in this range, capstone does not. + test_display([0x90, 0x90, 0x7f, 0xd9], "ldg x16, [x4, #-0x70]"); } #[test] @@ -4832,6 +4847,45 @@ fn test_pac() { ([0x00, 0x04, 0xf0, 0xf8], "ldrab x0, [x0, #-0x800]"), ([0x00, 0x14, 0x20, 0xf8], "ldraa x0, [x0, #0x8]"), ([0x00, 0x04, 0xa4, 0xf8], "ldrab x0, [x0, #0x200]"), + + ([0x3f, 0x23, 0x03, 0xd5], "paciasp"), + ([0x1f, 0x23, 0x03, 0xd5], "paciaz"), + ([0x1f, 0x21, 0x03, 0xd5], "pacia1716"), + ([0x7f, 0x23, 0x03, 0xd5], "pacibsp"), + ([0x5f, 0x23, 0x03, 0xd5], "pacibz"), + ([0x5f, 0x21, 0x03, 0xd5], "pacib1716"), + + ([0xbf, 0x23, 0x03, 0xd5], "autiasp"), + ([0x9f, 0x23, 0x03, 0xd5], "autiaz"), + ([0x9f, 0x21, 0x03, 0xd5], "autia1716"), + ([0xff, 0x23, 0x03, 0xd5], "autibsp"), + ([0xdf, 0x23, 0x03, 0xd5], "autibz"), + ([0xdf, 0x21, 0x03, 0xd5], "autib1716"), + + ([0xfe, 0x83, 0xc1, 0xda], "pacnbiasppc"), + ([0xfe, 0x87, 0xc1, 0xda], "pacnbibsppc"), + ([0xfe, 0x8b, 0xc1, 0xda], "pacia171615"), + ([0xfe, 0x8f, 0xc1, 0xda], "pacib171615"), + ([0x7e, 0x92, 0xc1, 0xda], "autiasppcr x19"), + ([0x7e, 0x96, 0xc1, 0xda], "autibsppcr x19"), + ([0xfe, 0xa3, 0xc1, 0xda], "paciasppc"), + ([0xfe, 0xa7, 0xc1, 0xda], "pacibsppc"), + ([0xfe, 0xbb, 0xc1, 0xda], "autia171615"), + ([0xfe, 0xbf, 0xc1, 0xda], "autib171615"), + + ([0xff, 0x24, 0x03, 0xd5], "pacm"), + ([0xff, 0x20, 0x03, 0xd5], "xpaclri"), + ([0x1f, 0x00, 0x00, 0x55], "retaasppc $-0x3fffc"), + ([0x1f, 0x00, 0x20, 0x55], "retabsppc $-0x3fffc"), + ([0xff, 0xff, 0x1f, 0x55], "retaasppc $+0x0"), + ([0xff, 0xff, 0x3f, 0x55], "retabsppc $+0x0"), + ([0xf0, 0x0b, 0x5f, 0xd6], "retaasppcr x16"), + ([0xf0, 0x0f, 0x5f, 0xd6], "retabsppcr x16"), + + ([0x1f, 0x00, 0x80, 0xf3], "autiasppc $-0x3fffc"), + ([0x1f, 0x00, 0xa0, 0xf3], "autibsppc $-0x3fffc"), + ([0xff, 0xff, 0x9f, 0xf3], "autiasppc $+0x0"), + ([0xff, 0xff, 0xbf, 0xf3], "autibsppc $+0x0"), ]; let errs = run_tests(TESTS); @@ -4987,3 +5041,22 @@ fn test_bitfield() { assert!(errs.is_empty()); } + +#[test] +fn test_tags() { + const TESTS: &[([u8; 4], &'static str)] = &[ + ([0x00, 0x10, 0x60, 0xd9], "ldg x0, [x0, #0x10]"), + ([0x00, 0x20, 0x60, 0xd9], "ldg x0, [x0, #0x20]"), + ([0x00, 0x21, 0x60, 0xd9], "ldg x0, [x8, #0x20]"), + ([0x03, 0x21, 0x60, 0xd9], "ldg x3, [x8, #0x20]"), + ([0x03, 0x21, 0x7f, 0xd9], "ldg x3, [x8, #-0xe0]"), + ]; + + let errs = run_tests(TESTS); + + for err in errs.iter() { + println!("{}", err); + } + + assert!(errs.is_empty()); +} diff --git a/tests/no_std_check/.gitignore b/tests/no_std_check/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/tests/no_std_check/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/tests/no_std_check/Cargo.toml b/tests/no_std_check/Cargo.toml new file mode 100644 index 0000000..3edf154 --- /dev/null +++ b/tests/no_std_check/Cargo.toml @@ -0,0 +1,24 @@ +[package] + +name = "no-std-test" +version = "0.0.1" +authors = ["iximeow <me@iximeow.net>"] +license = "0BSD" +description = "test crate to check that yaxpeax-arm is actually no-std" +edition = "2021" +publish = false + +[[bin]] +name = "no-std-test" +path = "src/main.rs" + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" + +[dependencies] +yaxpeax-arm = { path = "../..", default-features = false } + +[workspace] diff --git a/tests/no_std_check/src/main.rs b/tests/no_std_check/src/main.rs new file mode 100644 index 0000000..73b5d56 --- /dev/null +++ b/tests/no_std_check/src/main.rs @@ -0,0 +1,11 @@ +#![no_std] +#![no_main] + +#[allow(unused_imports)] +use yaxpeax_arm; + +#[panic_handler] +fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } + +#[no_mangle] +pub extern "C" fn _start() -> ! { loop {} } |
