소스 검색

* ppc32/linux: cprt0 update, fixing linking to libc
* ppc32/linux: stat update, making the compiler cycle with -dFPC_USE_LIBC again
* fixed typo in ugetrlimit libc function name

git-svn-id: trunk@1756 -

tom_at_work 19 년 전
부모
커밋
99ed1d009b
3개의 변경된 파일215개의 추가작업 그리고 147개의 파일을 삭제
  1. 111 105
      rtl/linux/powerpc/cprt0.as
  2. 102 41
      rtl/linux/powerpc/stat.inc
  3. 2 1
      rtl/unix/oscdeclh.inc

+ 111 - 105
rtl/linux/powerpc/cprt0.as

@@ -1,105 +1,111 @@
-/*
-  $Id: cprt0.as,v 1.9 2004/09/02 18:57:37 marco 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.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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.  See the GNU
-   Lesser General Public License for more details.
-
-   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.  */
-
-        .section ".text"
-        .globl  _start
-_start:
-	mr 	26,1
-	/* Set up an initial stack frame, and clear the LR.  */
-	clrrwi	1,1,4
-	li	0,0
-	stwu	1,-16(1)
-	mtlr	0
-	stw	0,0(1)
-
-        lis 	11,operatingsystem_parameter_argc@ha
-	stw 	3,operatingsystem_parameter_argc@l(11);
-
-        lis 	11,operatingsystem_parameter_argv@ha
-	stw 	4,operatingsystem_parameter_argv@l(11);
-
-	lis 	11,operatingsystem_parameter_envp@ha
-	stw 	5,operatingsystem_parameter_envp@l(11);
-
-	/* init libc, parameters are already setup at this point */
-	bl	__libc_init_first
-
-	/* install finalization code handler */
-	lis	3,_fini@ha
-	addi	3,3,_fini@l
-	bl	PASCALMAIN
-
-        .globl  _haltproc
-        .type   _haltproc,@function
-_haltproc:
-        li      0,1	         /* exit call */
-	lis	3,operatingsystem_result@h
-	stw	3,operatingsystem_result@l(3)
-        sc
-        b	_haltproc
-
-	/* Define a symbol for the first piece of initialized data.  */
-	.section ".data"
-	.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 operatingsystem_parameter_envp,4
-        .comm operatingsystem_parameter_argc,4
-        .comm operatingsystem_parameter_argv,4
-
-/*
-
-  Revision 1.9  2004/09/02 18:57:37  marco
-   * fixed argc<->argv
-
-  Revision 1.8  2004/08/18 14:26:50  karoly
-    * quick fix to make it compile
-
-  Revision 1.7  2004/07/03 21:50:31  daniel
-    * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
-      longer necessary
-
-  Revision 1.6  2004/01/04 17:28:03  florian
-    * clean up
-
-  Revision 1.5  2004/01/04 17:12:28  florian
-    * arg* and envp handling fixed
-
-  Revision 1.4  2003/12/28 20:08:53  florian
-    * initial code
-
-  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
-*/
+/*
+ * Startup code for programs linked with GNU libc, PowerPC
+ * version.
+ *
+ * Adapted from the glibc-sources (2.3.5) in the file
+ * 
+ *     sysdeps/powerpc/powerpc32/elf/start.S
+ *
+ * Original header follows.
+ */
+
+/* Startup code for programs linked with GNU libc.
+   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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.  See the GNU
+   Lesser General Public License for more details.
+
+   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.  
+*/
+
+/* These are the various addresses we require.  */
+    .section ".rodata"
+    .align    2
+start_addresses:
+    .long     _SDA_BASE_
+    .long     main_stub
+    .long     __libc_csu_init
+    .long     __libc_csu_fini
+    .size   start_adresses, .-start_addresses
+
+    .section ".text"
+    .globl  _start
+_start:
+    /* save stack pointer for later use */
+    mr     9, 1
+ /* Set up an initial stack frame, and clear the LR.  */
+    clrrwi 1, 1, 4
+    li     0, 0
+    stwu   1, -16(1)
+    mtlr   0
+    stw    0, 0(1)
+ /* Set r13 to point at the 'small data area', and put the address of
+    start_addresses in r8...  */
+    lis    8,  start_addresses@ha
+    lwzu   13, start_addresses@l(8)
+ /* and continue in libc-start, in glibc.  */
+    b      __libc_start_main
+
+    .globl  main_stub
+    .type   main_stub, @function
+main_stub:
+ /* save link register and setup stack frame */ 
+    mflr    0
+    stw     0, 0(1)
+    stwu    1, -16(1)
+
+    lis     11, operatingsystem_parameter_argc@ha
+    stw      3, operatingsystem_parameter_argc@l(11);
+
+    lis     11, operatingsystem_parameter_argv@ha
+    stw      4, operatingsystem_parameter_argv@l(11);
+
+    lis     11, operatingsystem_parameter_envp@ha
+    stw      5, operatingsystem_parameter_envp@l(11);
+
+    lis     11, ___fpc_ret@ha
+    stw     1, ___fpc_ret@l(11)
+
+    bl      PASCALMAIN
+
+    .globl  _haltproc
+    .type   _haltproc, @function
+_haltproc:
+    lis     11, ___fpc_ret@ha
+    lwz     1, ___fpc_ret@l(11)
+    addi    1, 1, 16
+    lwz     0, 0(1)
+    mtlr    0
+    blr
+
+#    li      0, 1       /* exit call */
+#    lis     3, operatingsystem_result@h
+#    stw     3, operatingsystem_result@l(3)
+#    sc
+#    b       _haltproc
+
+ /* Define a symbol for the first piece of initialized data.  */
+    .section ".data"
+    .globl   __data_start
+__data_start:
+data_start:
+
+___fpc_ret:                            /* return address to libc */
+    .long   0
+
+.text
+    .comm operatingsystem_parameter_envp, 4
+    .comm operatingsystem_parameter_argc, 4
+    .comm operatingsystem_parameter_argv, 4
+

