Jelajahi Sumber

* stack checking checks also proper alignment

git-svn-id: trunk@43011 -
florian 5 tahun lalu
induk
melakukan
1872bee116
1 mengubah file dengan 15 tambahan dan 5 penghapusan
  1. 15 5
      rtl/inc/system.inc

+ 15 - 5
rtl/inc/system.inc

@@ -951,15 +951,25 @@ begin
   { Avoid recursive calls when called from the exit routines }
   if StackError then
    exit;
-  { don't use sack_size, since the stack pointer has already been
+  { check stack alignment }
+{$ifdef CPUI386}
+{$ifdef FPC_STACKALIGNMENT=16}
+  if ((PtrUInt(Sptr)+4) mod 16)<>0 then
+    begin
+      StackError:=true;
+      HandleError(202);
+    end;
+{$endif FPC_STACKALIGNMENT=16}
+{$endif CPUI386}
+  { don't use stack_size, since the stack pointer has already been
     decreased when this routine is called
   }
   c := Sptr - STACK_MARGIN;
   if (c <= StackBottom) then
-   begin
-     StackError:=true;
-     HandleError(202);
-   end;
+    begin
+      StackError:=true;
+      HandleError(202);
+    end;
 end;
 {$POP}