crt0.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // Load SDAs
  29. la r2, r0, C_SYMBOL_NAME(_SDA_BASE_)
  30. la r13, r0, C_SYMBOL_NAME(_SDA2_BASE_)
  31. // tail-call uclibc's startup routine
  32. brid C_SYMBOL_NAME(__uClibc_main)
  33. nop
  34. /* Stick in a dummy reference to `main', so that if an application
  35. is linking when the `main' function is in a static library (.a)
  36. we can be sure that `main' actually gets linked in. */
  37. L_dummy_main_reference:
  38. .long C_SYMBOL_NAME(main)
  39. /* Define a symbol for the first piece of initialized data. */
  40. .data
  41. .globl __data_start
  42. __data_start:
  43. .long 0
  44. .weak data_start
  45. data_start = __data_start