prt0.as 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Startup code for ARM & ELF
  2. Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002 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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /* This is the canonical entry point, usually the first thing in the text
  17. segment.
  18. Note that the code in the .init section has already been run.
  19. This includes _init and _libc_init
  20. At this entry point, most registers' values are unspecified, except:
  21. a1 Contains a function pointer to be registered with `atexit'.
  22. This is how the dynamic linker arranges to have DT_FINI
  23. functions called for shared libraries that have been loaded
  24. before this code runs.
  25. sp The stack contains the arguments and environment:
  26. 0(sp) argc
  27. 4(sp) argv[0]
  28. ...
  29. (4*argc)(sp) NULL
  30. (4*(argc+1))(sp) envp[0]
  31. ...
  32. NULL
  33. */
  34. .text
  35. .globl _start
  36. .type _start,#function
  37. _start:
  38. /* Fetch address of fini */
  39. ldr ip, =__libc_csu_fini
  40. /* Clear the frame pointer since this is the outermost frame. */
  41. mov fp, #0
  42. /* Pop argc off the stack and save a pointer to argv */
  43. ldr a2, [sp], #4
  44. mov a3, sp
  45. /* Push stack limit */
  46. str a3, [sp, #-4]!
  47. /* Push rtld_fini */
  48. str a1, [sp, #-4]!
  49. /* Set up the other arguments in registers */
  50. ldr a1, =main
  51. ldr a4, =__libc_csu_init
  52. /* Push fini */
  53. str ip, [sp, #-4]!
  54. /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
  55. /* Let the libc call main and exit with its return code. */
  56. bl PASCALMAIN
  57. /* should never get here....*/
  58. bl abort
  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
  66. /*
  67. $Log$
  68. Revision 1.1 2003-08-27 13:07:07 florian
  69. * initial revision of arm startup code
  70. */