prt0.as 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. .ifdef PIC
  33. /* Set %l7 to _GLOBAL_OFFSET_TABLE value */
  34. sethi %hi(_GLOBAL_OFFSET_TABLE_-8),%l7
  35. or %l7,%lo(_GLOBAL_OFFSET_TABLE_-4),%l7
  36. call FPC_GETGOT
  37. nop
  38. .endif
  39. /* Extract the arguments and environment as encoded on the stack. The
  40. argument info starts after one register window (16 words) past the SP. */
  41. ld [%sp+22*4], %o2
  42. sethi %hi(operatingsystem_parameter_argc),%o1
  43. or %o1,%lo(operatingsystem_parameter_argc),%o1
  44. .ifdef PIC
  45. ld [%o1+%l7],%o1
  46. .endif
  47. st %o2, [%o1]
  48. add %sp, 23*4, %o0
  49. sethi %hi(operatingsystem_parameter_argv),%o1
  50. or %o1,%lo(operatingsystem_parameter_argv),%o1
  51. .ifdef PIC
  52. ld [%o1+%l7],%o1
  53. .endif
  54. st %o0, [%o1]
  55. /* envp=(argc+1)*4+argv */
  56. inc %o2
  57. sll %o2, 2, %o2
  58. add %o2, %o0, %o2
  59. sethi %hi(operatingsystem_parameter_envp),%o1
  60. or %o1,%lo(operatingsystem_parameter_envp),%o1
  61. .ifdef PIC
  62. ld [%o1+%l7],%o1
  63. .endif
  64. st %o2, [%o1]
  65. /* Save initial stackpointer */
  66. sethi %hi(__stkptr),%o1
  67. or %o1,%lo(__stkptr),%o1
  68. .ifdef PIC
  69. ld [%o1+%l7],%o1
  70. .endif
  71. st %sp, [%o1]
  72. /* Call the user program entry point. */
  73. call PASCALMAIN
  74. nop
  75. /* Die very horribly if main returns. */
  76. unimp
  77. .globl _haltproc
  78. .type _haltproc,@function
  79. _haltproc:
  80. /* TODO: need to check whether __dl_fini is non-zero and call the function pointer in case */
  81. mov 188, %g1 /* "exit_group" system call */
  82. ta 0x10 /* dot the system call */
  83. nop /* delay slot */
  84. /* Die very horribly if exit returns. */
  85. unimp
  86. .size _start, .-_start
  87. .comm __stkptr,4
  88. .comm __dl_fini,4
  89. .comm operatingsystem_parameter_envp,4
  90. .comm operatingsystem_parameter_argc,4
  91. .comm operatingsystem_parameter_argv,4