Преглед на файлове

Fix StackTop computation by using StackTopPtr variable set in _start code

git-svn-id: trunk@33009 -
pierre преди 9 години
родител
ревизия
aec9ef1b70
променени са 4 файла, в които са добавени 35 реда и са изтрити 3 реда
  1. 2 0
      rtl/solaris/i386/start.inc
  2. 9 2
      rtl/solaris/sparc/start.inc
  3. 16 1
      rtl/solaris/system.pp
  4. 8 0
      rtl/solaris/x86_64/start.inc

+ 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:   }
 procedure _start;assembler;nostackframe;public name '_start';
 asm
+   mov    %esp,%eax
+   mov    %eax,StackTopPtr
    pushl  $0x0
    pushl  $0x0
    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';
 asm
-        // Terminate the stack frame, and reserve space for functions to
-        //   drop their arguments.
+        // Terminate the stack frame
         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
 
         // 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;
     envp:PPchar;
 
+{$define FPC_SYSTEM_HAS_STACKTOP}
+var
+   StackTopPtr : pointer;
+
 {$if defined(CPUARM) or defined(CPUM68K) or (defined(CPUSPARC) and defined(VER2_6))}
 
 {$define fpc_softfpu_interface}
@@ -264,10 +268,21 @@ begin
   result := stklen;
 end;
 
+function StackTop : pointer;
+begin
+  if assigned(StackTopPtr) then
+    StackTop:=StackTopPtr
+  else
+    StackTop:=StackBottom + StackLength;
+end;
+
 Begin
   IsConsole := TRUE;
   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) }
   InstallSignals;
 { Setup heap }

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

@@ -168,6 +168,14 @@ asm
  * 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
    movq   %rsp,%rbp