crt0.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #
  2. # crt0.S, part of the i960 support for the uClibc library.
  3. #
  4. # Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.com/
  5. #
  6. # This program is free software; you can redistribute it and/or modify it under
  7. # the terms of the GNU Library General Public License as published by the Free
  8. # Software Foundation; either version 2 of the License, or (at your option) any
  9. # later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but WITHOUT
  12. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  14. # details.
  15. #
  16. # You should have received a copy of the GNU Library General Public License
  17. # along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. #
  19. /*
  20. *
  21. * The behavior in this file is tightly coupled with how the linux kernel sets things up
  22. * on the stack before calling us.
  23. *
  24. * Currently fs/binfmt_flat.c (for STACK_GROWS_UP) and arch/i960/kernel/process.c
  25. * build things so that a pointer to argc is left in g13 by start_thread().
  26. *
  27. * ^
  28. * | <- sp somewhere around here, after being aligned.
  29. * |
  30. * |envp -> envp[0]
  31. * |argv -> argv[0]
  32. * |argc <- g13
  33. *
  34. * A complete picture of how things are set up can be seen in the comments of
  35. * create_flat_tables_stack_grows_up in fs/binfmt_flat.c
  36. *
  37. * I believe having to use this register could probably be avoided.
  38. *
  39. */
  40. .globl start
  41. start:
  42. mov g13, r3
  43. ldt (r3), g0
  44. callx ___uClibc_main
  45. /* We might want to add some instruction so that it crashes if main returns */
  46. /* Define a symbol for the first piece of initialized data. */
  47. .data
  48. .globl __data_start
  49. __data_start:
  50. .long 0
  51. .weak data_start
  52. data_start = __data_start