crt1.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <features.h>
  7. .text
  8. #ifndef __UCLIBC_CTOR_DTOR__
  9. .weak _init
  10. .weak _fini
  11. #endif
  12. /* Stick in a dummy reference to main(), so that if an application
  13. * is linking when the main() function is in a static library (.a)
  14. * we can be sure that main() actually gets linked in
  15. */
  16. .type main,@function
  17. .type _main,@function
  18. /* When we enter this piece of code, the program stack looks like this:
  19. argc argument counter (integer)
  20. argv[0] program name (pointer)
  21. argv[1...N] program args (pointers)
  22. argv[argc-1] end of args (integer)
  23. NULL
  24. env[0...N] environment variables (pointers)
  25. NULL
  26. */
  27. .text
  28. .align 4
  29. .global __start
  30. .hidden __start
  31. .type __start,@function
  32. __start:
  33. mov fp, 0
  34. ld_s r1, [sp] ; argc
  35. mov_s r5, r0 ; rltd_fini
  36. add_s r2, sp, 4 ; argv
  37. mov_s r0, main
  38. mov_s r3, _init
  39. mov r4, _fini
  40. and sp, sp, -8
  41. mov r6, sp
  42. /* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
  43. bl __uClibc_main
  44. /* Should never get here.... */
  45. flag 1
  46. .size __start,.-__start