__uClibc_syscall.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * June 27, 2001 Manuel Novoa III
  3. *
  4. * This is a heavily modified version of gcc's output for the syscall5 macro.
  5. * The idea (originally from dietlibc) is that all syscall functions simply
  6. * set the syscall number in %al (since <= 255) and then jump here. All the
  7. * common work is done by __uClibc_syscall, saving a fair amount of generated
  8. * code where a number of syscalls are used. The (potential) cost is some
  9. * unnecessary pushes, pops, and movs but the execution time penalty should
  10. * be relatively small compared to the cost of the syscall itself.
  11. *
  12. * WARNING: If the startup code for uClibc changes, I suppose it is possible
  13. * that this code might try to access memory under the bottom of
  14. * the stack.
  15. * WARNING: This will need to be modified if the number of syscalls ever
  16. * exceeds 255. So will the associated syscall macros.
  17. */
  18. .text
  19. .align 4
  20. .globl __uClibc_syscall
  21. .type __uClibc_syscall,@function
  22. __uClibc_syscall:
  23. pushl %edi
  24. pushl %esi
  25. pushl %ebx
  26. and $0xff,%eax
  27. movl 16(%esp),%ebx
  28. movl 20(%esp),%ecx
  29. movl 24(%esp),%edx
  30. movl 28(%esp),%esi
  31. movl 32(%esp),%edi
  32. #APP
  33. int $0x80
  34. #NO_APP
  35. cmpl $-4095,%eax
  36. jbe .Ldone
  37. #ifdef PIC
  38. call Lhere
  39. Lhere:
  40. popl %ebx
  41. addl $_GLOBAL_OFFSET_TABLE_+[.-Lhere],%ebx
  42. negl %eax
  43. movl %eax,%ecx
  44. #ifdef _LIBC_REENTRANT
  45. call __errno_location@PLT
  46. #else
  47. movl errno@GOT(%ebx),%eax
  48. #endif /* _LIBC_REENTRANT */
  49. movl %ecx,(%eax)
  50. #else
  51. negl %eax
  52. #ifdef _LIBC_REENTRANT
  53. movl %eax,%ecx
  54. call __errno_location
  55. movl %ecx,(%eax)
  56. #else
  57. movl %eax,errno
  58. #endif /* _LIBC_REENTRANT */
  59. #endif /* PIC */
  60. movl $-1,%eax
  61. .p2align 4,,7
  62. .Ldone:
  63. popl %ebx
  64. popl %esi
  65. popl %edi
  66. ret
  67. .Lsize:
  68. .size __uClibc_syscall,.Lsize-__uClibc_syscall