crt0.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * libc/sysdeps/linux/v850/crt0.S -- Initial program entry point for linux/v850
  3. *
  4. * Copyright (C) 2001 NEC Corporation
  5. * Copyright (C) 2001 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. 1: add 4, r8
  24. add -1, r10
  25. bp 1b
  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: sst.w r0, 0[ep]
  30. add 4, ep
  31. cmp ep, r10
  32. bne 2b
  33. // Load CTBP register
  34. mov hilo(C_SYMBOL_NAME(_ctbp)), r19
  35. ldsr r19, ctbp
  36. // Load GP
  37. mov hilo(C_SYMBOL_NAME(_gp)), gp
  38. // call uclibc's startup routine
  39. jarl C_SYMBOL_NAME(__uClibc_main), lp
  40. // should never get here....
  41. jr C_SYMBOL_NAME(abort)