start.S 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This is the canonical entry point, usually the first thing in the text
  2. segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
  3. point runs, most registers' values are unspecified, except for:
  4. %rdx Contains a function pointer to be registered with `atexit'.
  5. This is how the dynamic linker arranges to have DT_FINI
  6. functions called for shared libraries that have been loaded
  7. before this code runs.
  8. %rsp The stack contains the arguments and environment:
  9. 0(%rsp) argc
  10. 8(%rsp) argv[0]
  11. ...
  12. (8*argc)(%rsp) NULL
  13. (8*(argc+1))(%rsp) envp[0]
  14. ...
  15. NULL
  16. */
  17. .text
  18. .globl shim_start
  19. .type shim_start,@function
  20. shim_start:
  21. .cfi_startproc
  22. # Clear the frame pointer. The ABI suggests this be done, to mark
  23. # the outermost frame obviously.
  24. xorq %rbp, %rbp
  25. # Arguments for shim_init:
  26. movq 0(%rsp), %rdi # argc
  27. leaq 8(%rsp), %rsi # args
  28. # Required by System V AMD64 ABI.
  29. andq $~0xF, %rsp
  30. callq *shim_init@GOTPCREL(%rip)
  31. # TODO: Call initial %rdi to execute atexit callbacks.
  32. .cfi_endproc