start.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Startup code for SH & ELF.
  2. Copyright (C) 1999-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. In addition to the permissions in the GNU Lesser General Public
  9. License, the Free Software Foundation gives you unlimited
  10. permission to link the compiled version of this file with other
  11. programs, and to distribute those programs without any restriction
  12. coming from the use of this file. (The GNU Lesser General Public
  13. License restrictions do apply in other respects; for example, they
  14. cover modification of the file, and distribution when not linked
  15. into another program.)
  16. Note that people who make modified versions of this file are not
  17. obligated to grant this special exception for their modified
  18. versions; it is their choice whether to do so. The GNU Lesser
  19. General Public License gives permission to release a modified
  20. version without this exception; this exception also makes it
  21. possible to release a modified version which carries forward this
  22. exception.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <http://www.gnu.org/licenses/>. */
  30. /* This is the canonical entry point, usually the first thing in the text
  31. segment.
  32. Note that the code in the .init section has already been run.
  33. This includes _init and _libc_init
  34. At this entry point, most registers' values are unspecified, except:
  35. r4 Contains a function pointer to be registered with `atexit'.
  36. This is how the dynamic linker arranges to have DT_FINI
  37. functions called for shared libraries that have been loaded
  38. before this code runs.
  39. sp The stack contains the arguments and environment:
  40. 0(sp) argc
  41. 4(sp) argv[0]
  42. ...
  43. (4*argc)(sp) NULL
  44. (4*(argc+1))(sp) envp[0]
  45. ...
  46. NULL
  47. */
  48. .text
  49. .globl _start
  50. .type _start,@function
  51. _start:
  52. /* Clear the frame pointer since this is the outermost frame. */
  53. mov #0, r14
  54. /* Pop argc off the stack and save a pointer to argv */
  55. mov.l @r15+,r5
  56. mov r15, r6
  57. /* Push the last arguments to main() onto the stack */
  58. mov.l r4,@-r15
  59. mov.l L_fini,r0
  60. mov.l r0,@-r15
  61. /* Set up the other arguments for main() that go in registers */
  62. mov.l L_main,r4
  63. mov.l L_init,r7
  64. /* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
  65. /* Let the libc call main and exit with its return code. */
  66. mov.l L_libc_start_main,r1
  67. jsr @r1
  68. nop
  69. /* should never get here....*/
  70. mov.l L_abort,r1
  71. jsr @r1
  72. nop
  73. .align 2
  74. L_main:
  75. .long main
  76. L_init:
  77. .long __libc_csu_init
  78. L_fini:
  79. .long __libc_csu_fini
  80. L_libc_start_main:
  81. .long __libc_start_main
  82. L_abort:
  83. .long abort
  84. /* Define a symbol for the first piece of initialized data. */
  85. .data
  86. .globl __data_start
  87. __data_start:
  88. .long 0
  89. .weak data_start
  90. data_start = __data_start
  91. .global __fpscr_values
  92. __fpscr_values:
  93. .long 0
  94. .long 0x80000