crt0.S 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Startup code for SH5 & 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. 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. .file "crt0.S"
  30. .globl _start
  31. .globl __main
  32. .type __uClibc_start_main,@function
  33. .section .text64,"xa"
  34. .align 2 /* 2^2 = 4 */
  35. _start:
  36. /* Clear the frame pointer since this is the outermost frame. */
  37. ### mov #0, r14 # qqq
  38. /* Pop argc off the stack and save a pointer to argv */
  39. ld.l r15, 0, r2 /* argc */
  40. addi r15, 4, r3 /* argv */
  41. /* set up the value for the environment pointer r4 = (argc+1)*4+argv */
  42. addi r2, 1, r4 /* envp = argc + 1 */
  43. shlli r4, 2, r4 /* envp = envp * 4 */
  44. add r3, r4, r4 /* envp = envp + argv */
  45. /* call main() */
  46. movi __uClibc_start_main,r17
  47. ptabs/l r17,tr0
  48. blink tr0,r18
  49. /* should never get here....*/
  50. ### movi abort@lh,r17
  51. ### shori abort@ll,r17
  52. ptabs/l r17,tr0
  53. blink tr0,r63 /* call abort() => (r63) do not come back ... */
  54. /*
  55. * The following is a stub to stop the GNU toolchain
  56. * from calling its C-RTL initialization routines.
  57. */
  58. __main:
  59. ptabs/l r18,tr0
  60. blink tr0,r63
  61. /* Define a symbol for the first piece of initialized data. */
  62. .data
  63. .globl __data_start
  64. __data_start:
  65. .long 0
  66. .weak data_start
  67. data_start = __data_start