glibc/sysdeps/unix/make-syscalls.sh
Adhemerval Zanella ebd6f0076a Remove cancellation support for syscall generation
This patch removes the cancellation mark from the auto-generation syscall
script.  Now all the cancellable syscalls are done throught C code using
the SYSCALL_CANCEL macro.  It simplifies the assembly required to each
architecture port, since the SYSCALL_CANCEL uses the already defined
INLINE_SYSCALL macros, and allows a more straigh fix on cancellation
machanism (since no more specific assembly fixes will be required).

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.A
Also with build-many-glibc.py with remaning touched architectures.

	* sysdeps/unix/make-syscalls.sh: Remove cancellable tagging for
	syscall definitions.
	* sysdeps/unix/syscall-template.S (SYSCALL_CANCELLABLE): Remove
	definition.
	* sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (__local_enable_asynccancel): Likewise.
	[IS_IN (libpthread)] (__local_disable_asynccancel): Likewise.
	[IS_IN (libc)] (__local_enable_asynccancel): Likewise.
	[IS_IN (libc)] (__local_enable_asynccancel): Likewise.
	[IS_IN (librt)] (__local_disable_asynccancel): Likewise.
	[IS_IN (librt)] (__local_disable_asynccancel): Likewise.
	(CENABLE): Likewise.
	(CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/arm/sysdep-cancel.h (PSEUDO): Remove
	defintion.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h (PSEUDO):
	Remove definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	(SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Remove file.
	* sysdeps/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h: New file.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Remove file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h: New file.
	* sysdeps/unix/sysv/linux/tile/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (PSEUDO): Remove
	definition.
	(PSEUDO_END): Likewise.
	[IS_IN (libpthread)] (CENABLE): Likewise.
	[IS_IN (libpthread)] (CDISABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (libc)] (CENABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[IS_IN (librt)] (CDISABLE): Likewise.
	[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
2017-08-24 14:58:35 -03:00

318 lines
9.5 KiB
Bash

#!/bin/sh
# Usage: make-syscalls.sh ../sysdeps/unix/common
# Expects $sysdirs in environment.
##############################################################################
#
# This script is used to process the syscall data encoded in the various
# syscalls.list files to produce thin assembly syscall wrappers around the
# appropriate OS syscall. See syscall-template.s for more details on the
# actual wrapper.
#
# Syscall Signature Prefixes:
#
# E: errno and return value are not set by the call
# V: errno is not set, but errno or zero (success) is returned from the call
#
# Syscall Signature Key Letters:
#
# a: unchecked address (e.g., 1st arg to mmap)
# b: non-NULL buffer (e.g., 2nd arg to read; return value from mmap)
# B: optionally-NULL buffer (e.g., 4th arg to getsockopt)
# f: buffer of 2 ints (e.g., 4th arg to socketpair)
# F: 3rd arg to fcntl
# i: scalar (any signedness & size: int, long, long long, enum, whatever)
# I: 3rd arg to ioctl
# n: scalar buffer length (e.g., 3rd arg to read)
# N: pointer to value/return scalar buffer length (e.g., 6th arg to recvfrom)
# p: non-NULL pointer to typed object (e.g., any non-void* arg)
# P: optionally-NULL pointer to typed object (e.g., 2nd argument to gettimeofday)
# s: non-NULL string (e.g., 1st arg to open)
# S: optionally-NULL string (e.g., 1st arg to acct)
# v: vararg scalar (e.g., optional 3rd arg to open)
# V: byte-per-page vector (3rd arg to mincore)
# W: wait status, optionally-NULL pointer to int (e.g., 2nd arg of wait4)
#
##############################################################################
thisdir=$1; shift
echo ''
echo \#### DIRECTORY = $thisdir
# Check each sysdep dir with higher priority than this one,
# and remove from $calls all the functions found in other dirs.
# Punt when we reach the directory defining these syscalls.
sysdirs=`for dir in $sysdirs; do
test $dir = $thisdir && break; echo $dir; done`
echo \#### SYSDIRS = $sysdirs
# Get the list of system calls for this directory.
calls=`sed 's/#.*$//
/^[ ]*$/d' $thisdir/syscalls.list`
calls=`echo "$calls" |
while read file caller rest; do
# Remove each syscall that is implemented by a file in $dir.
# If a syscall specified a "caller", then only compile that syscall
# if the caller function is also implemented in this directory.
srcfile=-;
for dir in $sysdirs; do
{ test -f $dir/$file.c && srcfile=$dir/$file.c; } ||
{ test -f $dir/$file.S && srcfile=$dir/$file.S; } ||
{ test x$caller != x- &&
{ { test -f $dir/$caller.c && srcfile=$dir/$caller.c; } ||
{ test -f $dir/$caller.S && srcfile=$dir/$caller.S; }; }; } && break;
done;
echo $file $srcfile $caller $rest;
done`
# Any calls left?
test -n "$calls" || exit 0
# This uses variables $weak, $strong, and $any_versioned.
emit_weak_aliases()
{
# A shortcoming in the current gas is that it will only allow one
# version-alias per symbol. So we create new strong aliases as needed.
vcount=""
# We use the <shlib-compat.h> macros to generate the versioned aliases
# so that the version sets can be mapped to the configuration's
# minimum version set as per shlib-versions DEFAULT lines. If an
# entry point is specified in the form NAME@VERSION:OBSOLETED, a
# SHLIB_COMPAT conditional is generated.
if [ $any_versioned = t ]; then
echo " echo '#include <shlib-compat.h>'; \\"
fi
for name in $weak; do
case $name in
*@@*)
base=`echo $name | sed 's/@@.*//'`
ver=`echo $name | sed 's/.*@@//;s/\./_/g'`
echo " echo '#if IS_IN (libc)'; \\"
if test -z "$vcount" ; then
source=$strong
vcount=1
else
source="${strong}_${vcount}"
vcount=`expr $vcount + 1`
echo " echo 'strong_alias ($strong, $source)'; \\"
fi
echo " echo 'versioned_symbol (libc, $source, $base, $ver)'; \\"
echo " echo '#else'; \\"
echo " echo 'strong_alias ($strong, $base)'; \\"
echo " echo '#endif'; \\"
;;
*@*)
base=`echo $name | sed 's/@.*//'`
ver=`echo $name | sed 's/.*@//;s/\./_/g'`
case $ver in
*:*)
compat_ver=${ver#*:}
ver=${ver%%:*}
compat_cond=" && SHLIB_COMPAT (libc, $ver, $compat_ver)"
;;
*)
compat_cond=
;;
esac
echo " echo '#if defined SHARED && IS_IN (libc)$compat_cond'; \\"
if test -z "$vcount" ; then
source=$strong
vcount=1
else
source="${strong}_${vcount}"
vcount=`expr $vcount + 1`
echo " echo 'strong_alias ($strong, $source)'; \\"
fi
echo " echo 'compat_symbol (libc, $source, $base, $ver)'; \\"
echo " echo '#endif'; \\"
;;
!*)
name=`echo $name | sed 's/.//'`
echo " echo 'strong_alias ($strong, $name)'; \\"
echo " echo 'hidden_def ($name)'; \\"
;;
*)
echo " echo 'weak_alias ($strong, $name)'; \\"
echo " echo 'hidden_weak ($name)'; \\"
;;
esac
done
}
# Emit rules to compile the syscalls remaining in $calls.
echo "$calls" |
while read file srcfile caller syscall args strong weak; do
vdso_syscall=
case x"$syscall" in
*:*@*)
vdso_syscall="${syscall#*:}"
syscall="${syscall%:*}"
;;
esac
case x"$syscall" in
x-) callnum=_ ;;
*)
# Figure out if $syscall is defined with a number in syscall.h.
callnum=-
eval `{ echo "#include <sysdep.h>";
echo "callnum=SYS_ify ($syscall)"; } |
$asm_CPP -D__OPTIMIZE__ - |
sed -n -e "/^callnum=.*$syscall/d" \
-e "/^\(callnum=\)[ ]*\(.*\)/s//\1'\2'/p"`
;;
esac
noerrno=0
errval=0
case $args in
E*) noerrno=1; args=`echo $args | sed 's/E:\?//'`;;
V*) errval=1; args=`echo $args | sed 's/V:\?//'`;;
esac
# Derive the number of arguments from the argument signature
case $args in
[0-9]) nargs=$args;;
?:) nargs=0;;
?:?) nargs=1;;
?:??) nargs=2;;
?:???) nargs=3;;
?:????) nargs=4;;
?:?????) nargs=5;;
?:??????) nargs=6;;
?:???????) nargs=7;;
?:????????) nargs=8;;
?:?????????) nargs=9;;
esac
# Make sure only the first syscall rule is used, if multiple dirs
# define the same syscall.
echo ''
echo "#### CALL=$file NUMBER=$callnum ARGS=$args SOURCE=$srcfile"
# If there are versioned aliases the entry is only generated for the
# shared library, unless it is a default version.
any_versioned=f
shared_only=f
case $weak in
*@@*) any_versioned=t ;;
*@*) any_versioned=t shared_only=t ;;
esac
case x$srcfile"$callnum" in
x--)
# Undefined callnum for an extra syscall.
if [ x$caller != x- ]; then
if [ $noerrno != 0 ]; then
echo >&2 "$0: no number for $fileno, no-error syscall ($strong $weak)"
exit 2
fi
echo "unix-stub-syscalls += $strong $weak"
fi
;;
x*-) ;; ### Do nothing for undefined callnum
x-*)
echo "ifeq (,\$(filter $file,\$(unix-syscalls)))"
if test $shared_only = t; then
# The versioned symbols are only in the shared library.
echo "ifneq (,\$(filter .os,\$(object-suffixes)))"
fi
# Accumulate the list of syscall files for this directory.
echo "unix-syscalls += $file"
test x$caller = x- || echo "unix-extra-syscalls += $file"
# Emit a compilation rule for this syscall.
if test $shared_only = t; then
# The versioned symbols are only in the shared library.
echo "shared-only-routines += $file"
test -n "$vdso_syscall" || echo "\$(objpfx)${file}.os: \\"
else
object_suffixes='$(object-suffixes)'
test -z "$vdso_syscall" || object_suffixes='$(object-suffixes-noshared)'
echo "\
\$(foreach p,\$(sysd-rules-targets),\
\$(foreach o,${object_suffixes},\$(objpfx)\$(patsubst %,\$p,$file)\$o)): \\"
fi
echo " \$(..)sysdeps/unix/make-syscalls.sh"
case x"$callnum" in
x_)
echo "\
\$(make-target-directory)
(echo '/* Dummy module requested by syscalls.list */'; \\"
;;
x*)
echo "\
\$(make-target-directory)
(echo '#define SYSCALL_NAME $syscall'; \\
echo '#define SYSCALL_NARGS $nargs'; \\
echo '#define SYSCALL_SYMBOL $strong'; \\
echo '#define SYSCALL_NOERRNO $noerrno'; \\
echo '#define SYSCALL_ERRVAL $errval'; \\
echo '#include <syscall-template.S>'; \\"
;;
esac
# Append any weak aliases or versions defined for this syscall function.
emit_weak_aliases
# And finally, pipe this all into the compiler.
echo ' ) | $(compile-syscall) '"\
\$(foreach p,\$(patsubst %$file,%,\$(basename \$(@F))),\$(\$(p)CPPFLAGS))"
if test -n "$vdso_syscall"; then
# In the shared library, we're going to emit an IFUNC using a vDSO function.
# $vdso_syscall looks like "name@KERNEL_X.Y" where "name" is the symbol
# name in the vDSO and KERNEL_X.Y is its symbol version.
vdso_symbol="${vdso_syscall%@*}"
vdso_symver="${vdso_syscall#*@}"
vdso_symver=`echo "$vdso_symver" | sed 's/\./_/g'`
cat <<EOF
\$(foreach p,\$(sysd-rules-targets),\$(objpfx)\$(patsubst %,\$p,$file).os): \\
\$(..)sysdeps/unix/make-syscalls.sh
\$(make-target-directory)
(echo '#include <dl-vdso.h>'; \\
echo 'extern void *${strong}_ifunc (void) __asm ("${strong}");'; \\
echo 'void *'; \\
echo 'inhibit_stack_protector'; \\
echo '${strong}_ifunc (void)'; \\
echo '{'; \\
echo ' PREPARE_VERSION_KNOWN (symver, ${vdso_symver});'; \\
echo ' return _dl_vdso_vsym ("${vdso_symbol}", &symver);'; \\
echo '}'; \\
echo 'asm (".type ${strong}, %gnu_indirect_function");'; \\
EOF
# This is doing "hidden_def (${strong})", but the compiler
# doesn't know that we've defined ${strong} in the same file, so
# we can't do it the normal way.
cat <<EOF
echo 'asm (".globl __GI_${strong}");'; \\
echo 'asm ("__GI_${strong} = ${strong}");'; \\
EOF
emit_weak_aliases
cat <<EOF
) | \$(compile-stdin.c) \
\$(foreach p,\$(patsubst %$file,%,\$(basename \$(@F))),\$(\$(p)CPPFLAGS))
EOF
fi
if test $shared_only = t; then
# The versioned symbols are only in the shared library.
echo endif
fi
echo endif
;;
esac
done