Skip to content

Getting AddrSpace by Address space ID #1

Description

@befoulad

Hi,

Suppose that we are translating a single ARM instruction (push {r7, lr}) using the following code in a pcode emulator:

let mut decompiler = Decompiler::builder().arm(ArmVersion::Arm8, Endian::LittleEndian, rmMode::Thumb).build();
let code = Vec::from([0x80,0xb5]);
let(_, insts) = decompiler.disassemble(&code, 0x1000);
let (_, pcodes) = decompiler.translate(&code, 0x1000);
println!("{:?}", insts);
for pcode in pcodes {
    let opcode = pcode.opcode;
    println!("  opcode: {:?} ", opcode);
    if let Opcode::Store = opcode {
        println!("      {:?}", pcode.vars)
    }
}

The highlighted input varnode in the program output is supposed to be an address space ID:

[Instruction { address: 4096, mnemonic: "push", body: "{ r7, lr }" }]
opcode: Copy
opcode: IntSub
opcode: Store
[VarnodeData { space: AddrSpace { name: "const", ty: Constant }, offset: 94449029331728, size: 8 }, VarnodeData { space: AddrSpace { name: "const", ty: Constant }, offset: 94449029331728, size: 8 }, VarnodeData { space: AddrSpace { name: "const", ty: Constant }, offset: 94449029331728, size: 8 }]
opcode: IntSub
opcode: Store
[VarnodeData { space: AddrSpace { name: "const", ty: Constant }, offset: 94449029331728, size: 8 }, VarnodeData { space: AddrSpace { name: "const", ty: Constant }, offset: 94449029331728, size: 8 }, VarnodeData { space: AddrSpace { name: "const", ty: Constant }, offset: 94449029331728, size: 8 }]
opcode: Copy

Is there a way to get the actual AddrSpace asscoiated with this address space ID (94449029331728)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions