crt0.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * libc/sysdeps/linux/v850/crt0.S -- Initial program entry point for linux/v850
  3. *
  4. * Copyright (C) 2001,2002 NEC Corporation
  5. * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU Lesser
  8. * General Public License. See the file COPYING.LIB in the main
  9. * directory of this archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #include <clinkage.h>
  14. /* Upon entry, the stack contains the following data:
  15. argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
  16. */
  17. .text
  18. C_ENTRY(start):
  19. ld.w 0[sp], r6 // Arg 0: argc
  20. addi 4, sp, r7 // Arg 1: argv
  21. mov r7, r8 // Arg 2: envp
  22. mov r6, r10 // skip argc elements to get envp start
  23. add 1, r10 // ...plus the NULL at the end of argv
  24. shl 2, r10 // Convert to byte-count to skip
  25. add r10, r8
  26. // Zero bss area, since we can't rely upon any loader to do so
  27. mov hilo(C_SYMBOL_NAME(edata)), ep
  28. mov hilo(C_SYMBOL_NAME(end)), r10
  29. 2: cmp ep, r10
  30. be 3f
  31. sst.w r0, 0[ep]
  32. add 4, ep
  33. br 2b
  34. // Load CTBP register
  35. 3: mov hilo(C_SYMBOL_NAME(_ctbp)), r19
  36. ldsr r19, ctbp
  37. // Load GP
  38. mov hilo(C_SYMBOL_NAME(_gp)), gp
  39. // call uclibc's startup routine
  40. jarl C_SYMBOL_NAME(__uClibc_main), lp
  41. // should never get here....
  42. jr C_SYMBOL_NAME(abort)