Initial revision

From-SVN: r3431
This commit is contained in:
Jim Wilson 1993-02-05 15:50:44 -08:00
parent d68398271c
commit 266f95411b
5 changed files with 311 additions and 0 deletions

155
gcc/config/i386/sol2-c1.asm Normal file
View File

@ -0,0 +1,155 @@
! crt1.s for Solaris 2, x86
! Copyright (C) 1993 Free Software Foundation, Inc.
! Written By Fred Fish, Nov 1992
!
! This file is free software; you can redistribute it and/or modify it
! under the terms of the GNU General Public License as published by the
! Free Software Foundation; either version 2, or (at your option) any
! later version.
!
! In addition to the permissions in the GNU General Public License, the
! Free Software Foundation gives you unlimited permission to link the
! compiled version of this file with other programs, and to distribute
! those programs without any restriction coming from the use of this
! file. (The General Public License restrictions do apply in other
! respects; for example, they cover modification of the file, and
! distribution when not linked into another program.)
!
! This file 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
! General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; see the file COPYING. If not, write to
! the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
!
! As a special exception, if you link this library with files
! compiled with GCC to produce an executable, this does not cause
! the resulting executable to be covered by the GNU General Public License.
! This exception does not however invalidate any other reasons why
! the executable file might be covered by the GNU General Public License.
!
! This file takes control of the process from the kernel, as specified
! in section 3 of the System V Application Binary Interface, Intel386
! Processor Supplement. It has been constructed from information obtained
! from the ABI, information obtained from single stepping existing
! Solaris executables through their startup code with gdb, and from
! information obtained by single stepping executables on other i386 SVR4
! implementations. This file is the first thing linked into any executable.
.file "crt1.s"
.ident "GNU C crt1.s"
.weak _cleanup
.weak _DYNAMIC
.text
! Start creating the initial frame by pushing a NULL value for the return
! address of the initial frame, and mark the end of the stack frame chain
! (the innermost stack frame) with a NULL value, per page 3-32 of the ABI.
! Initialize the first stack frame pointer in %ebp (the contents of which
! are unspecified at process initialization).
.globl _start
_start:
pushl $0x0
pushl $0x0
movl %esp,%ebp
! As specified per page 3-32 of the ABI, %edx contains a function
! pointer that should be registered with atexit(), for proper
! shared object termination. Just push it onto the stack for now
! to preserve it. We want to register _cleanup() first.
pushl %edx
! Check to see if there is an _cleanup() function linked in, and if
! so, register it with atexit() as the last thing to be run by
! atexit().
movl $_cleanup,%eax
testl %eax,%eax
je .L1
pushl $_cleanup
call atexit
addl $0x4,%esp
.L1:
! Now check to see if we have an _DYNAMIC table, and if so then
! we need to register the function pointer previously in %edx, but
! now conveniently saved on the stack as the argument to pass to
! atexit().
movl $_DYNAMIC,%eax
testl %eax,%eax
je .L2
call atexit
.L2:
! Register _fini() with atexit(). We will take care of calling _init()
! directly.
pushl $_fini
call atexit
! Compute the address of the environment vector on the stack and load
! it into the global variable _environ. Currently argc is at 8 off
! the frame pointer. Fetch the argument count into %eax, scale by the
! size of each arg (4 bytes) and compute the address of the environment
! vector which is 16 bytes (the two zero words we pushed, plus argc,
! plus the null word terminating the arg vector) further up the stack,
! off the frame pointer (whew!).
movl 8(%ebp),%eax
leal 16(%ebp,%eax,4),%edx
movl %edx,_environ
! Push the environment vector pointer, the argument vector pointer,
! and the argument count on to the stack to set up the arguments
! for _init(), _fpstart(), and main(). Note that the environment
! vector pointer and the arg count were previously loaded into
! %edx and %eax respectively. The only new value we need to compute
! is the argument vector pointer, which is at a fixed address off
! the initial frame pointer.
pushl %edx
leal 12(%ebp),%edx
pushl %edx
pushl %eax
! Call _init(argc, argv, environ), _fpstart(argc, argv, environ), and
! main(argc, argv, environ).
call _init
call __fpstart
call main
! Pop the argc, argv, and environ arguments off the stack, push the
! value returned from main(), and call exit().
addl $12,%esp
pushl %eax
call exit
! An inline equivalent of _exit, as specified in Figure 3-26 of the ABI.
pushl $0x0
movl $0x1,%eax
lcall $7,$0
! If all else fails, just try a halt!
hlt
.type _start,@function
.size _start,.-_start
! A dummy profiling support routine for non-profiling executables,
! in case we link in some objects that have been compiled for profiling.
.globl _mcount
_mcount:
ret
.type _mcount,@function
.size _mcount,.-_mcount

View File

