LibC: Save callee saved registers on setjmp
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// jmp_buf: esp, eip, ebx, ebp, edi, esi
|
||||
|
||||
// int setjmp(jmp_buf env)
|
||||
.global setjmp
|
||||
setjmp:
|
||||
@@ -9,6 +11,11 @@ setjmp:
|
||||
movl (%esp), %eax
|
||||
movl %eax, 4(%edx)
|
||||
|
||||
movl %ebx, 8(%edx)
|
||||
movl %ebp, 12(%edx)
|
||||
movl %edi, 16(%edx)
|
||||
movl %esi, 20(%edx)
|
||||
|
||||
xorl %eax, %eax
|
||||
|
||||
ret
|
||||
@@ -25,8 +32,12 @@ longjmp:
|
||||
testl %ecx, %ecx
|
||||
cmovnzl %ecx, %eax
|
||||
|
||||
movl 0(%edx), %esp
|
||||
movl 4(%edx), %ecx
|
||||
movl 0(%edx), %esp
|
||||
movl 4(%edx), %ecx
|
||||
movl 8(%edx), %ebx
|
||||
movl 12(%edx), %ebp
|
||||
movl 16(%edx), %edi
|
||||
movl 20(%edx), %esi
|
||||
jmp *%ecx
|
||||
|
||||
.size longjmp, . - longjmp
|
||||
|
||||
Reference in New Issue
Block a user