home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gcc-2.7.2.1-base.tgz / gcc-2.7.2.1-base.tar / fsf / gcc / config / sparc / sol2-c1.asm < prev    next >
Assembly Source File  |  1995-06-15  |  3KB  |  87 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, 59 Temple Place - Suite 330,
  23. ! Boston, MA 02111-1307, USA.
  24. !    As a special exception, if you link this library with files
  25. !    compiled with GCC to produce an executable, this does not cause
  26. !    the resulting executable to be covered by the GNU General Public License.
  27. !    This exception does not however invalidate any other reasons why
  28. !    the executable file might be covered by the GNU General Public License.
  29.  
  30. ! This file takes control of the process from the kernel, as specified
  31. ! in section 3 of the SVr4 ABI.
  32. ! This file is the first thing linked into any executable.
  33.  
  34.     .section    ".text"
  35.     .proc    022
  36.     .global    _start
  37.  
  38. _start:
  39.     mov    0, %fp        ! Mark bottom frame pointer
  40.     ld    [%sp + 64], %l0    ! argc
  41.     add    %sp, 68, %l1    ! argv
  42.  
  43.     ! Leave some room for a call.  Sun leaves 32 octets (to sit on
  44.     ! a cache line?) so we do too.
  45.     sub    %sp, 32, %sp
  46.  
  47.     ! %g1 may contain a function to be registered w/atexit
  48.     orcc    %g0, %g1, %g0
  49.     be    .nope
  50.     mov    %g1, %o0
  51.     call    atexit
  52.     nop   
  53. .nope:
  54.     ! Now make sure constructors and destructors are handled.
  55.     set    _fini, %o0
  56.     call    atexit, 1
  57.     nop
  58.     call    _init, 0
  59.     nop
  60.  
  61.     ! We ignore the auxiliary vector; there's no defined way to
  62.     ! access those data anyway.  Instead, go straight to main:
  63.     mov    %l0, %o0    ! argc
  64.     mov    %l1, %o1    ! argv
  65.     ! Skip argc words past argv, to env:
  66.     sll    %l0, 2, %o2
  67.     add    %o2, 4, %o2
  68.     add    %l1, %o2, %o2    ! env
  69.     set    _environ, %o3
  70.     st    %o2, [%o3]    ! *_environ
  71.     call    main, 4
  72.     nop   
  73.     call    exit, 0
  74.     nop   
  75.     call    _exit, 0
  76.     nop   
  77.     ! We should never get here.
  78.  
  79.     .type    _start,#function
  80.     .size    _start,.-_start
  81.