-
Notifications
You must be signed in to change notification settings - Fork 145
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 (partially) far calls #355
base: master
Are you sure you want to change the base?
Conversation
The [1] https://github.com/trailofbits/remill/blob/487228c9b61a1dae7dd7a264d71b9905130bea02/remill/Arch/Runtime/Definitions.h#L38 |
Does the return address get written in the "destination" address space? If so, it may make sense to have a sync hyper call, somewhat like... template <typename S1, typename S2>
DEF_SEM(CALL_FAR_PTR, S1 target_pc, S2 target_seg, PC return_pc) {
// New---------
state.segment_to_load = Read(target_seg);
memory = __remill_sync_hyper_call(state, memory, SyncHyperCall::kX86GetMemoryForSegment);
// End new----------
HYPER_CALL = AsyncHyperCall::kX86CallFar;
addr_t next_sp = USub(REG_XSP, ADDRESS_SIZE_BYTES * 2);
// stack update
WriteZExt(WritePtr<addr_t>(next_sp + ADDRESS_SIZE_BYTES), Read(REG_CS.flat)); // _IF_32BIT?
Write(WritePtr<addr_t>(next_sp _IF_32BIT(REG_SS_BASE)), Read(return_pc));
// register update
Write(REG_XSP, Read(next_sp));
WriteZExt(REG_PC, Read(target_pc));
Write(REG_CS.flat, Read(target_seg));
return memory;
} Where Some additional You're likely in the best position to evaluate if these semantics are actually working, as I'm not particularly familiar with the intricacies of far calls/jumps. I've always kind of punted on them ;-) That is a bizarre error... It probably has to do with the trace lifter not being sufficiently aggressive at cloning the function into the "final" module. Can you file an issue for it? |
Ping @tathanhdinh. |
Hello @pgoodman, Sorry for the delay, I'm on vacation this week. I will come back next week. |
ping @tathanhdinh |
Hi @pgoodman, Sorry again for the late, following is a summary for the current progress:
|
Hello
This PR is for early review only (my purpose is to support far call/ret in both 64-bit/compat modes). E.g.
There as some detail in
remill
for which I'm still confused:https://github.com/trailofbits/remill/blob/d37ee6bc30b689480d9ef274e3f96fc7d76a190c/remill/Arch/X86/Semantics/CALL_RET.cpp#L21-L28
What is the purpose of
_IF_32BIT
macro in this line?And a bizzare error, when I try to lift the instruction using:
but get
Many thanks for any help.