prt0.as 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Startup code for programs linked with GNU libc.
  2. Copyright (C) 1998, 1999, 2000, 2001 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. .section ".text"
  17. .globl _start
  18. _start:
  19. mr 26,1
  20. /* Set up an initial stack frame, and clear the LR. */
  21. clrrwi 1,1,4
  22. li 0,0
  23. stwu 1,-16(1)
  24. mtlr 0
  25. stw 0,0(1)
  26. lwz 3,0(26) /* get argc */
  27. lis 11,U_SYSTEM_ARGC@ha
  28. stw 3,U_SYSTEM_ARGC@l(11);
  29. addi 4,26,4 /* get argv */
  30. lis 11,U_SYSTEM_ARGV@ha
  31. stw 4,U_SYSTEM_ARGV@l(11);
  32. addi 27,3,1 /* calculate argc + 1 into r27 */
  33. slwi 27,27,2 /* calculate (argc + 1) * sizeof(char *) into r27 */
  34. add 5,4,27 /* get address of env[0] */
  35. lis 11,U_SYSTEM_ENVP@ha
  36. stw 5,U_SYSTEM_ENVP@l(11);
  37. bl PASCALMAIN
  38. .globl _haltproc
  39. .type _haltproc,@function
  40. _haltproc:
  41. li 0,1 /* exit call */
  42. lis 3,U_SYSTEM_EXITCODE@h
  43. stw 3,U_SYSTEM_EXITCODE@l(3)
  44. sc
  45. b _haltproc
  46. /* Define a symbol for the first piece of initialized data. */
  47. .section ".data"
  48. .globl __data_start
  49. __data_start:
  50. data_start:
  51. .globl ___fpc_brk_addr /* heap management */
  52. .type ___fpc_brk_addr,@object
  53. .size ___fpc_brk_addr,4
  54. ___fpc_brk_addr:
  55. .long 0
  56. /*
  57. $Log$
  58. Revision 1.1 2003-05-20 23:56:40 florian
  59. * basic setup; derived from FreeBSD and Linux
  60. Revision 1.10 2003/05/12 22:36:45 florian
  61. + added setup of argv, argc and envp
  62. Revision 1.9 2002/09/07 16:01:20 peter
  63. * old logs removed and tabs fixed
  64. Revision 1.8 2002/08/31 21:29:57 florian
  65. * several PC related fixes
  66. Revision 1.7 2002/08/31 16:13:12 florian
  67. * made _start global
  68. Revision 1.6 2002/08/31 14:02:23 florian
  69. * r3 renamed to 3
  70. Revision 1.5 2002/08/31 14:01:28 florian
  71. * _haltproc to prt0.as added (Linux/PPC)
  72. Revision 1.4 2002/08/31 13:11:11 florian
  73. * several fixes for Linux/PPC compilation
  74. Revision 1.3 2002/08/19 21:19:15 florian
  75. * small fixes
  76. Revision 1.2 2002/07/26 17:09:44 florian
  77. * log fixed
  78. Revision 1.1 2002/07/26 16:57:40 florian
  79. + initial version, plain copy from glibc/sysdeps/powerpc/elf/start.S
  80. */