diff options
Diffstat (limited to 'lib/mlibc/options/internal/x86/setjmp.S')
-rw-r--r-- | lib/mlibc/options/internal/x86/setjmp.S | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/mlibc/options/internal/x86/setjmp.S b/lib/mlibc/options/internal/x86/setjmp.S new file mode 100644 index 0000000..fa6644c --- /dev/null +++ b/lib/mlibc/options/internal/x86/setjmp.S @@ -0,0 +1,53 @@ + +.type __setjmp, "function" +__setjmp: + mov 4(%esp), %eax # Save argument (buffer) in edi + mov %ebx, 0x00(%eax) + mov %ebp, 0x04(%eax) + mov %esi, 0x08(%eax) + mov %edi, 0x0c(%eax) + + lea 4(%esp), %ecx # esp before return eip is pushed + mov %ecx, 0x10(%eax) + mov (%esp), %ecx # Return eip + mov %ecx, 0x14(%eax) + + test %edx, %edx + jnz 1f + xor %eax, %eax + ret + +1: + jmp __sigsetjmp@PLT + +.global setjmp +.type setjmp, "function" +setjmp: + xor %edx, %edx + jmp __setjmp + +.global sigsetjmp +.type sigsetjmp, "function" +sigsetjmp: + mov $1, %edx + jmp __setjmp + +.global longjmp +.type longjmp, "function" +longjmp: + mov 4(%esp), %ecx + mov 0x00(%ecx), %ebx + mov 0x04(%ecx), %ebp + mov 0x08(%ecx), %esi + mov 0x0c(%ecx), %edi + + mov 8(%esp), %eax + test %eax, %eax + jnz 1f + inc %eax +1: + mov 0x10(%ecx), %esp + jmp *0x14(%ecx) + +.section .note.GNU-stack,"",%progbits + |