|
| 1 | +use crate::tests::helpers; |
| 2 | +use crate::*; |
| 3 | + |
| 4 | +#[test] |
| 5 | +// this tests the emu.linux_call64() ARM ABI (used in linux calls) |
| 6 | +pub fn linux_call64() { |
| 7 | + helpers::setup(); |
| 8 | + |
| 9 | + /* |
| 10 | + int test(int p1, int p2, int p3, int p4, int p5, int p6, int p7) { |
| 11 | + return p1+p2+p3+p4+p5+p6+p7; |
| 12 | + } |
| 13 | + */ |
| 14 | + |
| 15 | + let mut emu = emu64(); |
| 16 | + let opcodes: Vec<u8> = vec![ |
| 17 | + 0x55, 0x48, 0x89, 0xe5, 0x89, 0x7d, 0xfc, 0x89, 0x75, 0xf8, 0x89, 0x55, |
| 18 | + 0xf4, 0x89, 0x4d, 0xf0, 0x44, 0x89, 0x45, 0xec, 0x44, 0x89, 0x4d, 0xe8, |
| 19 | + 0x8b, 0x55, 0xfc, 0x8b, 0x45, 0xf8, 0x01, 0xc2, 0x8b, 0x45, 0xf4, 0x01, |
| 20 | + 0xc2, 0x8b, 0x45, 0xf0, 0x01, 0xc2, 0x8b, 0x45, 0xec, 0x01, 0xc2, 0x8b, |
| 21 | + 0x45, 0xe8, 0x01, 0xc2, 0x8b, 0x45, 0x10, 0x01, 0xd0, 0x5d, 0xc3 |
| 22 | + ]; |
| 23 | + emu.set_verbose(0); |
| 24 | + emu.linux = true; |
| 25 | + emu.load_code_bytes(&opcodes); |
| 26 | + emu.regs_mut().rax = 0; |
| 27 | + let rax = emu.linux_call64(emu.regs().rip, &[1,2,3,4,5,6,7]).unwrap(); |
| 28 | + assert_eq!(rax, emu.regs().rax); |
| 29 | + assert_eq!(emu.regs().rax, 1+2+3+4+5+6+7); |
| 30 | +} |
0 commit comments