crt1.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "crt1.S"
  30. .globl _start
  31. .type _start,%function
  32. .type main,%function
  33. .section .text64,"xa"
  34. .align 2 /* 2^2 = 4 */
  35. _start:
  36. /* __uClibc_main (main, argc, argv, init, fini) */
  37. movi __main, r18
  38. or r2, r63, r18
  39. /* Pop argc off the stack and save a pointer to argv */
  40. ld.l r15, 0, r3 /* argc */
  41. addi r15, 4, r4 /* argv */
  42. movi _init, r5
  43. movi _fini, r6
  44. /* call main() */
  45. movi __uClibc_main, r17
  46. ptabs/l r17, tr0
  47. blink tr0, r18
  48. /* should never get here....*/
  49. movi abort, r17
  50. ptabs/l r17, tr0
  51. blink tr0, r63 /* call abort() => (r63) do not come back ... */
  52. /*
  53. * The following is a stub to stop the GNU toolchain
  54. * from calling its C-RTL initialization routines.
  55. */
  56. __main:
  57. movi main, r18
  58. ptabs/l r18, tr0
  59. blink tr0, r63
  60. /* Define a symbol for the first piece of initialized data. */
  61. .data
  62. .globl __data_start
  63. __data_start:
  64. .long 0
  65. .weak data_start
  66. data_start = __data_start