summaryrefslogtreecommitdiff
path: root/win32/lib/chkstk.S
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2020-08-14 23:04:13 +0100
committerThomas Preud'homme <robotux@celest.fr>2020-08-14 23:04:13 +0100
commitafd09586d7ead4f146ad7a7a471be34196b3c6bc (patch)
tree87854be29fb4264b979b700fa45445f58faa4c26 /win32/lib/chkstk.S
parente2ccf3981d78dfeb390d22c74625b60310100abb (diff)
New upstream version 0.9.27+git20200814.62c30a4a
Diffstat (limited to 'win32/lib/chkstk.S')
-rw-r--r--win32/lib/chkstk.S142
1 files changed, 12 insertions, 130 deletions
diff --git a/win32/lib/chkstk.S b/win32/lib/chkstk.S
index ec5c07f..6f583a5 100644
--- a/win32/lib/chkstk.S
+++ b/win32/lib/chkstk.S
@@ -1,13 +1,18 @@
/* ---------------------------------------------- */
/* chkstk86.s */
+#ifdef __leading_underscore
+# define _(s) _##s
+#else
+# define _(s) s
+#endif
+
/* ---------------------------------------------- */
#ifndef __x86_64__
/* ---------------------------------------------- */
-.globl __chkstk
-
-__chkstk:
+.globl _(__chkstk)
+_(__chkstk):
xchg (%esp),%ebp /* store ebp, get ret.addr */
push %ebp /* push ret.addr */
lea 4(%esp),%ebp /* setup frame ptr */
@@ -31,9 +36,8 @@ P0:
#else
/* ---------------------------------------------- */
-.globl __chkstk
-
-__chkstk:
+.globl _(__chkstk)
+_(__chkstk):
xchg (%rsp),%rbp /* store ebp, get ret.addr */
push %rbp /* push ret.addr */
lea 8(%rsp),%rbp /* setup frame ptr */
@@ -57,8 +61,8 @@ P0:
/* ---------------------------------------------- */
/* setjmp/longjmp support */
-.globl tinyc_getbp
-tinyc_getbp:
+.globl _(tinyc_getbp)
+_(tinyc_getbp):
mov %rbp,%rax
ret
@@ -67,125 +71,3 @@ tinyc_getbp:
/* ---------------------------------------------- */
-/* ---------------------------------------------- */
-#ifndef __x86_64__
-/* ---------------------------------------------- */
-
-/*
- int _except_handler3(
- PEXCEPTION_RECORD exception_record,
- PEXCEPTION_REGISTRATION registration,
- PCONTEXT context,
- PEXCEPTION_REGISTRATION dispatcher
- );
-
- int __cdecl _XcptFilter(
- unsigned long xcptnum,
- PEXCEPTION_POINTERS pxcptinfoptrs
- );
-
- struct _sehrec {
- void *esp; // 0
- void *exception_pointers; // 1
- void *prev; // 2
- void *handler; // 3
- void *scopetable; // 4
- int trylevel; // 5
- void *ebp // 6
- };
-
- // this is what the assembler code below means:
- __try
- {
- // ...
- }
- __except (_XcptFilter(GetExceptionCode(), GetExceptionInformation()))
- {
- exit(GetExceptionCode());
- }
-*/
-
-.globl _exception_info
-_exception_info:
- mov 1*4-24(%ebp),%eax
- ret
-
-.globl _exception_code
-_exception_code:
- call _exception_info
- mov (%eax),%eax
- mov (%eax),%eax
- ret
-
-seh_filter:
- call _exception_info
- push %eax
- call _exception_code
- push %eax
- call _XcptFilter
- add $ 8,%esp
- ret
-
-seh_except:
- mov 0*4-24(%ebp),%esp
- call _exception_code
- push %eax
- call _exit
-
-// msvcrt wants scopetables aligned and in read-only segment (using .text)
-.align 4
-seh_scopetable:
- .long -1
- .long seh_filter
- .long seh_except
-
-seh_handler:
- jmp _except_handler3
-
-.globl ___try__
-___try__:
-.globl __try__
-__try__:
- push %ebp
- mov 8(%esp),%ebp
-
-// void *esp;
- lea 12(%esp),%eax
- mov %eax,0*4(%ebp)
-
-// void *exception_pointers;
- xor %eax,%eax
- mov %eax,1*4(%ebp)
-
-// void *prev;
- mov %fs:0,%eax
- mov %eax,2*4(%ebp)
-
-// void *handler;
- mov $ seh_handler,%eax
- mov %eax,3*4(%ebp)
-
-// void *scopetable;
- mov $ seh_scopetable,%eax
- mov %eax,4*4(%ebp)
-
-// int trylevel;
- xor %eax,%eax
- mov %eax,5*4(%ebp)
-
-// register new SEH
- lea 2*4(%ebp),%eax
- mov %eax,%fs:0
-
- pop %ebp
- ret
-
-/* ---------------------------------------------- */
-#else
-/* ---------------------------------------------- */
-
-/* SEH on x86-64 not implemented */
-
-/* ---------------------------------------------- */
-#endif
-/* ---------------------------------------------- */