crt1.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. see <http://www.gnu.org/licenses/>. */
  16. /* This is the canonical entry point, usually the first thing in the text
  17. segment.
  18. At this entry point, most registers' values are unspecified, except:
  19. sp The stack contains the arguments and environment:
  20. 0(sp) argc
  21. 4(sp) argv[0]
  22. ...
  23. (4*argc)(sp) NULL
  24. (4*(argc+1))(sp) envp[0]
  25. ...
  26. NULL
  27. */
  28. .file "crt1.S"
  29. .globl _start
  30. .type _start,%function
  31. .type main,%function
  32. .section .text64,"xa"
  33. .align 2 /* 2^2 = 4 */
  34. _start:
  35. /* __uClibc_main (main, argc, argv, init, fini) */
  36. movi __main, r18
  37. or r2, r63, r18
  38. /* Pop argc off the stack and save a pointer to argv */
  39. ld.l r15, 0, r3 /* argc */
  40. addi r15, 4, r4 /* argv */
  41. movi _init, r5
  42. movi _fini, r6
  43. /* call main() */
  44. movi __uClibc_main, r17
  45. ptabs/l r17, tr0
  46. blink tr0, r18
  47. /* should never get here....*/
  48. movi abort, r17
  49. ptabs/l r17, tr0
  50. blink tr0, r63 /* call abort() => (r63) do not come back ... */
  51. /*
  52. * The following is a stub to stop the GNU toolchain
  53. * from calling its C-RTL initialization routines.
  54. */
  55. __main:
  56. movi main, r18
  57. ptabs/l r18, tr0
  58. blink tr0, r63
  59. /* Define a symbol for the first piece of initialized data. */
  60. .data
  61. .globl __data_start
  62. __data_start:
  63. .long 0
  64. .weak data_start
  65. data_start = __data_start