aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-04-29 05:35:34 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-04-29 05:35:34 -0700
commit2ad5d0845d80589d0adf86593bd36a7c71a521f8 (patch)
tree81bc0b7de7e0b93604944ed70e4125866547eb39 /sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
parent9207e30d3f070712df6c4175547094be112454d2 (diff)
downloadglibc-2ad5d0845d80589d0adf86593bd36a7c71a521f8.zip
glibc-2ad5d0845d80589d0adf86593bd36a7c71a521f8.tar.gz
glibc-2ad5d0845d80589d0adf86593bd36a7c71a521f8.tar.bz2
Add SYSCALL_ULONG_ARG_[12] to pass long to syscall [BZ #25810]
X32 has 32-bit long and pointer with 64-bit off_t. Since x32 psABI requires that pointers passed in registers must be zero-extended to 64bit, x32 can share many syscall interfaces with LP64. When a LP64 syscall with long and unsigned long int arguments is used for x32, these arguments must be properly extended to 64-bit. Otherwise if the upper 32 bits of the register have undefined value, such a syscall will be rejected by kernel. For syscalls implemented in assembly codes, 'U' is added to syscall signature key letters for unsigned long, which is zero-extended to 64-bit types. SYSCALL_ULONG_ARG_1 and SYSCALL_ULONG_ARG_2 are passed to syscall-template.S for the first and the second unsigned long int arguments if PSEUDOS_HAVE_ULONG_INDICES is defined. They are used by x32 to zero-extend 32-bit arguments to 64 bits. Tested on i386, x86-64 and x32 as well as with build-many-glibcs.py.
Diffstat (limited to 'sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h')
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
index a37d520..62e6f8f 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
@@ -26,7 +26,26 @@
#undef LO_HI_LONG
#define LO_HI_LONG(val) (val)
-#ifndef __ASSEMBLER__
+#ifdef __ASSEMBLER__
+/* Zero-extend 32-bit unsigned long int arguments to 64 bits. */
+# undef ZERO_EXTEND_1
+# define ZERO_EXTEND_1 movl %edi, %edi;
+# undef ZERO_EXTEND_2
+# define ZERO_EXTEND_2 movl %esi, %esi;
+# undef ZERO_EXTEND_3
+# define ZERO_EXTEND_3 movl %edx, %edx;
+# if SYSCALL_ULONG_ARG_1 == 4 || SYSCALL_ULONG_ARG_2 == 4
+# undef DOARGS_4
+# define DOARGS_4 movl %ecx, %r10d;
+# else
+# undef ZERO_EXTEND_4
+# define ZERO_EXTEND_4 movl %r10d, %r10d;
+# endif
+# undef ZERO_EXTEND_5
+# define ZERO_EXTEND_5 movl %r8d, %r8d;
+# undef ZERO_EXTEND_6
+# define ZERO_EXTEND_6 movl %r9d, %r9d;
+#else /* !__ASSEMBLER__ */
# undef ARGIFY
/* Enforce zero-extension for pointers and array system call arguments.
For integer types, extend to int64_t (the full register) using a