crt1.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <sysdep.h>
  8. .text
  9. #ifndef __UCLIBC_CTOR_DTOR__
  10. .weak _init
  11. .weak _fini
  12. #endif
  13. /* Stick in a dummy reference to main(), so that if an application
  14. * is linking when the main() function is in a static library (.a)
  15. * we can be sure that main() actually gets linked in
  16. */
  17. .type main,@function
  18. .type _main,@function
  19. /* When we enter this piece of code, the program stack looks like this:
  20. argc argument counter (integer)
  21. argv[0] program name (pointer)
  22. argv[1...N] program args (pointers)
  23. argv[argc-1] end of args (integer)
  24. NULL
  25. env[0...N] environment variables (pointers)
  26. NULL
  27. */
  28. ENTRY(__start)
  29. mov fp, 0
  30. ld_s r1, [sp] ; argc
  31. mov_s r5, r0 ; rltd_fini
  32. add_s r2, sp, 4 ; argv
  33. mov_s r0, main
  34. mov_s r3, _init
  35. mov r4, _fini
  36. and sp, sp, -8
  37. mov r6, sp
  38. /* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
  39. bl __uClibc_main
  40. /* Should never get here.... */
  41. flag 1
  42. END(__start)
  43. libc_hidden_def(__start)