Преглед изворни кода

Merged revisions 2265-2268,2270 via svnmerge from
http://[email protected]/svn/fpc/trunk

........
r2265 | peter | 2006-01-12 09:46:36 +0100 (Thu, 12 Jan 2006) | 3 lines

* always write backtracestr for exception address to print also backtrace info for
exceptions generated from the main body

........
r2266 | peter | 2006-01-12 10:29:57 +0100 (Thu, 12 Jan 2006) | 4 lines

* add initialstkptr to get the stackpointer at startup before
PASCALMAIN is called so the main body framepointer is seen as
a valid pointer with backtracing

........
r2267 | peter | 2006-01-12 12:04:03 +0100 (Thu, 12 Jan 2006) | 2 lines

* add missing .globl

........
r2268 | peter | 2006-01-12 12:55:36 +0100 (Thu, 12 Jan 2006) | 2 lines

* use initialstkptr for setting stackbottom

........
r2270 | florian | 2006-01-12 22:11:46 +0100 (Thu, 12 Jan 2006) | 2 lines

* fixed errors

........

git-svn-id: branches/fixes_2_0@2307 -

peter пре 19 година
родитељ
комит
e84e39b14c

+ 5 - 4
rtl/inc/system.inc

@@ -44,15 +44,16 @@ const
 var
   emptychar : char;public name 'FPC_EMPTYCHAR';
   initialstklen : SizeUint;external name '__stklen';
