Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Fix - signed_off_str #550

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn byteswap_str(name: &str, insn: &ebpf::Insn) -> String {
#[inline]
fn signed_off_str(value: i16) -> String {
if value < 0 {
format!("-{:#x}", -value)
format!("-{:#x}", -(value as isize))
} else {
format!("+{value:#x}")
}
Expand Down
12 changes: 6 additions & 6 deletions tests/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,22 @@ fn test_lddw() {
// Example for InstructionType::LoadReg.
#[test]
fn test_ldxdw() {
disasm!("entrypoint:\n ldxdw r1, [r2+0x3]\n");
disasm!("entrypoint:\n ldxdw r1, [r2-0x3]\n");
disasm!("entrypoint:\n ldxdw r1, [r2+0x7999]\n");
disasm!("entrypoint:\n ldxdw r1, [r2-0x8000]\n");
}

// Example for InstructionType::StoreImm.
#[test]
fn test_sth() {
disasm!("entrypoint:\n sth [r1+0x2], 3\n");
disasm!("entrypoint:\n sth [r1-0x2], 3\n");
disasm!("entrypoint:\n sth [r1+0x7999], 3\n");
disasm!("entrypoint:\n sth [r1-0x8000], 3\n");
}

// Example for InstructionType::StoreReg.
#[test]
fn test_stxh() {
disasm!("entrypoint:\n stxh [r1+0x2], r3\n");
disasm!("entrypoint:\n stxh [r1-0x2], r3\n");
disasm!("entrypoint:\n stxh [r1+0x7999], r3\n");
disasm!("entrypoint:\n stxh [r1-0x8000], r3\n");
}

// Test all supported AluBinary mnemonics.
Expand Down