Procházet zdrojové kódy

* stack checking checks also proper alignment

git-svn-id: trunk@43011 -
florian před 5 roky
rodič
revize
1872bee116
1 změnil soubory, kde provedl 15 přidání a 5 odebrání
  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 }
   { Avoid recursive calls when called from the exit routines }
   if StackError then
   if StackError then
    exit;
    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
     decreased when this routine is called
   }
   }
   c := Sptr - STACK_MARGIN;
   c := Sptr - STACK_MARGIN;
   if (c <= StackBottom) then
   if (c <= StackBottom) then
-   begin
-     StackError:=true;
-     HandleError(202);
-   end;
+    begin
+      StackError:=true;
+      HandleError(202);
+    end;
 end;
 end;
 {$POP}
 {$POP}