home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / config / sol2-c1.asm < prev    next >
Assembly Source File  |  1994-02-06  |  3KB  |  86 lines

  1. ! crt1.s for solaris 2.0.
  2.  
  3. !   Copyright (C) 1992 Free Software Foundation, Inc.
  4. !   Written By David Vinayak Henkel-Wallace, June 1992
  5. ! This file is free software; you can redistribute it and/or modify it
  6. ! under the terms of the GNU General Public License as published by the
  7. ! Free Software Foundation; either version 2, or (at your option) any
  8. ! later version.
  9. ! In addition to the permissions in the GNU General Public License, the
  10. ! Free Software Foundation gives you unlimited permission to link the
  11. ! compiled version of this file with other programs, and to distribute
  12. ! those programs without any restriction coming from the use of this
  13. ! file.  (The General Public License restrictions do apply in other
  14. ! respects; for example, they cover modification of the file, and
  15. ! distribution when not linked into another program.)
  16. ! This file is distributed in the hope that it will be useful, but
  17. ! WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19. ! General Public License for more details.
  20. ! You should have received a copy of the GNU General Public License
  21. ! along with this program; see the file COPYING.  If not, write to
  22. ! the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23. !    As a special exception, if you link this library with files
  24. !    compiled with GCC to produce an executable, this does not cause
  25. !    the resulting executable to be covered by the GNU General Public License.
  26. !    This exception does not however invalidate any other reasons why
  27. !    the executable file might be covered by the GNU General Public License.
  28.  
  29. ! This file takes control of the process from the kernel, as specified
  30. ! in section 3 of the SVr4 ABI.
  31. ! This file is the first thing linked into any executable.
  32.  
  33.     .section    ".text"
  34.     .proc    022
  35.     .global    _start
  36.  
  37. _start:
  38.     mov    0, %fp        ! Mark bottom frame pointer
  39.     ld    [%sp + 64], %l0    ! argc
  40.     add    %sp, 68, %l1    ! argv
  41.  
  42.     ! Leave some room for a call.  Sun leaves 32 octets (to sit on
  43.     ! a cache line?) so we do too.
  44.     sub    %sp, 32, %sp
  45.  
  46.     ! %g1 may contain a function to be registered w/atexit
  47.     orcc    %g0, %g1, %g0
  48.     be    .nope
  49.     mov    %g1, %o0
  50.     call    atexit
  51.     nop   
  52. .nope:
  53.     ! Now make sure constructors and destructors are handled.
  54.     set    _fini, %o0
  55.     call    atexit, 1
  56.     nop
  57.     call    _init, 0
  58.     nop
  59.  
  60.     ! We ignore the auxiliary vector; there's no defined way to
  61.     ! access those data anyway.  Instead, go straight to main:
  62.     mov    %l0, %o0    ! argc
  63.     mov    %l1, %o1    ! argv
  64.     ! Skip argc words past argv, to env:
  65.     sll    %l0, 2, %o2
  66.     add    %o2, 4, %o2
  67.     add    %l1, %o2, %o2    ! env
  68.     set    _environ, %o3
  69.     st    %o2, [%o3]    ! *_environ
  70.     call    main, 4
  71.     nop   
  72.     call    exit, 0
  73.     nop   
  74.     call    _exit, 0
  75.     nop   
  76.     ! We should never get here.
  77.  
  78.     .type    _start,#function
  79.     .size    _start,.-_start
  80.