crt1.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * libc/sysdeps/linux/microblaze/crt1.S -- Initial program entry point for linux/microblaze
  3. *
  4. * Copyright (C) 2009 Meyer Sound Laboratories
  5. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  6. * Copyright (C) 2001,2002 NEC Corporation
  7. * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
  8. *
  9. * This file is subject to the terms and conditions of the GNU Lesser
  10. * General Public License. See the file COPYING.LIB in the main
  11. * directory of this archive for more details.
  12. *
  13. * Written by Miles Bader <miles@gnu.org>
  14. */
  15. #include <libc-symbols.h>
  16. /* Upon entry, the stack contains the following data:
  17. argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
  18. */
  19. .text
  20. .globl C_SYMBOL_NAME(_start)
  21. .align 4
  22. C_SYMBOL_NAME(_start):
  23. /*
  24. Preparing arguments for uClibc's startup routine.
  25. The routine has 6 arguments, so 5 of them are placed
  26. into registers, one on the stack
  27. */
  28. la r5, r0, C_SYMBOL_NAME(main) /* Arg 1: main() */
  29. lw r6, r0, r1 /* Arg 2: argc */
  30. addi r7, r1, 4 /* Arg 3: argv */
  31. la r8, r0, _init /* Arg 4: init */
  32. la r9, r0, _fini /* Arg 5: fini */
  33. addk r10,r0,r0 /* Arg 6: rtld_fini = NULL */
  34. /* Reserve space for __uClibc_main to save parameters
  35. (Microblaze ABI stack calling convention)
  36. and for stack_end argument to __uClibc_main */
  37. add r3, r1, r0
  38. addi r1, r1, -32
  39. /* tail-call uClibc's startup routine */
  40. brid C_SYMBOL_NAME(__uClibc_main)
  41. swi r3, r1, 28 /* Arg 7: stack end [DELAY SLOT] */
  42. /* Define a symbol for the first piece of initialized data. */
  43. .data
  44. .globl __data_start
  45. __data_start:
  46. .long 0
  47. .weak data_start
  48. data_start = __data_start