Ver Fonte

Fix StackTop computation by using StackTopPtr variable set in _start code

git-svn-id: trunk@33009 -
pierre há 9 anos atrás
pai
commit
aec9ef1b70

+ 2 - 0
rtl/solaris/i386/start.inc

@@ -53,6 +53,8 @@ procedure __Argv;cdecl;external 'c' name '__Argv';
 Dump of assembler code for function _start:   }
 Dump of assembler code for function _start:   }
 procedure _start;assembler;nostackframe;public name '_start';
 procedure _start;assembler;nostackframe;public name '_start';
 asm
 asm
+   mov    %esp,%eax
+   mov    %eax,StackTopPtr
    pushl  $0x0
    pushl  $0x0
    pushl  $0x0
    pushl  $0x0
    mov    %esp,%ebp
    mov    %esp,%ebp

+ 9 - 2
rtl/solaris/sparc/start.inc

@@ -24,9 +24,16 @@ procedure PascalMain;cdecl;external name 'PASCALMAIN';
 
 
 procedure _start;assembler;nostackframe;public name '_start';
 procedure _start;assembler;nostackframe;public name '_start';
 asm
 asm
-        // Terminate the stack frame, and reserve space for functions to
-        //   drop their arguments.
+        // Terminate the stack frame
         mov     %g0, %fp
         mov     %g0, %fp
+
+        // Save current %sp to StackTopPtr
+        mov     %sp, %o2
+        sethi   %hi(StackTopPtr),%o1
+        or      %o1,%lo(StackTopPtr),%o1
+        st      %o2, [%o1]
+
+        // Reserve space for functions to drop their arguments.
         sub     %sp, 6*4, %sp
         sub     %sp, 6*4, %sp
 
 
         // Extract the arguments and environment as encoded on the stack.  The
         // Extract the arguments and environment as encoded on the stack.  The

+ 16 - 1
rtl/solaris/system.pp

@@ -28,6 +28,10 @@ var argc:longint;
     argv:PPchar;
     argv:PPchar;
     envp:PPchar;
     envp:PPchar;
 
 
+{$define FPC_SYSTEM_HAS_STACKTOP}
+var
+   StackTopPtr : pointer;
+
 {$if defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))}
 {$if defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))}
 
 
 {$define fpc_softfpu_interface}
 {$define fpc_softfpu_interface}
@@ -264,10 +268,21 @@ begin
   result := stklen;
   result := stklen;
 end;
 end;
 
 
+function StackTop : pointer;
+begin
+  if assigned(StackTopPtr) then
+    StackTop:=StackTopPtr
+  else
+    StackTop:=StackBottom + StackLength;
+end;
+
 Begin
 Begin
   IsConsole := TRUE;
   IsConsole := TRUE;
   StackLength := CheckInitialStkLen(InitialStkLen);
   StackLength := CheckInitialStkLen(InitialStkLen);
-  StackBottom := Sptr - StackLength;
+  if assigned(StackTopPtr) then
+    StackBottom:=StackTopPtr - StackLength
+  else
+    StackBottom := Sptr - StackLength;
   { Set up signals handlers (may be needed by init code to test cpu features) }
   { Set up signals handlers (may be needed by init code to test cpu features) }
   InstallSignals;
   InstallSignals;
 { Setup heap }
 { Setup heap }

+ 8 - 0
rtl/solaris/x86_64/start.inc

@@ -168,6 +168,14 @@ asm
  * there was a genuine call to _start.
  * there was a genuine call to _start.
  */
  */
 *)
 *)
+   movq   %rsp,%rax
+  // Save %rsp to StackTopPtr
+{$ifdef FPC_PIC}
+   movq   StackTopPtr@GOTPCREL(%rip),%rcx
+{$else FPC_PIC}
+   movq   $StackTopPtr,%rcx
+{$endif FPC_PIC}
+   movq   %rax,(%rcx)
    pushq  $0x0
    pushq  $0x0
    pushq  $0x0
    pushq  $0x0
    movq   %rsp,%rbp
    movq   %rsp,%rbp