iced
iced copied to clipboard
Support for resolving far call/jump targets without selector
I'm trying to make iced_x86 to format something like call 0x1234:0x5678 as call far FUN_1234_5678. Using SymbolResolver Rust API and NASM formatter, I can only manage something like this: call (seg FUN_1234_5678):FUN_1234_5678. This, while accepted by NASM, is not ideal. It would be good to be able to resolve symbols this way without having to do manual formatting for those calls.
That's my attempt on resolving symbols:
struct MyResolver;
impl SymbolResolver for MyResolver {
fn symbol(
&mut self, instruction: &Instruction, operand: u32, _instruction_operand: Option<u32>, address: u64, _address_size: u32,
) -> Option<SymbolResult<'_>> {
if instruction.is_call_far() || instruction.is_jmp_far() {
let s = format!("FUN_{:04x}_{:04x}", instruction.far_branch_selector(), instruction.far_branch16());
if operand == 0 {
Some(SymbolResult::with_string(address, s))
} else {
Some(SymbolResult::with_string(address, format!("(seg {})", s)))
}
} else {
None
}
}
}