stub.S 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "as-layout.h"
  2. .globl syscall_stub
  3. .section .__syscall_stub, "ax"
  4. syscall_stub:
  5. syscall
  6. /* We don't have 64-bit constants, so this constructs the address
  7. * we need.
  8. */
  9. movq $(STUB_DATA >> 32), %rbx
  10. salq $32, %rbx
  11. movq $(STUB_DATA & 0xffffffff), %rcx
  12. or %rcx, %rbx
  13. movq %rax, (%rbx)
  14. int3
  15. .globl batch_syscall_stub
  16. batch_syscall_stub:
  17. mov $(STUB_DATA >> 32), %rbx
  18. sal $32, %rbx
  19. mov $(STUB_DATA & 0xffffffff), %rax
  20. or %rax, %rbx
  21. /* load pointer to first operation */
  22. mov %rbx, %rsp
  23. add $0x10, %rsp
  24. again:
  25. /* load length of additional data */
  26. mov 0x0(%rsp), %rax
  27. /* if(length == 0) : end of list */
  28. /* write possible 0 to header */
  29. mov %rax, 8(%rbx)
  30. cmp $0, %rax
  31. jz done
  32. /* save current pointer */
  33. mov %rsp, 8(%rbx)
  34. /* skip additional data */
  35. add %rax, %rsp
  36. /* load syscall-# */
  37. pop %rax
  38. /* load syscall params */
  39. pop %rdi
  40. pop %rsi
  41. pop %rdx
  42. pop %r10
  43. pop %r8
  44. pop %r9
  45. /* execute syscall */
  46. syscall
  47. /* check return value */
  48. pop %rcx
  49. cmp %rcx, %rax
  50. je again
  51. done:
  52. /* save return value */
  53. mov %rax, (%rbx)
  54. /* stop */
  55. int3