crt1.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Startup code for SH & ELF.
  2. Copyright (C) 1999 Free Software Foundation, Inc.
  3. Copyright (C) 2001 Hewlett-Packard Australia
  4. Copyright (C) 2002 Stefan Allius
  5. This program is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU Library General Public License as published by the Free
  7. Software Foundation; either version 2 of the License, or (at your option) any
  8. later version.
  9. This program is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  12. details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this program; if not, write to the Free Software Foundation, Inc.,
  15. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. /* This is the canonical entry point, usually the first thing in the text
  18. segment.
  19. At this entry point, most registers' values are unspecified, except:
  20. sp The stack contains the arguments and environment:
  21. 0(sp) argc
  22. 4(sp) argv[0]
  23. ...
  24. (4*argc)(sp) NULL
  25. (4*(argc+1))(sp) envp[0]
  26. ...
  27. NULL
  28. */
  29. #include <features.h>
  30. .text
  31. .globl _start
  32. .type _start,%function
  33. .type main,%function
  34. _start:
  35. /* Clear the frame pointer since this is the outermost frame. */
  36. mov #0, r14
  37. /* Pop argc off the stack and save a pointer to argv */
  38. mov.l @r15+,r5
  39. mov r15, r6
  40. /* Push the fini func onto the stack */
  41. mov.l r4,@-r15
  42. mov.l L_fini,r0
  43. mov.l r0,@-r15
  44. /* Set up the main/init funcs that go in registers */
  45. mov.l L_main,r4
  46. mov.l L_init,r7
  47. /* __uClibc_main (main, argc, argv, init, fini) */
  48. /* Let the libc call main and exit with its return code. */
  49. mov.l L_uClibc_main,r1
  50. jsr @r1
  51. nop
  52. /* We should not get here. */
  53. mov.l L_abort,r1
  54. jmp @r1
  55. nop
  56. .size _start,.-_start
  57. .align 2
  58. L_main:
  59. .long main
  60. L_init:
  61. .long _init
  62. L_fini:
  63. .long _fini
  64. L_uClibc_main:
  65. .long __uClibc_main
  66. L_abort:
  67. .long abort
  68. /* Define a symbol for the first piece of initialized data. */
  69. .data
  70. .globl __data_start
  71. __data_start:
  72. .long 0
  73. .weak data_start
  74. data_start = __data_start