crt0.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Startup code for SH & ELF.
  2. Copyright (C) 1999 Free Software Foundation, Inc.
  3. Copyright (C) 2001 Hewlett-Packard Australia
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. 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. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with the GNU C Library; see the file COPYING.LIB. If not,
  15. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. Boston, MA 02111-1307, USA. */
  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. r4 Contains a function pointer to be registered with `atexit'.
  21. This is how the dynamic linker arranges to have DT_FINI
  22. functions called for shared libraries that have been loaded
  23. before this code runs.
  24. WARNING: At that stage only static linker is supported. For
  25. uCLinux we won't bother with r4.
  26. sp The stack contains the arguments and environment:
  27. 0(sp) argc
  28. 4(sp) argv[0]
  29. ...
  30. (4*argc)(sp) NULL
  31. (4*(argc+1))(sp) envp[0]
  32. ...
  33. NULL
  34. */
  35. .text
  36. .globl _start
  37. _start:
  38. /* Clear the frame pointer since this is the outermost frame. */
  39. mov #0, r14
  40. /* Pop argc off the stack and save a pointer to argv */
  41. mov.l @r15+,r4
  42. mov r15, r5
  43. /* set up the value for the environment pointer
  44. r6 = (argc+1)*4+argv
  45. */
  46. mov r4,r6
  47. add #1,r6
  48. shll2 r6
  49. add r5,r6
  50. /* call main */
  51. mov.l L_main,r1
  52. jsr @r1
  53. nop
  54. /* should never get here....*/
  55. mov.l L_abort,r1
  56. jsr @r1
  57. nop
  58. .align 2
  59. L_main:
  60. .long __uClibc_main
  61. L_abort:
  62. .long abort
  63. .data