__start_context.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (C) 2002-2012 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Andreas Jaeger <aj@suse.de>, 2002.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. /* This is the helper code which gets called if a function which is
  17. registered with 'makecontext' returns. In this case we have to
  18. install the context listed in the uc_link element of the context
  19. 'makecontext' manipulated at the time of the 'makecontext' call.
  20. If the pointer is NULL the process must terminate. */
  21. ENTRY(__start_context)
  22. /* This removes the parameters passed to the function given to
  23. 'makecontext' from the stack. RBX contains the address
  24. on the stack pointer for the next context. */
  25. movq %rbx, %rsp
  26. popq %rdi /* This is the next context. */
  27. cfi_adjust_cfa_offset(-8)
  28. testq %rdi, %rdi
  29. je 2f /* If it is zero exit. */
  30. call JUMPTARGET(__setcontext)
  31. /* If this returns (which can happen if the syscall fails) we'll
  32. exit the program with the return error value (-1). */
  33. movq %rax,%rdi
  34. 2:
  35. call HIDDEN_JUMPTARGET(exit)
  36. /* The 'exit' call should never return. In case it does cause
  37. the process to terminate. */
  38. hlt
  39. END(__start_context)