glibc/sysdeps
H.J. Lu 7378e9c520 x32: Properly 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 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.

Enforce zero-extension for pointers and array system call arguments.
For integer types, extend to int64_t (the full register) using a
regular cast, resulting in zero or sign extension based on the
signedness of the original type.

For

       void *mmap(void *addr, size_t length, int prot, int flags,
                  int fd, off_t offset);

we now generate

   0:	41 f7 c1 ff 0f 00 00 	test   $0xfff,%r9d
   7:	75 1f                	jne    28 <__mmap64+0x28>
   9:	48 63 d2             	movslq %edx,%rdx
   c:	89 f6                	mov    %esi,%esi
   e:	4d 63 c0             	movslq %r8d,%r8
  11:	4c 63 d1             	movslq %ecx,%r10
  14:	b8 09 00 00 40       	mov    $0x40000009,%eax
  19:	0f 05                	syscall

That is

1. addr is unchanged.
2. length is zero-extend to 64 bits.
3. prot is sign-extend to 64 bits.
4. flags is sign-extend to 64 bits.
5. fd is sign-extend to 64 bits.
6. offset is unchanged.

For int arguments, since kernel uses only the lower 32 bits and ignores
the upper 32 bits in 64-bit registers, these work correctly.

Tested on x86-64 and x32.  There are no code changes on x86-64.

(cherry picked from commit df76ff3a44)
2020-05-07 05:12:27 -07:00
..
aarch64 aarch64: simplify the DT_AARCH64_VARIANT_PCS handling code 2019-07-10 15:28:00 +01:00
alpha Update Alpha libm-test-ulps 2019-09-03 21:38:07 +02:00
arm arm: Fix softp-fp Implies (BZ #25635) 2020-03-24 08:48:43 -03:00
csky
generic Add nocancel version of pread64() 2020-01-17 13:56:43 +01:00
gnu login: Add nonstring attributes to struct utmp, struct utmpx [BZ #24899] 2020-01-17 13:56:00 +01:00
hppa Add new file missed in previous hppa commit. 2020-05-04 22:00:52 +02:00
htl
hurd
i386 i386: Use comdat instead of .gnu.linkonce for i386 setup pic register (BZ #20543) 2020-03-24 08:46:59 -03:00
ia64
ieee754 math/test-sinl-pseudo: Use stack protector only if available 2020-03-11 12:59:42 +01:00
init_array
m68k
mach
microblaze
mips
nios2
nptl nptl: Remove unnecessary forwarding of pthread_cond_clockwait from libc 2019-07-18 11:24:33 -03:00
posix posix: Fix system error return value [BZ #25715] 2020-03-24 08:48:58 -03:00
powerpc Fix array overflow in backtrace on PowerPC (bug 25423) 2020-03-18 10:26:13 -04:00
pthread nptl: Add POSIX-proposed sem_clockwait 2019-07-12 13:36:23 +00:00
riscv riscv: restore ABI compatibility (bug 24484) 2019-07-04 14:55:58 +02:00
s390 S390: Fix handling of needles crossing a page in strstr z15 ifunc-variant. [BZ #25226] 2019-11-27 12:38:58 +01:00
sh
sparc nptl: Rename lll_timedlock to lll_clocklock and add clockid parameter 2019-07-12 13:36:25 +00:00
unix x32: Properly pass long to syscall [BZ #25810] 2020-05-07 05:12:27 -07:00
wordsize-32
wordsize-64
x86 Call _dl_open_check after relocation [BZ #24259] 2019-07-01 12:23:22 -07:00
x86_64 x86-64: Compile branred.c with -mprefer-vector-width=128 [BZ #24603] 2019-07-24 14:48:43 -07:00