2
0
Эх сурвалжийг харах

+ add i386-linux uclibc process startup code

git-svn-id: trunk@8694 -
micha 18 жил өмнө
parent
commit
7d5d4ba706

+ 2 - 0
.gitattributes

@@ -4758,6 +4758,7 @@ rtl/linux/i386/si_c21g.inc svneol=native#text/plain
 rtl/linux/i386/si_dll.inc svneol=native#text/plain
 rtl/linux/i386/si_g.inc svneol=native#text/plain
 rtl/linux/i386/si_prc.inc svneol=native#text/plain
+rtl/linux/i386/si_uc.inc svneol=native#text/plain
 rtl/linux/i386/sighnd.inc svneol=native#text/plain
 rtl/linux/i386/sighndh.inc svneol=native#text/plain
 rtl/linux/i386/stat.inc svneol=native#text/plain
@@ -4818,6 +4819,7 @@ rtl/linux/si_dll.pp svneol=native#text/plain
 rtl/linux/si_g.pp svneol=native#text/plain
 rtl/linux/si_intf.inc svneol=native#text/plain
 rtl/linux/si_prc.pp svneol=native#text/plain
+rtl/linux/si_uc.pp svneol=native#text/plain
 rtl/linux/signal.inc svneol=native#text/plain
 rtl/linux/sparc/bsyscall.inc svneol=native#text/plain
 rtl/linux/sparc/cprt0.as svneol=native#text/plain

+ 13 - 3
rtl/linux/Makefile

@@ -1,11 +1,12 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/08/22]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/09/29]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
+OSNeedsComspecToRunBatch = go32v2 watcom
 FORCE:
 .PHONY: FORCE
 override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
@@ -56,6 +57,11 @@ else
 SRCBATCHEXT=.bat
 endif
 endif
+ifdef COMSPEC
+ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
+RUNBATCH=$(COMSPEC) /C
+endif
+endif
 ifdef inUnix
 PATHSEP=/
 else
@@ -249,7 +255,7 @@ else
 override LOADERS+=cprt21 gprt21
 endif
 CPU_UNITS=x86 ports cpu mmx
-SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll
+SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll si_uc
 endif
 ifeq ($(CPU_TARGET),x86_64)
 SYSINIT_UNITS=   # si_prc si_c si_dll
@@ -2114,7 +2120,7 @@ override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
 endif
 ifndef CROSSBOOTSTRAP
 ifneq ($(BINUTILSPREFIX),)
-override FPCOPT+=-XP$(BINUTILSPREFIX) 
+override FPCOPT+=-XP$(BINUTILSPREFIX)
 endif
 ifneq ($(BINUTILSPREFIX),)
 override FPCOPT+=-Xr$(RLINKPATH)
@@ -2246,9 +2252,13 @@ ifeq (,$(findstring -s ,$(COMPILER)))
 EXECPPAS=
 else
 ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+ifdef RUNBATCH
+EXECPPAS:=@$(RUNBATCH) $(PPAS)
+else
 EXECPPAS:=@$(PPAS)
 endif
 endif
+endif
 .PHONY: fpc_loaders
 ifneq ($(TARGET_LOADERS),)
 override ALLTARGET+=fpc_loaders

+ 1 - 1
rtl/linux/Makefile.fpc

@@ -67,7 +67,7 @@ else
 override LOADERS+=cprt21 gprt21
 endif
 CPU_UNITS=x86 ports cpu mmx
-SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll
+SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll si_uc
 endif
 
 ifeq ($(CPU_TARGET),x86_64)

+ 114 - 0
rtl/linux/i386/si_uc.inc

@@ -0,0 +1,114 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, 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/uClibc startup code for Free Pascal
+    taken from uClibc/sysdeps/linux/i386/crt1.S
+
+ %edx  Contains a function pointer to be registered with `atexit'.
+       This is how the dynamic linker arranges to have DT_FINI
+       functions called for shared libraries that have been loaded
+       before this code runs.
+   
+
+ Stack layout at program start:
+
+         nil
+         envn
+         ....
+         ....           ENVIRONMENT VARIABLES
+         env1
+         env0
+         nil
+         argn
+         ....
+         ....           COMMAND LINE OPTIONS
+         arg1
+         arg0
+         argc <--- esp
+}
+
+
+procedure libc_init; external name '__uClibc_init';
+procedure libc_fini; external name '__uClibc_fini';
+procedure libc_exit; external name '_exit';
+procedure libc_main; external name '__uClibc_main';
+
+procedure PASCALMAIN; external name 'PASCALMAIN';
+
+{******************************************************************************
+                          C library start/halt
+ ******************************************************************************}
+{$asmmode ATT}
+
+procedure _FPC_libc_start; assembler; nostackframe; public name '_start';
+asm
+  xorl    %ebp,%ebp               { clear outer most frame for backtraces }
+  popl    %esi                    { Get argc in ecx }
+  movl    %esp,%ecx               { Esp now points to the arguments }
+  leal    4(%esp,%esi,4),%eax     { The start of the environment is: esp+4*eax+8 }
+  andl    $0xfffffff0,%esp        { Align stack }
+  pushl   %eax                    { push garbage, so we push 32 bytes in total }
+
+  movl    %eax,operatingsystem_parameter_envp    { save the environment pointer }
+  movl    %esi,operatingsystem_parameter_argc    { save the argument counter    }
+  movl    %ecx,operatingsystem_parameter_argv    { save the argument pointer    }
+  movl    %esp,initialstkptr                     { save initial stack pointer   }
+
+  pushl   %esp            { provide highest stack address to C library }
+  pushl   %edx            { push address of shared library finalization }
+
+{$ifdef PIC}
+  call    .L0
+.L0:
+  pop     %ebx
+  addl    $_GLOBAL_OFFSET_TABLE_+[.-.L0],%ebx
+
+  pushl   _fini@GOT(%ebx) { push address of entry points }
+  pushl   _init@GOT(%ebx)
+
+  pushl   %ecx            { push argv }                                 
+  pushl   %esi            { push argc }
+                                                                       
+  pushl   $PASCALMAIN     { push fpc main procedure }
+  call    libc_main       { let fpc main be called from libc startup }
+{$else}
+  pushl   $libc_fini      { push address of entry points }
+  pushl   $libc_init
+
+  pushl   %ecx            { push argv }
+  pushl   %esi            { push argc }
+
+  pushl   $PASCALMAIN     { push fpc main procedure }
+  call    libc_main       { let fpc main be called from libc startup }
+{$endif}
+end;
+
+procedure _FPC_libc_haltproc; assembler; nostackframe; public name '_haltproc';
+asm
+.Lhaltproc:
+{$if sizeof(ExitCode)=2}
+  movzwl  ExitCode,%ebx
+{$else}
+  mov     ExitCode,%ebx
+{$endif}
+  pushl   %ebx
+  call    libc_exit
+  xorl    %eax,%eax
+  incl    %eax                    { eax=1, exit call }
+  popl    %ebx
+  int     $0x80
+  jmp     .Lhaltproc
+end;
+

+ 26 - 0
rtl/linux/si_uc.pp

@@ -0,0 +1,26 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, 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.
+
+ **********************************************************************}
+
+unit si_uc;
+
+interface
+
+{$i si_intf.inc}
+
+implementation
+
+{$i sysnr.inc}
+{$i si_uc.inc}
+
+end.