sleigh icon indicating copy to clipboard operation
sleigh copied to clipboard

Getting AddrSpace by Address space ID

Open befoulad opened this issue 1 year ago • 0 comments

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)?

befoulad avatar Oct 04 '23 16:10 befoulad