+ 102 - 41
rtl/linux/powerpc/stat.inc

@@ -1,7 +1,9 @@
 {
 {
     This file is part of the Free Pascal run time library.
     This file is part of the Free Pascal run time library.
-    Copyright (c) 1999-2000 by Jonas Maebe,
-    member of the Free Pascal development team.
+    Copyright (c) 1999-2000 by Jonas Maebe, (c) 2005 Thomas Schatzl,
+    members of the Free Pascal development team.
+
+    Contains the definition of the stat type for the PowerPC platform.
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -12,45 +14,104 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
-  Stat = packed Record  // No unix typing because of differences
+{ This structure was ported from 
+
+    /usr/include/asm-ppc/stat.h
+
+  on a 2.6.11 kernel.
+}
+
+{$PACKRECORDS C}
+
+{$IFNDEF FPC_USE_LIBC}
+  stat = record
     case byte of
     case byte of
-      0: (st_dev    : cardinal;
-          st_ino,
-          st_mode   : cardinal;
-          nlink     : word;
-          __pad1    : word;
-          uid,
-          gid,
-          rdev      : cardinal;
-          st_size   : longint;
-          st_blksize,
-          st_blocks,
-          st_atime,
-          __unused1,
-          st_mtime,
-          __unused2,
-          st_ctime,
-          __unused3,
-          __unused4,
-          __unused5  : cardinal;);
-      1: (dev    : cardinal;
-          ino,
-          mode   : cardinal;
-          nlink_dummy     : word;
-          __pad2    : word;
-          uid_dummy,
-          gid_dummy,
-          rdev_dummy      : cardinal;
-          size   : longint;
-          blksize,
-          blocks,
-          atime,
-          __unused1_dummy,
-          mtime,
-          __unused2_dummy,
-          ctime,
-          __unused3_dummy,
-          __unused4_dummy,
-          __unused5_dummy  : cardinal;);
+      0: (
+        st_dev     : cULong;   { actually dev_t, but this one is defined wrongly }
+        st_ino     : ino_t;
+        st_mode    : mode_t;
+        st_nlink   : nlink_t;
+        st_uid     : uid_t;
+        st_gid     : gid_t;
+        st_rdev    : cULong;   { actually dev_t, but this one is defined wrongly }
+        st_size    : off_t;
+        st_blksize : cULong;
+        st_blocks  : cULong;
+        st_atime,
+        __unused1,
+        st_mtime,
+        __unused2,
+        st_ctime,
+        __unused3,
+        __unused4,
+        __unused5  : cULong);
+      1: (
+        dev    : cULong;
+        ino    : ino_t;
+        mode   : mode_t;
+        nlink  : nlink_t;
+        uid    : uid_t;
+        gid    : gid_t;
+        rdev   : cULong;
+        size   : off_t;
+        blksize,
+        blocks,
+        atime,
+        __unused1_dummy,
+        mtime,
+        __unused2_dummy,
+        ctime,
+        __unused3_dummy,
+        __unused4_dummy,
+        __unused5_dummy  : cULong);
   end;
   end;
 
 
+{$ELSE FPC_USE_LIBC}
+
+{ when linking to libc, we need to use some other, 64 bit enhanced stat type.
+ Found out by having too much time on hand and some sophisticated guessing. }
+
+  stat = record
+    case byte of
+      0: (
+        st_dev     : cULongLong;
+        st_ino     : cULongLong;
+        st_mode    : mode_t;
+        st_nlink   : nlink_t;
+        st_uid     : uid_t;
+        st_gid     : gid_t;
+        st_rdev    : cULongLong;
+        st_size    : cLongLong;
+        st_blksize : cULong;
+        st_blocks  : cULong;
+        st_atime,
+        __unused1,
+        st_mtime,
+        __unused2,
+        st_ctime,
+        __unused3,
+        __unused4,
+        __unused5  : cULong);
+      1: (
+        dev    : cULongLong;
+        ino    : cULongLong;
+        mode   : mode_t;
+        nlink  : nlink_t;
+        uid    : uid_t;
+        gid    : gid_t;
+        rdev   : cULongLong;
+        size   : cLongLong;
+        blksize,
+        blocks,
+        atime,
+        __unused1_dummy,
+        mtime,
+        __unused2_dummy,
+        ctime,
+        __unused3_dummy,
+        __unused4_dummy,
+        __unused5_dummy  : cULong);
+  end;
+
+{$ENDIF FPC_USE_LIBC}
+

+ 2 - 1
rtl/unix/oscdeclh.inc

@@ -88,7 +88,8 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     function  fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint; cdecl; external clib name 'settimeofday';
     function  fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint; cdecl; external clib name 'settimeofday';
     function FpGetRLimit(resource : cInt; rlim : PRLimit) : cInt; cdecl; external clib name 'getrlimit';
     function FpGetRLimit(resource : cInt; rlim : PRLimit) : cInt; cdecl; external clib name 'getrlimit';
     {$ifdef HAS_UGETRLIMIT}
     {$ifdef HAS_UGETRLIMIT}
-    function FpGetRLimit(resource : cInt; rlim : PRLimit) : cInt; cdecl; external clib name 'ugetrlimit';
+    { there is no ugetrlimit libc call, just map it to the getrlimit call in these cases }
+    function FpUGetRLimit(resource : cInt; rlim : PRLimit) : cInt; cdecl; external clib name 'getrlimit';
     {$endif}
     {$endif}
 
 
 {$ifdef linux}
 {$ifdef linux}