[PATCH] Add SYSCALL_LONG/SYSCALL_ULONG to pass long to syscall [BZ #25810]
H.J. Lu
hjl.tools@gmail.com
Sat Apr 11 21:58:51 GMT 2020
On Sat, Apr 11, 2020 at 1:47 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * H. J. Lu:
>
> > What x32 needs are
> >
> > 1. Pointer arguments: no cast.
> > 2. 64-bit integer arguments: no cast.
> > 3. 32-bit integer arguments: extend to 64 bits.
> >
> > I am having a very hard time to do it in INLINE_SYSCALLs.
>
> Is the problem avoiding sign extension on pointer values?
>
> I'm not sure if that is actually necessary to distinguish pointers and
> integer. It should be possible to lump pointers together with
> unsigned 32-bit arguments, like this:
>
> #define ARGIFY(X) \
> (((__typeof__ (X)) 0 < (__typeof__ (X)) -1 && sizeof (X) == 4)
> ? (long long int) (uintptr_t) (X) \
> : (long long int) (X))
>
> The first branch is used for pointers and unsigned int values,
> resulting in zero extension. The other branch uses zero or sign
> extension, depending on the type of X.
I tried variants of this. I got
/usr/gcc-9.3.1-x32/bin/gcc -mx32 ../sysdeps/unix/sysv/linux/fexecve.c
-c -std=gnu11 -fgnu89-inline -O2 -g -Wall -Wwrite-strings -Wundef
-Werror -fmerge-all-constants -frounding-math -fno-stack-protector
-Wstrict-prototypes -Wold-style-definition -fmath-errno
-ftls-model=initial-exec -I../include
-I/export/build/gnu/tools-build/glibc-x32-gitlab/build-x86_64-linux/posix
-I/export/build/gnu/tools-build/glibc-x32-gitlab/build-x86_64-linux
-I../sysdeps/unix/sysv/linux/x86_64/x32
-I../sysdeps/unix/sysv/linux/x86_64
-I../sysdeps/unix/sysv/linux/x86/include
-I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/x86/nptl
-I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/x86_64/nptl
-I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
-I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu
-I../sysdeps/unix/inet -I../sysdeps/unix/sysv
-I../sysdeps/unix/x86_64 -I../sysdeps/unix -I../sysdeps/posix
-I../sysdeps/x86_64/x32/fpu -I../sysdeps/x86_64/x32
-I../sysdeps/x86_64/fpu/multiarch -I../sysdeps/x86_64/fpu
-I../sysdeps/x86/fpu -I../sysdeps/x86_64/multiarch
-I../sysdeps/x86_64 -I../sysdeps/x86 -I../sysdeps/ieee754/float128
-I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96
-I../sysdeps/ieee754/dbl-64/wordsize-64 -I../sysdeps/ieee754/dbl-64
-I../sysdeps/ieee754/flt-32 -I../sysdeps/wordsize-32
-I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I.
-D_LIBC_REENTRANT -include
/export/build/gnu/tools-build/glibc-x32-gitlab/build-x86_64-linux/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h
-DTOP_NAMESPACE=glibc -o
/export/build/gnu/tools-build/glibc-x32-gitlab/build-x86_64-linux/posix/fexecve.o
-MD -MP -MF /export/build/gnu/tools-build/glibc-x32-gitlab/build-x86_64-linux/posix/fexecve.o.dt
-MT /export/build/gnu/tools-build/glibc-x32-gitlab/build-x86_64-linux/posix/fexecve.o
nohup: ignoring input and appending output to 'nohup.out'
gnu-tools-1:pts/5[130]> m nohup.out
In file included from ../sysdeps/x86_64/nptl/tls.h:28,
from ../include/errno.h:25,
from ../sysdeps/unix/sysv/linux/fexecve.c:18:
../sysdeps/unix/sysv/linux/fexecve.c: In function ‘fexecve’:
../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:56:6: error: cast from pointer to
integer of different size [-Werror=pointer-to-int-cast]
56 | : (long long int) (X))
| ^
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:313:29: note: in expansion of macro ‘
ARGIFY’
313 | TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
| ^~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:222:2: note: in expansion of macro ‘i
nternal_syscall5’
222 | internal_syscall##nr (SYS_ify (name), args)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro ‘INTERNAL
_SYSCALL’
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/fexecve.c:43:3: note: in expansion of macro ‘INLINE_S
YSCALL’
43 | INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0], AT_EMPTY_PATH
gnu-tools-1:pts/5[131]> cat nohup.out
In file included from ../sysdeps/x86_64/nptl/tls.h:28,
from ../include/errno.h:25,
from ../sysdeps/unix/sysv/linux/fexecve.c:18:
../sysdeps/unix/sysv/linux/fexecve.c: In function ‘fexecve’:
../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:56:6: error: cast from
pointer to integer of different size [-Werror=pointer-to-int-cast]
56 | : (long long int) (X))
| ^
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:313:29: note: in expansion
of macro ‘ARGIFY’
313 | TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
| ^~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:222:2: note: in expansion
of macro ‘internal_syscall5’
222 | internal_syscall##nr (SYS_ify (name), args)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro
‘INTERNAL_SYSCALL’
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/fexecve.c:43:3: note: in expansion of macro
‘INLINE_SYSCALL’
43 | INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0],
AT_EMPTY_PATH);
| ^~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:56:6: error: cast from
pointer to integer of different size [-Werror=pointer-to-int-cast]
56 | : (long long int) (X))
| ^
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:314:29: note: in expansion
of macro ‘ARGIFY’
314 | TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
| ^~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:222:2: note: in expansion
of macro ‘internal_syscall5’
222 | internal_syscall##nr (SYS_ify (name), args)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro
‘INTERNAL_SYSCALL’
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/fexecve.c:43:3: note: in expansion of macro
‘INLINE_SYSCALL’
43 | INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0],
AT_EMPTY_PATH);
| ^~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:54:5: error: cast
specifies array type
54 | (((__typeof__ (X)) 0 < (__typeof__ (X)) -1 && sizeof (X) == 4) \
| ^
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:315:29: note: in expansion
of macro ‘ARGIFY’
315 | TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
| ^~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:222:2: note: in expansion
of macro ‘internal_syscall5’
222 | internal_syscall##nr (SYS_ify (name), args)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro
‘INTERNAL_SYSCALL’
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/fexecve.c:43:3: note: in expansion of macro
‘INLINE_SYSCALL’
43 | INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0],
AT_EMPTY_PATH);
| ^~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:54:26: error: cast
specifies array type
54 | (((__typeof__ (X)) 0 < (__typeof__ (X)) -1 && sizeof (X) == 4) \
| ^
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:315:29: note: in expansion
of macro ‘ARGIFY’
315 | TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
| ^~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:222:2: note: in expansion
of macro ‘internal_syscall5’
222 | internal_syscall##nr (SYS_ify (name), args)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro
‘INTERNAL_SYSCALL’
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/fexecve.c:43:3: note: in expansion of macro
‘INLINE_SYSCALL’
43 | INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0],
AT_EMPTY_PATH);
| ^~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:56:6: error: cast from
pointer to integer of different size [-Werror=pointer-to-int-cast]
56 | : (long long int) (X))
| ^
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:315:29: note: in expansion
of macro ‘ARGIFY’
315 | TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
| ^~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:222:2: note: in expansion
of macro ‘internal_syscall5’
222 | internal_syscall##nr (SYS_ify (name), args)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro
‘INTERNAL_SYSCALL’
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/fexecve.c:43:3: note: in expansion of macro
‘INLINE_SYSCALL’
43 | INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0],
AT_EMPTY_PATH);
| ^~~~~~~~~~~~~~
--
H.J.
More information about the Libc-alpha
mailing list