<div dir="ltr"><div><div><div><div><div><div>Hello,<br></div>I'm working on a project that does migration between machines with different ISAs (currently x86_64, Aarch64 and PowerPC64). The migration is done with a compiler and runtime support based LLVM (3.7) that does stack transformation. It generates binaries for all ISAs and resumes the execution on the migrated architecture. For this purpose we record the registers and walk the call chain to record any other information needed such as callee-saved registers, live values and addresses that FP and SP point to, CFA, TOC...etc. We enforce the usage of an FP. Then create the same call chain on the destination architecture.<br><br></div>To test our stack transformation first we try it on the same architecture assuming we do a migration from an architecture with ISA x to the machine with the same ISA.. We get an architecture say PowerPC, divide its stack into 2 and walk the call chain on the upper partuntil the leaf fuction is hit, then switch to the lower part assuming this is the destination architecture and rewrite the frames here.<br><br></div>To resume the execution when we switch to the lower part of the stack, we jump to the beginning of the leaf function and attach FP and SP accordingly (we already know the whole register values of this function as well as its frame size) and load the register set with correct values.<br><br></div>We're able to walk the chain up on the destination and create all the call frames, however the call chain itself is broken as soon as I switch to the destination. To be more precise it's broken when I move the FP to point to SP on the destination stack (this is how LLVM does it, FP points to the top of the stack ust as SP does). So I'm left with some frames missing, no crashes but the execution is not correctly performed.<br><br>I assume that the backchain is broken on destination since we resume starting from the leaf function, at this point the callers don't have their frames on the stack yet. <br><br></div><div>I wonder if creating frames on the destination in the reverse order (a.k.a like a normal execution would do, filling the stack with frames starting from the caller not the callee.<br><br></div><div>I'm looking forward your help. apologies for what I have described being very abstract and long. <br></div><div><br></div>P.S. We observe this behavior on neither x86 nor ARM.<br><br></div>Thank you!<br><div><div><div><div><div><div><br><br clear="all"><div><div><br>-- <br><div class="gmail_signature"><div dir="ltr">Buse</div></div>
</div></div></div></div></div></div></div></div></div>