Fix problem using alloca function, executable crashed even with a exception handler...
authorCarlos Montiers <carlos@thefunsouth.com>
Thu, 10 Jul 2014 04:37:20 +0000 (10 00:37 -0400)
committerCarlos Montiers <carlos@thefunsouth.com>
Thu, 10 Jul 2014 04:37:20 +0000 (10 00:37 -0400)
lib/alloca86-bt.S
lib/alloca86.S
lib/alloca86_64.S

index ffad515..ff07bbb 100644 (file)
@@ -14,10 +14,10 @@ __bound_alloca:
 #ifdef TCC_TARGET_PE
 p4:
     cmp     $4096,%eax
-    jle     p5
+    jb      p5
+    test    %eax,-4096(%esp)
     sub     $4096,%esp
     sub     $4096,%eax
-    test    %eax,(%esp)
     jmp p4
 
 p5:
index b836efb..5bb38b1 100644 (file)
@@ -13,10 +13,10 @@ alloca:
 #ifdef TCC_TARGET_PE
 p1:
     cmp     $4096,%eax
-    jle     p2
+    jb      p2
+    test    %eax,-4096(%esp)
     sub     $4096,%esp
     sub     $4096,%eax
-    test    %eax,(%esp)
     jmp p1
 p2:
 #endif
index dd46ce6..51acd42 100644 (file)
@@ -17,10 +17,10 @@ alloca:
 #ifdef TCC_TARGET_PE
 p1:
     cmp     $4096,%rax
-    jle     p2
+    jb      p2
+    test    %rax,-4096(%rsp)
     sub     $4096,%rsp
     sub     $4096,%rax
-    test    %rax,(%rsp)
     jmp p1
 p2:
 #endif