crt0.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * libc/sysdeps/linux/microblaze/crt0.S -- Initial program entry point for linux/microblaze
  3. *
  4. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  5. * Copyright (C) 2001,2002 NEC Corporation
  6. * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU Lesser
  9. * General Public License. See the file COPYING.LIB in the main
  10. * directory of this archive for more details.
  11. *
  12. * Written by Miles Bader <miles@gnu.org>
  13. */
  14. #include <clinkage.h>
  15. /* Upon entry, the stack contains the following data:
  16. argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
  17. */
  18. .text
  19. C_ENTRY(_start):
  20. lw r5, r0, r1 /* Arg 0: argc */
  21. addi r6, r1, 4 /* Arg 1: argv */
  22. /* Arg 2: envp */
  23. addi r3, r5, 1 /* skip argc elements to get envp start */
  24. /* ...plus the NULL at the end of argv */
  25. add r3, r3, r3 /* Make word offset */
  26. add r3, r3, r3
  27. add r7, r6, r3 /* add to argv to get offset */
  28. /* tail-call uclibc's startup routine */
  29. brid C_SYMBOL_NAME(__uClibc_main)
  30. nop
  31. /* Stick in a dummy reference to `main', so that if an application
  32. is linking when the `main' function is in a static library (.a)
  33. we can be sure that `main' actually gets linked in. */
  34. L_dummy_main_reference:
  35. .long C_SYMBOL_NAME(main)
  36. /* Define a symbol for the first piece of initialized data. */
  37. .data
  38. .globl __data_start
  39. __data_start:
  40. .long 0
  41. .weak data_start
  42. data_start = __data_start