prt0.as 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # $Id$
  2. /* Startup code for elf32-sparc
  3. Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by Richard Henderson <[email protected]>, 1997.
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2.1 of the License, or (at your option) any later version.
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with the GNU C Library; if not, write to the Free
  16. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17. 02111-1307 USA. */
  18. .section ".text"
  19. .align 4
  20. .global _start
  21. .type _start,#function
  22. _start:
  23. /* Terminate the stack frame, and reserve space for functions to
  24. drop their arguments. */
  25. mov %g0, %fp
  26. sub %sp, 6*4, %sp
  27. /* Extract the arguments and environment as encoded on the stack. The
  28. argument info starts after one register window (16 words) past the SP. */
  29. ld [%sp+22*4], %o1
  30. add %sp, 23*4, %o2
  31. /* Load the addresses of the user entry points. */
  32. sethi %hi(main), %o0
  33. sethi %hi(fpc_initialize), %o3
  34. sethi %hi(fpc_finalize), %o4
  35. or %o0, %lo(main), %o0
  36. or %o3, %lo(fpc_initialize), %o3
  37. or %o4, %lo(fpc_finalize), %o4
  38. /* When starting a binary via the dynamic linker, %g1 contains the
  39. address of the shared library termination function, which will be
  40. registered with atexit(). If we are statically linked, this will
  41. be NULL. */
  42. mov %g1, %o5
  43. /* Call the user program entry point. */
  44. call PASCALMAIN
  45. nop
  46. .globl _haltproc
  47. .type _haltproc,@function
  48. _haltproc:
  49. mov 1, %g1 /* "exit" system call */
  50. sethi %hi(U_SYSTEM_EXITCODE),%o0
  51. or %o0,%lo(U_SYSTEM_EXITCODE),%o0
  52. ld [%o0], %o0 /* give exit status to parent process*/
  53. ta 0x10 /* dot the system call */
  54. nop /* delay slot */
  55. /* and what if it goes wrong? just retry! */
  56. call _haltproc
  57. /* Die very horribly if exit returns. */
  58. unimp
  59. .size _start, .-_start
  60. # $Log$
  61. # Revision 1.5 2004-03-16 10:19:11 mazen
  62. # + _haltproc definition for linux/sparc
  63. #
  64. # Revision 1.4 2003/06/02 22:03:37 mazen
  65. # *making init and fini symbols compatible FPC code by
  66. # changing _init ==> fpc_initialize
  67. # and _fini ==> fpc_finalize
  68. #
  69. # Revision 1.3 2002/11/18 19:03:46 mazen
  70. # * start code of gcc adapted for FPC
  71. #