crt1.S 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Startup code for Alpha/ELF.
  2. Copyright (C) 1993,1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Richard Henderson <rth@tamu.edu>
  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. #include <features.h>
  18. #include <asm/regdef.h>
  19. .text
  20. .global _start
  21. .ent _start,0
  22. .type _start,%function
  23. #if defined(__UCLIBC_CTOR_DTOR__)
  24. .type _init,%function
  25. .type _fini,%function
  26. #else
  27. .weak _init
  28. .weak _fini
  29. #endif
  30. .type __uClibc_main,%function
  31. /* Stick in a dummy reference to main(), so that if an application
  32. * is linking when the main() function is in a static library (.a)
  33. * we can be sure that main() actually gets linked in */
  34. .type main,%function
  35. _start:
  36. .frame $15, 0, $15
  37. br gp, 1f
  38. 1: ldgp gp, 0(gp)
  39. subq sp, 16, sp
  40. mov 0, $15
  41. .prologue 0
  42. /* Load address of the user's main function. */
  43. lda a0, main
  44. ldl a1, 16(sp) /* get argc */
  45. lda a2, 24(sp) /* get argv */
  46. /* Load address of our own entry points to .fini and .init. */
  47. lda a3, _init
  48. lda a4, _fini
  49. /* Store address of the shared library termination function. */
  50. mov v0, a5
  51. /* Provide the highest stack address to the user code. */
  52. stq sp, 0(sp)
  53. /* Call the user's main function, and exit with its value.
  54. * But let the libc call main. */
  55. jsr ra, __uClibc_main
  56. /* Die very horribly if exit returns. Call_pal hlt is callable from
  57. * kernel mode only; this will result in an illegal instruction trap. */
  58. call_pal 0
  59. .end _start
  60. /* Define a symbol for the first piece of initialized data. */
  61. .data
  62. .global __data_start
  63. __data_start:
  64. .long 0
  65. .weak data_start
  66. data_start = __data_start