@ -0,0 +1,50 @@
! crti.s for Solaris 2, x86.
! Copyright (C) 1993 Free Software Foundation, Inc.
! Written By Fred Fish, Nov 1992
!
! This file is free software; you can redistribute it and/or modify it
! under the terms of the GNU General Public License as published by the
! Free Software Foundation; either version 2, or (at your option) any
! later version.
!
! In addition to the permissions in the GNU General Public License, the
! Free Software Foundation gives you unlimited permission to link the
! compiled version of this file with other programs, and to distribute
! those programs without any restriction coming from the use of this
! file. (The General Public License restrictions do apply in other
! respects; for example, they cover modification of the file, and
! distribution when not linked into another program.)
!
! This file 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
! General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; see the file COPYING. If not, write to
! the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
!
! As a special exception, if you link this library with files
! compiled with GCC to produce an executable, this does not cause
! the resulting executable to be covered by the GNU General Public License.
! This exception does not however invalidate any other reasons why
! the executable file might be covered by the GNU General Public License.
!
! This file just supplies labeled starting points for the .init and .fini
! sections. It is linked in before the values-Xx.o files and also before
! crtbegin.o.
.file "crti.s"
.ident "GNU C crti.s"
.section .init
.globl _init
.type _init,@function
_init:
.section .fini
.globl _fini
.type _fini,@function
_fini:

View File

@ -0,0 +1,45 @@
! crtn.s for Solaris 2, x86.
! Copyright (C) 1993 Free Software Foundation, Inc.
! Written By Fred Fish, Nov 1992
!
! This file is free software; you can redistribute it and/or modify it
! under the terms of the GNU General Public License as published by the
! Free Software Foundation; either version 2, or (at your option) any
! later version.
!
! In addition to the permissions in the GNU General Public License, the
! Free Software Foundation gives you unlimited permission to link the
! compiled version of this file with other programs, and to distribute
! those programs without any restriction coming from the use of this
! file. (The General Public License restrictions do apply in other
! respects; for example, they cover modification of the file, and
! distribution when not linked into another program.)
!
! This file 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
! General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; see the file COPYING. If not, write to
! the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
!
! As a special exception, if you link this library with files
! compiled with GCC to produce an executable, this does not cause
! the resulting executable to be covered by the GNU General Public License.
! This exception does not however invalidate any other reasons why
! the executable file might be covered by the GNU General Public License.
!
! This file just supplies returns for the .init and .fini sections. It is
! linked in after all other files.
.file "crtn.o"
.ident "GNU C crtn.o"
.section .init
ret $0x0
.section .fini
ret $0x0

33
gcc/config/i386/sol2.h Normal file
View File

@ -0,0 +1,33 @@
/* Target definitions for GNU compiler for Intel 80386 running Solaris 2
Copyright (C) 1993 Free Software Foundation, Inc.
Written by Fred Fish (fnf@cygnus.com).
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "i386/sysv4.h"
/* The Solaris 2.0 x86 linker botches alignment of code sections.
It tries to align to a 16 byte boundary by padding with 0x00000090
ints, rather than 0x90 bytes (nop). This generates trash in the
".init" section since the contribution from crtbegin.o is only 7
bytes. The linker pads it to 16 bytes with a single 0x90 byte, and
two 0x00000090 ints, which generates a segmentation violation when
executed. This macro forces the assembler to do the padding, since
it knows what it is doing. */
#define FORCE_INIT_SECTION_ALIGN do { asm (ALIGN_ASM_OP ## " 16"); } while (0)

28
gcc/config/i386/t-sol2 Normal file
View File

@ -0,0 +1,28 @@
# We need startup files for Solaris, since we don't get them with the system
# FIXME: Should include "gmon.o" when it is ported.
EXTRA_PARTS=crt1.o crti.o crtn.o crtbegin.o crtend.o
# we need to supply our own assembly versions of libgcc1.c files,
# since the user may not have native 'cc' available
LIBGCC1 = libgcc1.null
# gmon build rule:
gmon.o: $(srcdir)/config/i386/gmon-sol2.c $(GCC_PASSES) $(CONFIG_H)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \
-c $(srcdir)/config/i386/gmon-sol2.c -o gmon.o
# Assemble startup files.
# Apparently Sun believes that assembler files don't need comments, because no
# single ASCII character is valid (tried them all). So we manually strip out
# the comments with sed. This bug may only be in the Early Access releases.
crt1.o: $(srcdir)/config/i386/sol2-c1.asm
sed -e '/^!/d' <$(srcdir)/config/i386/sol2-c1.asm >crt1.s
$(AS) -o crt1.o crt1.s
crti.o: $(srcdir)/config/i386/sol2-ci.asm
sed -e '/^!/d' <$(srcdir)/config/i386/sol2-ci.asm >crti.s
$(AS) -o crti.o crti.s
crtn.o: $(srcdir)/config/i386/sol2-cn.asm
sed -e '/^!/d' <$(srcdir)/config/i386/sol2-cn.asm >crtn.s
$(AS) -o crtn.o crtn.s