+  initialstkptr : Pointer;external name '__stkptr';
 
 { checks whether the given suggested size for the stack of the current
- thread is acceptable. If this is the case, returns it unaltered. 
+ thread is acceptable. If this is the case, returns it unaltered.
  Otherwise it should return an acceptable value.
- 
- Operating systems that automatically expand their stack on demand, should 
+
+ Operating systems that automatically expand their stack on demand, should
  simply return a very large value.
  Operating systems which do not have a possibility to retrieve stack size
- information, should simply return the given stklen value (This is the default 
+ information, should simply return the given stklen value (This is the default
  implementation).
 }
 function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt; forward;

+ 6 - 0
rtl/linux/arm/cprt0.as

@@ -62,6 +62,10 @@ _start:
 	str sp,[a3]
     	str a4,[ip]
 
+    /* Save initial stackpointer */
+	ldr ip,=__stkptr
+	str sp,[ip]
+
         /* Fetch address of fini */
         ldr ip, =_fini
 
@@ -108,6 +112,8 @@ __data_start:
 	data_start = __data_start
 
 .bss
+        .comm __stkptr,4
+
         .comm operatingsystem_parameter_envp,4
         .comm operatingsystem_parameter_argc,4
         .comm operatingsystem_parameter_argv,4

+ 6 - 0
rtl/linux/arm/prt0.as

@@ -62,6 +62,10 @@ _start:
 	str sp,[a3]
    	str a2,[ip]
 
+    /* Save initial stackpointer */
+	ldr ip,=__stkptr
+	str sp,[ip]
+
 	/* Let the libc call main and exit with its return code.  */
 	bl PASCALMAIN
 
@@ -82,6 +86,8 @@ __data_start:
 	data_start = __data_start
 
 .bss
+        .comm __stkptr,4
+
         .comm operatingsystem_parameter_envp,4
         .comm operatingsystem_parameter_argc,4
         .comm operatingsystem_parameter_argv,4

+ 22 - 8
rtl/linux/i386/cprt0.as

@@ -66,6 +66,9 @@ _start:
         popl    %eax
         popl    %eax
 
+        /* Save initial stackpointer */
+        movl    %esp,__stkptr
+
         xorl    %ebp,%ebp
         call    PASCALMAIN              /* start the program */
 
@@ -74,20 +77,31 @@ _start:
 _haltproc:
 _haltproc2:             # GAS <= 2.15 bug: generates larger jump if a label is exported
         movzwl  operatingsystem_result,%ebx
-	pushl   %ebx
-	call    exit
+        pushl   %ebx
+        call    exit
         xorl    %eax,%eax
         incl    %eax                    /* eax=1, exit call */
-	popl    %ebx
+        popl    %ebx
         int     $0x80
         jmp     _haltproc2
 
 .data
 
 .bss
-        .type   ___fpc_brk_addr,@object
-        .comm   ___fpc_brk_addr,4        /* heap management */
+        .type   __stkptr,@object
+        .size   __stkptr,4
+        .global __stkptr
+__stkptr:
+        .skip   4
+
+        .type operatingsystem_parameters,@object
+        .size operatingsystem_parameters,12
+operatingsystem_parameters:
+        .skip 3*4
 
-        .comm operatingsystem_parameter_envp,4
-        .comm operatingsystem_parameter_argc,4
-        .comm operatingsystem_parameter_argv,4
+        .global operatingsystem_parameter_envp
+        .global operatingsystem_parameter_argc
+        .global operatingsystem_parameter_argv
+        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
+        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
+        .set operatingsystem_parameter_argv,operatingsystem_parameters+8

+ 19 - 5
rtl/linux/i386/cprt21.as

@@ -73,6 +73,9 @@ main:
         movl    %ebp,___fpc_ret_ebp
         pushl   %eax
 
+        /* Save initial stackpointer */
+        movl    %esp,__stkptr
+
         /* start the program */
         xorl    %ebp,%ebp
         call    PASCALMAIN
@@ -102,9 +105,20 @@ ___fpc_ret_ebp:
         .long   0
 
 .bss
-        .type   ___fpc_brk_addr,@object
-        .comm   ___fpc_brk_addr,4        /* heap management */
+        .type   __stkptr,@object
+        .size   __stkptr,4
+        .global __stkptr
+__stkptr:
+        .skip   4
+
+        .type operatingsystem_parameters,@object
+        .size operatingsystem_parameters,12
+operatingsystem_parameters:
+        .skip 3*4
 
-        .comm operatingsystem_parameter_envp,4
-        .comm operatingsystem_parameter_argc,4
-        .comm operatingsystem_parameter_argv,4
+        .global operatingsystem_parameter_envp
+        .global operatingsystem_parameter_argc
+        .global operatingsystem_parameter_argv
+        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
+        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
+        .set operatingsystem_parameter_argv,operatingsystem_parameters+8

+ 20 - 3
rtl/linux/i386/dllprt0.as

@@ -35,6 +35,9 @@ FPC_LIB_START:
 
         movb    $1,U_SYSTEM_ISLIBRARY
 
+        /* Save initial stackpointer */
+        movl    %esp,__stkptr
+
         call    PASCALMAIN
 
         leave
@@ -51,6 +54,20 @@ _haltproc2:             # GAS <= 2.15 bug: generates larger jump if a label is e
         jmp     _haltproc2
 
 .bss
-        .comm operatingsystem_parameter_envp,4
-        .comm operatingsystem_parameter_argc,4
-        .comm operatingsystem_parameter_argv,4
+        .type   __stkptr,@object
+        .size   __stkptr,4
+__stkptr:
+        .skip   4
+
+        .type operatingsystem_parameters,@object
+        .size operatingsystem_parameters,12
+operatingsystem_parameters:
+        .skip 3*4
+
+        .global operatingsystem_parameter_envp
+        .global operatingsystem_parameter_argc
+        .global operatingsystem_parameter_argv
+        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
+        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
+        .set operatingsystem_parameter_argv,operatingsystem_parameters+8
+

+ 19 - 5
rtl/linux/i386/gprt0.as

@@ -46,6 +46,9 @@ _start:
         call    atexit
         addl    $4,%esp
 
+        /* Save initial stackpointer */
+        movl    %esp,__stkptr
+
         xorl    %ebp,%ebp
         call    PASCALMAIN
 
@@ -67,9 +70,20 @@ ___fpucw:
         .long   0x1332
 
 .bss
-        .type   ___fpc_brk_addr,@object
-        .comm   ___fpc_brk_addr,4        /* heap management */
+        .type   __stkptr,@object
+        .size   __stkptr,4
+        .global __stkptr
+__stkptr:
+        .skip   4
+
+        .type operatingsystem_parameters,@object
+        .size operatingsystem_parameters,12
+operatingsystem_parameters:
+        .skip 3*4
 
-        .comm operatingsystem_parameter_envp,4
-        .comm operatingsystem_parameter_argc,4
-        .comm operatingsystem_parameter_argv,4
+        .global operatingsystem_parameter_envp
+        .global operatingsystem_parameter_argc
+        .global operatingsystem_parameter_argv
+        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
+        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
+        .set operatingsystem_parameter_argv,operatingsystem_parameters+8

+ 21 - 6
rtl/linux/i386/gprt21.as

@@ -58,7 +58,10 @@ cmain:
         movl    %edi,___fpc_ret_edi
         pushl   %eax
 
-	call    __gmon_start__
+        call    __gmon_start__
+
+        /* Save initial stackpointer */
+        movl    %esp,__stkptr
 
         /* start the program */
         call    PASCALMAIN
@@ -115,9 +118,21 @@ ___fpc_ret_edi:
 .bss
         .lcomm __monstarted,4
 
-        .type   ___fpc_brk_addr,@object
-        .comm   ___fpc_brk_addr,4        /* heap management */
+        .type   __stkptr,@object
+        .size   __stkptr,4
+        .global __stkptr
+__stkptr:
+        .skip   4
+
+        .type operatingsystem_parameters,@object
+        .size operatingsystem_parameters,12
+operatingsystem_parameters:
+        .skip 3*4
+
+        .global operatingsystem_parameter_envp
+        .global operatingsystem_parameter_argc
+        .global operatingsystem_parameter_argv
+        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
+        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
+        .set operatingsystem_parameter_argv,operatingsystem_parameters+8
 
-        .comm operatingsystem_parameter_envp,4
-        .comm operatingsystem_parameter_argc,4
-        .comm operatingsystem_parameter_argv,4

+ 30 - 17
rtl/linux/i386/prt0.as

@@ -44,21 +44,28 @@ _start:
         /* First locate the start of the environment variables */
         popl    %ecx                    /* Get argc in ecx */
         movl    %esp,%ebx               /* Esp now points to the arguments */
-	leal    4(%esp,%ecx,4),%eax     /* The start of the environment is: esp+4*eax+4 */
+        leal    4(%esp,%ecx,4),%eax     /* The start of the environment is: esp+4*eax+4 */
         andl    $0xfffffff8,%esp        /* Align stack */
 
-	leal    operatingsystem_parameters,%edi
-	stosl	/* Move the environment pointer */
-	xchg    %ecx,%eax
-	stosl   /* Move the argument counter    */
-	xchg	%ebx,%eax
-	stosl   /* Move the argument pointer    */
+        leal    operatingsystem_parameters,%edi
+        stosl   /* Move the environment pointer */
+        xchg    %ecx,%eax
+        stosl   /* Move the argument counter    */
+        xchg    %ebx,%eax
+        stosl   /* Move the argument pointer    */
 
 
         fninit                           /* initialize fpu */
         fwait
         fldcw   ___fpucw
 
+#        /* Initialize gs for thread local storage */
+#        movw    %ds,%ax
+#        movw    %ax,%gs
+
+        /* Save initial stackpointer */
+        movl    %esp,__stkptr
+
         xorl    %ebp,%ebp
         call    PASCALMAIN
 
@@ -66,7 +73,7 @@ _start:
         .type   _haltproc,@function
 _haltproc:
 _haltproc2:             # GAS <= 2.15 bug: generates larger jump if a label is exported
-	movl    $252,%eax                /* exit_group */
+        movl    $252,%eax                /* exit_group */
         movzwl  operatingsystem_result,%ebx
         int     $0x80
         movl    $1,%eax                /* exit */
@@ -80,17 +87,23 @@ ___fpucw:
 
 
 .bss
-        .type   ___fpc_brk_addr,@object
-	.comm   ___fpc_brk_addr,4        /* heap management */
+        .type   __stkptr,@object
+        .size   __stkptr,4
+        .global __stkptr
+__stkptr:
+        .skip   4
 
         .type operatingsystem_parameters,@object
         .size operatingsystem_parameters,12
 operatingsystem_parameters:
-	.skip 3*4
+        .skip 3*4
+
+        .global operatingsystem_parameter_envp
+        .global operatingsystem_parameter_argc
+        .global operatingsystem_parameter_argv
+        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
+        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
+        .set operatingsystem_parameter_argv,operatingsystem_parameters+8
 
-	.global operatingsystem_parameter_envp
-	.global operatingsystem_parameter_argc
-	.global operatingsystem_parameter_argv
-	.set operatingsystem_parameter_envp,operatingsystem_parameters+0
-	.set operatingsystem_parameter_argc,operatingsystem_parameters+4
-	.set operatingsystem_parameter_argv,operatingsystem_parameters+8
+//.section .threadvar,"aw",@nobits
+        .comm   ___fpc_threadvar_offset,4

+ 6 - 3
rtl/linux/powerpc/cprt0.as

@@ -3,7 +3,7 @@
  * version.
  *
  * Adapted from the glibc-sources (2.3.5) in the file
- * 
+ *
  *     sysdeps/powerpc/powerpc32/elf/start.S
  *
  * Original header follows.
@@ -26,7 +26,7 @@
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  
+   02111-1307 USA.
 */
 
 /* These are the various addresses we require.  */
@@ -60,7 +60,7 @@ _start:
     .globl  main_stub
     .type   main_stub, @function
 main_stub:
- /* save link register and setup stack frame */ 
+ /* save link register and setup stack frame */
     mflr    0
     stw     0, 0(1)
     stwu    1, -16(1)
@@ -74,6 +74,9 @@ main_stub:
     lis     11, operatingsystem_parameter_envp@ha
     stw      5, operatingsystem_parameter_envp@l(11);
 
+    lis 	11,__stkptr@ha
+	stw 	1,__stkptr@l(11);
+
     lis     11, ___fpc_ret@ha
     stw     1, ___fpc_ret@l(11)
 

+ 0 - 15
rtl/linux/powerpc/dllprt0.as

@@ -1,15 +0,0 @@
-/*
-  $Id: dllprt0.as,v 1.3 2002/09/07 16:01:20 peter Exp $
-*/
-
-/* 
-
-  Revision 1.3  2002/09/07 16:01:20  peter
-    * old logs removed and tabs fixed
-
-  Revision 1.2  2002/07/26 17:09:44  florian
-    * log fixed
-
-  Revision 1.1  2002/07/26 17:07:11  florian
-    + dummy implementation to test the makefile
-*/

+ 0 - 15
rtl/linux/powerpc/gprt0.as

@@ -1,15 +0,0 @@
-/*
-  $Id: gprt0.as,v 1.3 2002/09/07 16:01:20 peter Exp $
-*/
-
-/*
-
-  Revision 1.3  2002/09/07 16:01:20  peter
-    * old logs removed and tabs fixed
-
-  Revision 1.2  2002/07/26 17:09:44  florian
-    * log fixed
-
-  Revision 1.1  2002/07/26 17:07:11  florian
-    + dummy implementation to test the makefile
-*/

+ 6 - 54
rtl/linux/powerpc/prt0.as

@@ -1,6 +1,3 @@
-/*
-  $Id: prt0.as,v 1.14 2004/08/18 14:26:50 karoly Exp $
-*/
 /* Startup code for programs linked with GNU libc.
    Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
@@ -44,8 +41,11 @@ _start:
 	lis 	11,operatingsystem_parameter_envp@ha
 	stw 	5,operatingsystem_parameter_envp@l(11);
 
+    lis 	11,__stkptr@ha
+	stw 	1,__stkptr@l(11);
+
 	bl	PASCALMAIN
-	
+
 	b	_haltproc
 
         .globl  _haltproc
@@ -60,58 +60,10 @@ _haltproc:
 	.globl	__data_start
 __data_start:
 data_start:
-        .globl  ___fpc_brk_addr         /* heap management */
-        .type   ___fpc_brk_addr,@object
-        .size   ___fpc_brk_addr,4
-___fpc_brk_addr:
-        .long   0
 
 .text
+        .comm __stkptr,4
+
         .comm operatingsystem_parameter_envp,4
         .comm operatingsystem_parameter_argc,4
         .comm operatingsystem_parameter_argv,4
-/*
-
-  Revision 1.14  2004/08/18 14:26:50  karoly
-    * quick fix to make it compile
-
-  Revision 1.13  2004/07/03 21:50:31  daniel
-    * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
-      longer necessary
-
-  Revision 1.12  2004/05/26 20:48:17  florian
-    * _haltproc fixed
-
-  Revision 1.11  2004/01/04 17:23:57  florian
-    + header added
-
-  Revision 1.10  2003/05/12 22:36:45  florian
-    + added setup of argv, argc and envp
-
-  Revision 1.9  2002/09/07 16:01:20  peter
-    * old logs removed and tabs fixed
-
-  Revision 1.8  2002/08/31 21:29:57  florian
-    * several PC related fixes
-
-  Revision 1.7  2002/08/31 16:13:12  florian
-    * made _start global
-
-  Revision 1.6  2002/08/31 14:02:23  florian
-    * r3 renamed to 3
-
-  Revision 1.5  2002/08/31 14:01:28  florian
-    * _haltproc to prt0.as added (Linux/PPC)
-
-  Revision 1.4  2002/08/31 13:11:11  florian
-    * several fixes for Linux/PPC compilation
-
-  Revision 1.3  2002/08/19 21:19:15  florian
-    * small fixes
-
-  Revision 1.2  2002/07/26 17:09:44  florian
-    * log fixed
-
-  Revision 1.1  2002/07/26 16:57:40  florian
-    + initial version, plain copy from glibc/sysdeps/powerpc/elf/start.S
-*/

+ 6 - 1
rtl/linux/sparc/cprt0.as

@@ -29,6 +29,11 @@ _start:
        	or	%o1,%lo(operatingsystem_parameter_envp),%o1
        	st	%o2, [%o1]
 
+    /* Save initial stackpointer */
+	sethi	%hi(__stkptr),%o1
+	or	%o1,%lo(__stkptr),%o1
+	st	%sp, [%o1]
+
   /* reload the addresses for C startup code  */
         ld      [%sp+22*4], %o1
         add     %sp, 23*4, %o2
@@ -71,7 +76,7 @@ _start:
 
 .data
 
-        .comm   ___fpc_brk_addr,4        /* heap management */
+        .comm __stkptr,4
 
         .comm operatingsystem_parameter_envp,4
         .comm operatingsystem_parameter_argc,4

+ 6 - 1
rtl/linux/sparc/gprt0.as

@@ -29,6 +29,11 @@ _start:
        	or	%o1,%lo(operatingsystem_parameter_envp),%o1
        	st	%o2, [%o1]
 
+    /* Save initial stackpointer */
+	sethi	%hi(__stkptr),%o1
+	or	%o1,%lo(__stkptr),%o1
+	st	%sp, [%o1]
+
   /* reload the addresses for C startup code  */
         ld      [%sp+22*4], %o1
         add     %sp, 23*4, %o2
@@ -92,7 +97,7 @@ _start:
 
 .data
 
-        .comm   ___fpc_brk_addr,4        /* heap management */
+        .comm __stkptr,4
 
         .comm operatingsystem_parameter_envp,4
         .comm operatingsystem_parameter_argc,4

+ 7 - 0
rtl/linux/sparc/prt0.as

@@ -49,6 +49,11 @@ _start:
 	or	%o1,%lo(operatingsystem_parameter_envp),%o1
 	st	%o2, [%o1]
 
+    /* Save initial stackpointer */
+	sethi	%hi(__stkptr),%o1
+	or	%o1,%lo(__stkptr),%o1
+	st	%sp, [%o1]
+
   	/* Call the user program entry point.  */
   	call	PASCALMAIN
   	nop
@@ -67,6 +72,8 @@ _haltproc:
 
 	.size _start, .-_start
 
+        .comm __stkptr,4
+
         .comm operatingsystem_parameter_envp,4
         .comm operatingsystem_parameter_argc,4
         .comm operatingsystem_parameter_argv,4

+ 2 - 2
rtl/linux/system.pp

@@ -1,5 +1,5 @@
 {
-    This file is part of the Free Pascal run time librar~y.
+    This file is part of the Free Pascal run time library.
     Copyright (c) 2000 by Marco van de Voort
     member of the Free Pascal development team.
 
@@ -254,7 +254,7 @@ Begin
   IsConsole := TRUE;
   IsLibrary := FALSE;
   StackLength := CheckInitialStkLen(initialStkLen);
-  StackBottom := Sptr - StackLength;
+  StackBottom := initialstkptr - StackLength;
   { Set up signals handlers }
   InstallSignals;
   { Setup heap }

+ 5 - 0
rtl/linux/x86_64/cprt0.as

@@ -83,6 +83,9 @@ main_stub:
         movq    %rbp,___fpc_ret_rbp
         pushq   %rax
 
+        /* Save initial stackpointer */
+        movq    %rsp,__stkptr
+
         /* start the program */
         xorq    %rbp,%rbp
         call    PASCALMAIN
@@ -120,6 +123,8 @@ ___fpc_ret_rbp:
         .quad   0
 
 .bss
+        .comm __stkptr,8
+
         .comm operatingsystem_parameter_envp,8
         .comm operatingsystem_parameter_argc,8
         .comm operatingsystem_parameter_argv,8

+ 5 - 0
rtl/linux/x86_64/gprt0.as

@@ -91,6 +91,9 @@ main_stub:
         movq    $_mcleanup,%rdi
         call    atexit
 
+        /* Save initial stackpointer */
+        movq    %rsp,__stkptr
+
         /* start the program */
         xorq    %rbp,%rbp
         call    PASCALMAIN
@@ -128,6 +131,8 @@ ___fpc_ret_rbp:
         .quad   0
 
 .bss
+        .comm __stkptr,8
+
         .comm operatingsystem_parameter_envp,8
         .comm operatingsystem_parameter_argc,8
         .comm operatingsystem_parameter_argv,8

+ 5 - 0
rtl/linux/x86_64/prt0.as

@@ -48,6 +48,9 @@ _start:
         movq     %rax,operatingsystem_parameter_envp
         andq     $~15,%rsp            /* Align the stack to a 16 byte boundary to follow the ABI.  */
 
+        /* Save initial stackpointer */
+        movq    %rsp,__stkptr
+
         xorq    %rbp, %rbp
         call    PASCALMAIN
 	jmp	_haltproc
@@ -69,6 +72,8 @@ __data_start:
         data_start = __data_start
 
 .bss
+        .comm __stkptr,8
+
         .comm operatingsystem_parameter_envp,8
         .comm operatingsystem_parameter_argc,8
         .comm operatingsystem_parameter_argv,8

+ 1 - 1
rtl/objpas/sysutils/sysutils.inc

@@ -206,9 +206,9 @@ begin
    end
   else
    Writeln(stdout,'Exception object ',Obj.ClassName,' is not of class Exception.');
+  Writeln(stdout,BackTraceStrFunc(Addr));
   if (FrameCount>0) then
     begin
-      Writeln(stdout,BackTraceStrFunc(Addr));
       for i:=0 to FrameCount-1 do
         Writeln(stdout,BackTraceStrFunc(Frames[i]));
     end;

+ 1 - 1
rtl/win32/system.pp

@@ -1130,7 +1130,7 @@ const
 
 begin
   StackLength := CheckInitialStkLen(InitialStkLen);
-  StackBottom := Sptr - StackLength;
+  StackBottom := initialstkptr - StackLength;
   { get some helpful informations }
   GetStartupInfo(@startupinfo);
   { some misc Win32 stuff }

+ 3 - 14
rtl/win32/wcygprt0.as

@@ -21,6 +21,7 @@ _cmain:
      subl   $0x8,%esp
      andl   $0xfffffff0,%esp
      call   ___main
+     movl   %esp,__stkptr
      call   _FPC_EXE_Entry
      ret
 
@@ -68,17 +69,5 @@ exitprocess:
 .L6:
 	.ascii	"kernel32.dll\000"
 
-
-
-
-// Revision 1.1  2004/11/04 17:15:01  peter
-//  * wcygprt is now used for cygwin (libc) linking, initc contains only cerrno
-//
-// Revision 1.4  2002/11/30 18:17:35  carl
-//   + profiling support
-//
-// Revision 1.3  2002/07/28 20:43:51  florian
-//   * several fixes for linux/powerpc
-//   * several fixes to MT
-//
-//
+.bss
+    .comm   __stkptr,4

+ 8 - 15
rtl/win32/wprt0.as

@@ -5,14 +5,16 @@
      .globl _mainCRTStartup
 _mainCRTStartup:
      movb   $1,U_SYSTEM_ISCONSOLE
+     movl   %esp,__stkptr
      call   _FPC_EXE_Entry
      .globl _WinMainCRTStartup
 _WinMainCRTStartup:
      movb   $0,U_SYSTEM_ISCONSOLE
+     movl   %esp,__stkptr
      call   _FPC_EXE_Entry
-     
+
      .globl asm_exit
-asm_exit:     
+asm_exit:
     pushl   %eax
 	call	exitprocess
 
@@ -21,7 +23,7 @@ asm_exit:
 exitprocess:
 	jmp	*.L10
 	.balign 4,144
-	
+
 .text
 	.balign 4,144
 
@@ -38,7 +40,7 @@ exitprocess:
 
 .section .idata$5
 .L8:
-	
+
 
 .section .idata$5
 .L10:
@@ -55,14 +57,5 @@ exitprocess:
 .L6:
 	.ascii	"kernel32.dll\000"
 
-
-	
-
-// Revision 1.4  2002/11/30 18:17:35  carl
-//   + profiling support
-//
-// Revision 1.3  2002/07/28 20:43:51  florian
-//   * several fixes for linux/powerpc
-//   * several fixes to MT
-//
-//
+.bss
+    .comm   __stkptr,4