crt1.S 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Startup code for Alpha/ELF.
  2. Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003
  3. Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by Richard Henderson <rth@tamu.edu>
  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. In addition to the permissions in the GNU Lesser General Public
  11. License, the Free Software Foundation gives you unlimited
  12. permission to link the compiled version of this file with other
  13. programs, and to distribute those programs without any restriction
  14. coming from the use of this file. (The GNU Lesser General Public
  15. License restrictions do apply in other respects; for example, they
  16. cover modification of the file, and distribution when not linked
  17. into another program.)
  18. Note that people who make modified versions of this file are not
  19. obligated to grant this special exception for their modified
  20. versions; it is their choice whether to do so. The GNU Lesser
  21. General Public License gives permission to release a modified
  22. version without this exception; this exception also makes it
  23. possible to release a modified version which carries forward this
  24. exception.
  25. The GNU C Library is distributed in the hope that it will be useful,
  26. but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  28. Lesser General Public License for more details.
  29. You should have received a copy of the GNU Lesser General Public
  30. License along with the GNU C Library; if not, write to the Free
  31. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  32. 02111-1307 USA. */
  33. #include <features.h>
  34. #include <sys/regdef.h>
  35. .text
  36. .align 3
  37. .globl _start
  38. .ent _start, 0
  39. .type _start,@function
  40. #if defined(__UCLIBC_CTOR_DTOR__)
  41. .type _init,%function
  42. .type _fini,%function
  43. #else
  44. .weak _init
  45. .weak _fini
  46. #endif
  47. .type __uClibc_main,%function
  48. _start:
  49. .frame $15, 0, $15
  50. br gp, 1f
  51. 1: ldgp gp, 0(gp)
  52. subq sp, 16, sp
  53. mov 0, $15
  54. .prologue 0
  55. /* Load address of the user's main function. */
  56. lda a0, main
  57. ldl a1, 16(sp) /* get argc */
  58. lda a2, 24(sp) /* get argv */
  59. /* Load address of our own entry points to .fini and .init. */
  60. lda a3, _init
  61. lda a4, _fini
  62. /* Store address of the shared library termination function. */
  63. mov v0, a5
  64. /* Provide the highest stack address to the user code. */
  65. stq sp, 0(sp)
  66. /* Call the user's main function, and exit with its value.
  67. But let the libc call main. */
  68. jsr ra, __uClibc_main
  69. /* Die very horribly if exit returns. Call_pal hlt is callable from
  70. kernel mode only; this will result in an illegal instruction trap. */
  71. call_pal 0
  72. .end _start
  73. /* For ECOFF backwards compatibility. */
  74. /*weak_alias (_start, __start)*/
  75. /* Define a symbol for the first piece of initialized data. */
  76. .data
  77. .globl __data_start
  78. __data_start:
  79. .weak data_start
  80. data_start = __data_start