You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

linux_syscall.S 784B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. .section ".data"
  2. .globl linux_errno
  3. linux_errno: .int 0
  4. .section ".text"
  5. .code32
  6. .globl linux_syscall
  7. .type linux_syscall, @function
  8. linux_syscall:
  9. /* Save registers */
  10. pushl %ebx
  11. pushl %esi
  12. pushl %edi
  13. pushl %ebp
  14. movl 20(%esp), %eax // C arg1 -> syscall number
  15. movl 24(%esp), %ebx // C arg2 -> syscall arg1
  16. movl 28(%esp), %ecx // C arg3 -> syscall arg2
  17. movl 32(%esp), %edx // C arg4 -> syscall arg3
  18. movl 36(%esp), %esi // C arg5 -> syscall arg4
  19. movl 40(%esp), %edi // C arg6 -> syscall arg5
  20. movl 44(%esp), %ebp // C arg7 -> syscall arg6
  21. int $0x80
  22. /* Restore registers */
  23. popl %ebp
  24. popl %edi
  25. popl %esi
  26. popl %ebx
  27. cmpl $-4095, %eax
  28. jae 1f
  29. ret
  30. 1:
  31. negl %eax
  32. movl %eax, linux_errno
  33. movl $-1, %eax
  34. ret
  35. .size linux_syscall, . - linux_syscall