Explorar o código

* load StackTop and StackBottom correctly on windows, also in libraries

git-svn-id: trunk@21912 -
florian %!s(int64=13) %!d(string=hai) anos
pai
achega
3d76823929
Modificáronse 1 ficheiros con 9 adicións e 11 borrados
  1. 9 11
      rtl/win32/system.pp

+ 9 - 11
rtl/win32/system.pp

@@ -214,11 +214,6 @@ procedure Exe_entry(const info : TEntryInformation);[public,alias:'_FPC_EXE_Entr
         movl %esp,%eax
         movl %eax,System_exception_frame
         pushl %ebp
-        movl %esp,%eax
-        movl %eax,st
-     end;
-     StackTop:=st;
-     asm
         xorl %eax,%eax
         movw %ss,%ax
         movl %eax,_SS
@@ -631,14 +626,11 @@ function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
 	     DataDirectory : array[1..$80] of byte;
 	  end;
 	begin
-          if (SysInstance=0) and not IsLibrary then
-            SysInstance:=getmodulehandle(nil);
-          if (SysInstance=0) then
-            result:=stklen
-          else
-            result:=tpeheader((pointer(SysInstance)+(tdosheader(pointer(SysInstance)^).e_lfanew))^).SizeOfStackReserve;
+          result:=tpeheader((pointer(getmodulehandle(nil))+(tdosheader(pointer(getmodulehandle(nil))^).e_lfanew))^).SizeOfStackReserve;
 	end;
 
+var
+  st : Pointer;
 
 begin
   { get some helpful informations }
@@ -649,6 +641,12 @@ begin
 
   MainInstance:=SysInstance;
 
+  asm
+    movl %fs:(4),%eax
+    movl %eax,st
+  end;
+  StackTop:=st;
+
   { pass dummy value }
   StackLength := CheckInitialStkLen($1000000);
   StackBottom := StackTop - StackLength;