summaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/x86/setjmp.S
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/options/internal/x86/setjmp.S
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/internal/x86/setjmp.S')
-rw-r--r--lib/mlibc/options/internal/x86/setjmp.S53
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
+