に沿って何かをする必要があります。
私の現在のソリューションを提供します。私はrbpを格納するので、一時的な格納に使用してから、関数の呼び出しの前に復元することができます。この説明している他の人のように%のEBPを使用するよりもおそらく遅く
movq %rbp, -24(%rsp) //store original rbp 3 words beyond the stack
movq %rsp, %rbp //store original rsp
subq $8, %rsp //buy a word on the stack
andq $-0x10, %rsp //16 byte align the stack (growing downwards)
//We now have 1 or 2 words free on the stack (depending on the original
// alignment). This is why we put rbp 3 words beyond the stack
movq %rbp, (%rsp) //store the original rsp right here
movq -24(%rbp), %rbp //restore original rbp
call foo
movq (%rsp), %rsp //restore original rsp
iretq
ヒープにSPを格納していますか? –
@ H2CO3それは恐ろしい考えのように聞こえる。この文脈でヒープの概念も持っていません。 – dschatz
それはちょっとした気分だった。 –