crt0.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. _start:
  35. .frame fp, 0, zero
  36. mov zero, fp
  37. br gp, 1f
  38. 1: ldgp gp, 0(gp)
  39. subq sp, 16, sp
  40. .prologue 0
  41. ldl a0, 16(sp) /* get argc */
  42. lda a1, 24(sp) /* get argv */
  43. addq a0, 1, a2
  44. s8addq a2, a1, a2 /* Calculate environ */
  45. /* Call the user's main function, and exit with its value.
  46. But let the libc call main. */
  47. jsr ra, __uClibc_main
  48. /* Die very horribly if exit returns. Call_pal hlt is callable from
  49. kernel mode only; this will result in an illegal instruction trap. */
  50. call_pal 0
  51. .end _start
  52. /* For ECOFF backwards compatibility. */
  53. .weak __start;
  54. __start = _start
  55. /* Define a symbol for the first piece of initialized data. */
  56. .data
  57. .globl __data_start
  58. __data_start:
  59. .long 0
  60. .weak data_start
  61. data_start = __data_start