crt0.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #define a0 $16 /* argument registers (caller-saved) */
  18. #define a1 $17
  19. #define a2 $18
  20. #define a3 $19
  21. #define a4 $20
  22. #define a5 $21
  23. #define ra $26 /* return address register */
  24. #define s6 $15
  25. #define fp s6 /* frame-pointer (s6 in frame-less procedures) */
  26. #define gp $29 /* global pointer */
  27. #define sp $30 /* stack pointer */
  28. #define zero $31 /* reads as zero, writes are noops */
  29. .text
  30. .align 3
  31. .globl _start
  32. .ent _start, 0
  33. .type _start,@function
  34. #if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
  35. .type __uClibc_main,@function
  36. #else
  37. .weak _init
  38. .weak _fini
  39. .type __uClibc_start_main,@function
  40. #endif
  41. /* Stick in a dummy reference to main(), so that if an application
  42. * is linking when the main() function is in a static library (.a)
  43. * we can be sure that main() actually gets linked in */
  44. .type main,@function
  45. _start:
  46. .frame fp, 0, zero
  47. mov zero, fp
  48. br gp, 1f
  49. 1: ldgp gp, 0(gp)
  50. subq sp, 16, sp
  51. .prologue 0
  52. ldl a0, 16(sp) /* get argc */
  53. lda a1, 24(sp) /* get argv */
  54. addq a0, 1, a2
  55. s8addq a2, a1, a2 /* Calculate environ */
  56. /* Call the user's main function, and exit with its value.
  57. But let the libc call main. */
  58. jsr ra, __uClibc_main
  59. /* Die very horribly if exit returns. Call_pal hlt is callable from
  60. kernel mode only; this will result in an illegal instruction trap. */
  61. call_pal 0
  62. .end _start
  63. /* For ECOFF backwards compatibility. */
  64. .weak __start;
  65. __start = _start
  66. /* Define a symbol for the first piece of initialized data. */
  67. .data
  68. .globl __data_start
  69. __data_start:
  70. .long 0
  71. .weak data_start
  72. data_start = __data_start