123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- #ifndef _LINUX_I386_SYSDEP_H
- #define _LINUX_I386_SYSDEP_H 1
- #include <sys/syscall.h>
- #include <sysdeps/i386/sysdep.h>
- #ifndef offsetof
- # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
- #endif
- #undef SYS_ify
- #define SYS_ify(syscall_name) __NR_##syscall_name
- #if defined USE_DL_SYSINFO \
- && (!defined NOT_IN_libc || defined IS_IN_libpthread)
- # define I386_USE_SYSENTER 1
- #else
- # undef I386_USE_SYSENTER
- #endif
- #ifdef __ASSEMBLER__
- #ifdef PIC
- # define SYSCALL_ERROR_LABEL 0f
- #else
- # define SYSCALL_ERROR_LABEL syscall_error
- #endif
- #undef PSEUDO
- #define PSEUDO(name, syscall_name, args) \
- .text
- ENTRY (name) \
- DO_CALL (syscall_name, args)
- cmpl $-4095, %eax
- jae SYSCALL_ERROR_LABEL
- L(pseudo_end):
- #undef PSEUDO_END
- #define PSEUDO_END(name) \
- SYSCALL_ERROR_HANDLER \
- END (name)
- #undef PSEUDO_NOERRNO
- #define PSEUDO_NOERRNO(name, syscall_name, args) \
- .text
- ENTRY (name) \
- DO_CALL (syscall_name, args)
- #undef PSEUDO_END_NOERRNO
- #define PSEUDO_END_NOERRNO(name) \
- END (name)
- #define ret_NOERRNO ret
- #undef PSEUDO_ERRVAL
- #define PSEUDO_ERRVAL(name, syscall_name, args) \
- .text
- ENTRY (name) \
- DO_CALL (syscall_name, args)
- negl %eax
- #undef PSEUDO_END_ERRVAL
- #define PSEUDO_END_ERRVAL(name) \
- END (name)
- #define ret_ERRVAL ret
- #ifndef PIC
- # define SYSCALL_ERROR_HANDLER
- #else
- # ifdef RTLD_PRIVATE_ERRNO
- # define SYSCALL_ERROR_HANDLER \
- 0:SETUP_PIC_REG(cx)
- addl $_GLOBAL_OFFSET_TABLE_, %ecx
- xorl %edx, %edx
- subl %eax, %edx
- movl %edx, rtld_errno@GOTOFF(%ecx)
- orl $-1, %eax
- jmp L(pseudo_end)
- # elif defined _LIBC_REENTRANT
- # if USE___THREAD
- # ifndef NOT_IN_libc
- # define SYSCALL_ERROR_ERRNO __libc_errno
- # else
- # define SYSCALL_ERROR_ERRNO errno
- # endif
- # define SYSCALL_ERROR_HANDLER \
- 0:SETUP_PIC_REG (cx)
- addl $_GLOBAL_OFFSET_TABLE_, %ecx
- movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx
- xorl %edx, %edx
- subl %eax, %edx
- SYSCALL_ERROR_HANDLER_TLS_STORE (%edx, %ecx)
- orl $-1, %eax
- jmp L(pseudo_end)
- # ifndef NO_TLS_DIRECT_SEG_REFS
- # define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- movl src, %gs:(destoff)
- # else
- # define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- addl %gs:0, destoff
- movl src, (destoff)
- # endif
- # else
- # define SYSCALL_ERROR_HANDLER \
- 0:pushl %ebx
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (ebx, 0)
- SETUP_PIC_REG (bx)
- addl $_GLOBAL_OFFSET_TABLE_, %ebx
- xorl %edx, %edx
- subl %eax, %edx
- pushl %edx
- cfi_adjust_cfa_offset (4)
- call __errno_location@PLT
- popl %ecx
- cfi_adjust_cfa_offset (-4)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebx)
- movl %ecx, (%eax)
- orl $-1, %eax
- jmp L(pseudo_end)
- # endif
- # else
- # define SYSCALL_ERROR_HANDLER \
- 0:SETUP_PIC_REG(cx)
- addl $_GLOBAL_OFFSET_TABLE_, %ecx
- xorl %edx, %edx
- subl %eax, %edx
- movl errno@GOT(%ecx), %ecx
- movl %edx, (%ecx)
- orl $-1, %eax
- jmp L(pseudo_end)
- # endif
- #endif
- #ifdef I386_USE_SYSENTER
- # ifdef SHARED
- # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
- # else
- # define ENTER_KERNEL call *_dl_sysinfo
- # endif
- #else
- # define ENTER_KERNEL int $0x80
- #endif
- #undef DO_CALL
- #define DO_CALL(syscall_name, args) \
- PUSHARGS_##args \
- DOARGS_##args \
- movl $SYS_ify (syscall_name), %eax
- ENTER_KERNEL \
- POPARGS_##args
- #define PUSHARGS_0
- #define DOARGS_0
- #define POPARGS_0
- #define _PUSHARGS_0
- #define _DOARGS_0(n)
- #define _POPARGS_0
- #define PUSHARGS_1 movl %ebx, %edx; L(SAVEBX1): PUSHARGS_0
- #define DOARGS_1 _DOARGS_1 (4)
- #define POPARGS_1 POPARGS_0; movl %edx, %ebx; L(RESTBX1):
- #define _PUSHARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (ebx, 0)
- #define _DOARGS_1(n) movl n(%esp), %ebx; _DOARGS_0(n-4)
- #define _POPARGS_1 _POPARGS_0; popl %ebx; cfi_adjust_cfa_offset (-4); \
- cfi_restore (ebx)
- #define PUSHARGS_2 PUSHARGS_1
- #define DOARGS_2 _DOARGS_2 (8)
- #define POPARGS_2 POPARGS_1
- #define _PUSHARGS_2 _PUSHARGS_1
- #define _DOARGS_2(n) movl n(%esp), %ecx; _DOARGS_1 (n-4)
- #define _POPARGS_2 _POPARGS_1
- #define PUSHARGS_3 _PUSHARGS_2
- #define DOARGS_3 _DOARGS_3 (16)
- #define POPARGS_3 _POPARGS_3
- #define _PUSHARGS_3 _PUSHARGS_2
- #define _DOARGS_3(n) movl n(%esp), %edx; _DOARGS_2 (n-4)
- #define _POPARGS_3 _POPARGS_2
- #define PUSHARGS_4 _PUSHARGS_4
- #define DOARGS_4 _DOARGS_4 (24)
- #define POPARGS_4 _POPARGS_4
- #define _PUSHARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (esi, 0)
- #define _DOARGS_4(n) movl n(%esp), %esi; _DOARGS_3 (n-4)
- #define _POPARGS_4 _POPARGS_3; popl %esi; cfi_adjust_cfa_offset (-4); \
- cfi_restore (esi)
- #define PUSHARGS_5 _PUSHARGS_5
- #define DOARGS_5 _DOARGS_5 (32)
- #define POPARGS_5 _POPARGS_5
- #define _PUSHARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (edi, 0)
- #define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4)
- #define _POPARGS_5 _POPARGS_4; popl %edi; cfi_adjust_cfa_offset (-4); \
- cfi_restore (edi)
- #define PUSHARGS_6 _PUSHARGS_6
- #define DOARGS_6 _DOARGS_6 (40)
- #define POPARGS_6 _POPARGS_6
- #define _PUSHARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (ebp, 0)
- #define _DOARGS_6(n) movl n(%esp), %ebp; _DOARGS_5 (n-4)
- #define _POPARGS_6 _POPARGS_5; popl %ebp; cfi_adjust_cfa_offset (-4); \
- cfi_restore (ebp)
- #endif
- #if defined NOT_IN_libc && defined IS_IN_rtld
- #else
- # ifdef __ASSEMBLER__
- # define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \
- roll $9, reg
- # define PTR_DEMANGLE(reg) rorl $9, reg; \
- xorl %gs:POINTER_GUARD, reg
- # else
- # define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \
- "roll $9, %0" \
- : "=r" (var) \
- : "0" (var), \
- "i" (offsetof (tcbhead_t, \
- pointer_guard)))
- # define PTR_DEMANGLE(var) asm ("rorl $9, %0\n" \
- "xorl %%gs:%c2, %0" \
- : "=r" (var) \
- : "0" (var), \
- "i" (offsetof (tcbhead_t, \
- pointer_guard)))
- # endif
- #endif
- #endif
|