prt0.as 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Startup code for elf32-sparc
  2. Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Richard Henderson <[email protected]>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. .section ".text"
  18. .align 4
  19. .global _dynamic_start
  20. .type _dynamic_start,#function
  21. _dynamic_start:
  22. /* TODO: need to set __dl_fini here */
  23. b _start
  24. .align 4
  25. .global _start
  26. .type _start,#function
  27. _start:
  28. /* Terminate the stack frame, and reserve space for functions to
  29. drop their arguments. */
  30. mov %g0, %fp
  31. sub %sp, 6*4, %sp
  32. /* Extract the arguments and environment as encoded on the stack. The
  33. argument info starts after one register window (16 words) past the SP. */
  34. ld [%sp+22*4], %o2
  35. sethi %hi(operatingsystem_parameter_argc),%o1
  36. or %o1,%lo(operatingsystem_parameter_argc),%o1
  37. st %o2, [%o1]
  38. add %sp, 23*4, %o0
  39. sethi %hi(operatingsystem_parameter_argv),%o1
  40. or %o1,%lo(operatingsystem_parameter_argv),%o1
  41. st %o0, [%o1]
  42. /* envp=(argc+1)*4+argv */
  43. inc %o2
  44. sll %o2, 2, %o2
  45. add %o2, %o0, %o2
  46. sethi %hi(operatingsystem_parameter_envp),%o1
  47. or %o1,%lo(operatingsystem_parameter_envp),%o1
  48. st %o2, [%o1]
  49. /* Save initial stackpointer */
  50. sethi %hi(__stkptr),%o1
  51. or %o1,%lo(__stkptr),%o1
  52. st %sp, [%o1]
  53. /* Call the user program entry point. */
  54. call PASCALMAIN
  55. nop
  56. /* Die very horribly if main returns. */
  57. unimp
  58. .globl _haltproc
  59. .type _haltproc,@function
  60. _haltproc:
  61. /* TODO: need to check whether __dl_fini is non-zero and call the function pointer in case */
  62. mov 188, %g1 /* "exit_group" system call */
  63. ta 0x10 /* dot the system call */
  64. nop /* delay slot */
  65. /* Die very horribly if exit returns. */
  66. unimp
  67. .size _start, .-_start
  68. .comm __stkptr,4
  69. .comm __dl_fini,4
  70. .comm operatingsystem_parameter_envp,4
  71. .comm operatingsystem_parameter_argc,4
  72. .comm operatingsystem_parameter_argv,4