syscall6.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*-
  2. * Copyright (c) 2017
  3. * mirabilos <m@mirbsd.org>
  4. *
  5. * Provided that these terms and disclaimer and all copyright notices
  6. * are retained or reproduced in an accompanying document, permission
  7. * is granted to deal in this work without restriction, including un-
  8. * limited rights to use, publicly perform, distribute, sell, modify,
  9. * merge, give away, or sublicence.
  10. *
  11. * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
  12. * the utmost extent permitted by applicable law, neither express nor
  13. * implied; without malicious intent or gross negligence. In no event
  14. * may a licensor, author or contributor be held liable for indirect,
  15. * direct, other damage, loss, or other issues arising in any way out
  16. * of dealing in the work, even if advised of the possibility of such
  17. * damage or existence of a defect, except proven that it results out
  18. * of said person's immediate fault when using the work as intended.
  19. */
  20. .intel_syntax noprefix
  21. .text
  22. /*-
  23. * long __libc_i386_syscall6(unsigned long nr, ...) with six varargs
  24. *
  25. * C definition:
  26. * extern long __libc_i386_syscall6(unsigned long, ...)
  27. * __attribute__((__cdecl__));
  28. *
  29. * Stack layout upon entry: Offsets after saving:
  30. * [esp + 28] arg6 -> ebp ! [esp + 44]
  31. * [esp + 24] arg5 -> edi ! [esp + 40]
  32. * [esp + 20] arg4 -> esi ! [esp + 36]
  33. * [esp + 16] arg3 -> edx [esp + 32]
  34. * [esp + 12] arg2 -> ecx [esp + 28]
  35. * [esp + 8] arg1 -> ebx ! [esp + 24]
  36. * [esp + 4] nr -> eax [esp + 20]
  37. * [esp] return address [esp + 16]
  38. * [esp + 12] saved ebp
  39. * [esp + 8] saved ebx
  40. * [esp + 4] saved esi
  41. * [esp] saved edi
  42. */
  43. .p2align 4,0x90
  44. .globl __libc_i386_syscall6
  45. .type __libc_i386_syscall6,@function
  46. __libc_i386_syscall6:
  47. push ebp
  48. push ebx
  49. push esi
  50. push edi
  51. mov eax,[esp + 20] /* nr */
  52. mov ebx,[esp + 24] /* arg1 */
  53. mov ecx,[esp + 28] /* arg2 */
  54. mov edx,[esp + 32] /* arg3 */
  55. mov esi,[esp + 36] /* arg4 */
  56. mov edi,[esp + 40] /* arg5 */
  57. mov ebp,[esp + 44] /* arg6 */
  58. int 0x80
  59. pop edi
  60. pop esi
  61. pop ebx
  62. pop ebp
  63. ret
  64. .size __libc_i386_syscall6,.-__libc_i386_syscall6