crt1.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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, see
  31. <http://www.gnu.org/licenses/>. */
  32. #include <features.h>
  33. #include <sys/regdef.h>
  34. .text
  35. .align 3
  36. .globl _start
  37. .ent _start, 0
  38. .type _start,@function
  39. #if defined(__UCLIBC_CTOR_DTOR__)
  40. .type _init,%function
  41. .type _fini,%function
  42. #else
  43. .weak _init
  44. .weak _fini
  45. #endif
  46. .type __uClibc_main,%function
  47. _start:
  48. .frame $15, 0, $15
  49. br gp, 1f
  50. 1: ldgp gp, 0(gp)
  51. subq sp, 16, sp
  52. mov 0, $15
  53. .prologue 0
  54. /* Load address of the user's main function. */
  55. lda a0, main
  56. ldl a1, 16(sp) /* get argc */
  57. lda a2, 24(sp) /* get argv */
  58. /* Load address of our own entry points to .fini and .init. */
  59. lda a3, _init
  60. lda a4, _fini
  61. /* Store address of the shared library termination function. */
  62. mov v0, a5
  63. /* Provide the highest stack address to the user code. */
  64. stq sp, 0(sp)
  65. /* Call the user's main function, and exit with its value.
  66. But let the libc call main. */
  67. jsr ra, __uClibc_main
  68. /* Die very horribly if exit returns. Call_pal hlt is callable from
  69. kernel mode only; this will result in an illegal instruction trap. */
  70. call_pal 0
  71. .end _start
  72. /* For ECOFF backwards compatibility. */
  73. /*weak_alias (_start, __start)*/
  74. /* Define a symbol for the first piece of initialized data. */
  75. .data
  76. .globl __data_start
  77. __data_start:
  78. .weak data_start
  79. data_start = __data_start