Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for resolving far call/jump targets without selector #627

Open
eugmes opened this issue Oct 16, 2024 · 0 comments
Open

Support for resolving far call/jump targets without selector #627

eugmes opened this issue Oct 16, 2024 · 0 comments

Comments

@eugmes
Copy link

eugmes commented Oct 16, 2024

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
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant