diff --git a/rtl/linux/i386/gprt1.as b/rtl/linux/i386/cprt0.as similarity index 69% rename from rtl/linux/i386/gprt1.as rename to rtl/linux/i386/cprt0.as index 60ae8c92c6..0faf5abba6 100644 --- a/rtl/linux/i386/gprt1.as +++ b/rtl/linux/i386/cprt0.as @@ -13,14 +13,13 @@ # #**********************************************************************} # -# Linux ELF startup code with profiling support for Free Pascal -# Note: Needs linking with -lgmon and -lc +# Linux ELF startup code for Free Pascal # - .file "gprt1.as" + .file "prt1.as" .text - .globl _start - .type _start,@function + .globl _start + .type _start,@function _start: /* First locate the start of the environment variables */ popl %ecx @@ -35,20 +34,27 @@ _start: movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ - finit /* initialize fpu */ - fwait - fldcw ___fpucw + movl %eax,__environ /* libc environ */ - pushl $_etext /* Initialize gmon */ - pushl $_start - call monstartup - addl $8,%esp - pushl $_mcleanup + pushl %eax + pushl %ebx + pushl %ecx + + call __libc_init /* init libc */ + movzwl __fpu_control,%eax + pushl %eax + call __setfpucw + addl $4,%esp + pushl $_fini call atexit addl $4,%esp + call _init + + popl %eax + popl %eax xorl %ebp,%ebp - call PASCALMAIN + call PASCALMAIN /* start the program */ .globl _haltproc .type _haltproc,@function @@ -67,8 +73,6 @@ _haltproc: .data .align 4 -___fpucw: - .long 0x1332 .globl ___fpc_brk_addr /* heap management */ .type ___fpc_brk_addr,@object @@ -82,15 +86,24 @@ ___fpc_brk_addr: __curbrk: .long 0 + .globl __environ + .type __environ,@object + .size __environ,4 +__environ: + .long 0 + # # $Log$ -# Revision 1.5 1998-11-04 10:16:27 peter +# Revision 1.1 1999-11-08 23:07:48 peter +# * removed aout entries +# +# Revision 1.3 1998/11/04 10:16:25 peter # + xorl ebp,ebp to indicate end of backtrace # -# Revision 1.4 1998/10/14 21:28:48 peter +# Revision 1.2 1998/10/14 21:28:46 peter # * initialize fpu so sigfpe is finally generated for fpu errors # -# Revision 1.3 1998/08/08 14:42:10 peter -# * added missing ___fpc_sbrk and logs +# Revision 1.1 1998/08/12 19:16:09 peter +# + loader including libc init and exit # # diff --git a/rtl/linux/i386/gprt0.as b/rtl/linux/i386/gprt0.as index 8e6a760a75..bfc2992fa0 100644 --- a/rtl/linux/i386/gprt0.as +++ b/rtl/linux/i386/gprt0.as @@ -13,21 +13,27 @@ # #**********************************************************************} # -# Linux a.out startup code with profiling support for Free Pascal +# Linux ELF startup code with profiling support for Free Pascal # Note: Needs linking with -lgmon and -lc # - .file "gprt0.as" + .file "gprt1.as" .text - .globl __entry -__entry: - movl 8(%esp),%eax /* Move the environment pointer */ - movl 4(%esp),%ebx /* Move the argument pointer */ - movl (%esp),%ecx /* Move the argument counter */ + .globl _start + .type _start,@function +_start: + /* First locate the start of the environment variables */ + popl %ecx + movl %esp,%ebx /* Points to the arguments */ + movl %ecx,%eax + incl %eax + shll $2,%eax + addl %esp,%eax + andl $0xfffffff8,%esp /* Align stack */ - movl %eax,U_SYSLINUX_ENVP - movl %ebx,U_SYSLINUX_ARGV - movl %ecx,U_SYSLINUX_ARGC + movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ + movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ + movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ finit /* initialize fpu */ fwait @@ -44,8 +50,8 @@ __entry: xorl %ebp,%ebp call PASCALMAIN - .globl _haltproc - .type _haltproc,@function + .globl _haltproc + .type _haltproc,@function _haltproc: xorl %ebx,%ebx /* load and save exitcode */ movw U_SYSLINUX_EXITCODE,%bx @@ -68,6 +74,7 @@ ___fpucw: .type ___fpc_brk_addr,@object .size ___fpc_brk_addr,4 ___fpc_brk_addr: + .long 0 .globl __curbrk /* necessary for libc */ .type __curbrk,@object @@ -77,13 +84,16 @@ __curbrk: # # $Log$ -# Revision 1.5 1998-11-04 10:16:26 peter +# Revision 1.6 1999-11-08 23:07:48 peter +# * removed aout entries +# +# Revision 1.5 1998/11/04 10:16:27 peter # + xorl ebp,ebp to indicate end of backtrace # -# Revision 1.4 1998/10/14 21:28:47 peter +# Revision 1.4 1998/10/14 21:28:48 peter # * initialize fpu so sigfpe is finally generated for fpu errors # -# Revision 1.3 1998/08/08 14:42:09 peter +# Revision 1.3 1998/08/08 14:42:10 peter # * added missing ___fpc_sbrk and logs # # diff --git a/rtl/linux/i386/prt0.as b/rtl/linux/i386/prt0.as index 486f3f509d..e781013f38 100644 --- a/rtl/linux/i386/prt0.as +++ b/rtl/linux/i386/prt0.as @@ -1,8 +1,8 @@ # # $Id$ # This file is part of the Free Pascal run time library. -# Copyright (c) 1996-98 by Michael Van Canneyt -# member of the Free Pascal development team. +# Copyright (c) 1993,97 by Michael Van Canneyt and Peter Vreman +# members of the Free Pascal development team. # # See the file COPYING.FPC, included in this distribution, # for details about the copyright. @@ -13,20 +13,26 @@ # #**********************************************************************} # -# Linux a.out startup code for Free Pascal +# Linux ELF startup code for Free Pascal # - .file "prt0.as" + .file "prt1.as" .text - .globl __entry -__entry: - movl 8(%esp),%eax /* Move the environment pointer */ - movl 4(%esp),%ebx /* Move the argument pointer */ - movl (%esp),%ecx /* Move the argument counter */ + .globl _start + .type _start,@function +_start: + /* First locate the start of the environment variables */ + popl %ecx + movl %esp,%ebx /* Points to the arguments */ + movl %ecx,%eax + incl %eax + shll $2,%eax + addl %esp,%eax + andl $0xfffffff8,%esp /* Align stack */ - movl %eax,U_SYSLINUX_ENVP - movl %ebx,U_SYSLINUX_ARGV - movl %ecx,U_SYSLINUX_ARGC + movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ + movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ + movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ finit /* initialize fpu */ fwait @@ -55,15 +61,24 @@ ___fpucw: ___fpc_brk_addr: .long 0 + .globl __curbrk /* necessary for libc */ + .type __curbrk,@object + .size __curbrk,4 +__curbrk: + .long 0 + # # $Log$ -# Revision 1.5 1998-11-04 10:16:28 peter +# Revision 1.6 1999-11-08 23:07:48 peter +# * removed aout entries +# +# Revision 1.5 1998/11/04 10:16:29 peter # + xorl ebp,ebp to indicate end of backtrace # -# Revision 1.4 1998/10/14 21:28:49 peter +# Revision 1.4 1998/10/14 21:28:50 peter # * initialize fpu so sigfpe is finally generated for fpu errors # -# Revision 1.3 1998/08/08 14:42:11 peter +# Revision 1.3 1998/08/08 14:42:12 peter # * added missing ___fpc_sbrk and logs # # diff --git a/rtl/linux/i386/prt1.as b/rtl/linux/i386/prt1.as deleted file mode 100644 index f5c2e291a2..0000000000 --- a/rtl/linux/i386/prt1.as +++ /dev/null @@ -1,81 +0,0 @@ -# -# $Id$ -# This file is part of the Free Pascal run time library. -# Copyright (c) 1993,97 by Michael Van Canneyt and Peter Vreman -# members of the Free Pascal development team. -# -# See the file COPYING.FPC, included in this distribution, -# for details about the copyright. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY;without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -#**********************************************************************} -# -# Linux ELF startup code for Free Pascal -# - - .file "prt1.as" - .text - .globl _start - .type _start,@function -_start: - /* First locate the start of the environment variables */ - popl %ecx - movl %esp,%ebx /* Points to the arguments */ - movl %ecx,%eax - incl %eax - shll $2,%eax - addl %esp,%eax - andl $0xfffffff8,%esp /* Align stack */ - - movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ - movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ - movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ - - finit /* initialize fpu */ - fwait - fldcw ___fpucw - - xorl %ebp,%ebp - call PASCALMAIN - - .globl _haltproc - .type _haltproc,@function -_haltproc: - movl $1,%eax /* exit call */ - xorl %ebx,%ebx - movw U_SYSLINUX_EXITCODE,%bx - int $0x80 - jmp _haltproc - -.data - .align 4 -___fpucw: - .long 0x1332 - - .globl ___fpc_brk_addr /* heap management */ - .type ___fpc_brk_addr,@object - .size ___fpc_brk_addr,4 -___fpc_brk_addr: - .long 0 - - .globl __curbrk /* necessary for libc */ - .type __curbrk,@object - .size __curbrk,4 -__curbrk: - .long 0 - -# -# $Log$ -# Revision 1.5 1998-11-04 10:16:29 peter -# + xorl ebp,ebp to indicate end of backtrace -# -# Revision 1.4 1998/10/14 21:28:50 peter -# * initialize fpu so sigfpe is finally generated for fpu errors -# -# Revision 1.3 1998/08/08 14:42:12 peter -# * added missing ___fpc_sbrk and logs -# -#