Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create hidden aliases for non-libc syscalls automatically.
The syscall wrappers mechanism automatically creates hidden aliases
for syscalls with libc_hidden_def / libc_hidden_weak.  The use of
libc_hidden_* has the side-effect that for syscall wrappers in
non-libc libraries those aliases are not created.  In turn, this means
that three mq_* syscalls in sysdeps/unix/sysv/linux/syscalls.list list
the __GI_* names explicitly.

The use of libc_hidden_* dates back to the original introduction of
that support in

2002-08-03  Roland McGrath  <roland@redhat.com>

        * sysdeps/unix/make-syscalls.sh: Generate libc_hidden_def or
        libc_hidden_weak for every system call symbol defined.

(predating the non-libc syscalls in question) and I see no reason for
excluding non-libc syscalls.  This patch changes the code to use
hidden_def / hidden_weak (via a wrapper syscall_hidden_def in the case
where the argument is itself a macro, so that the argument gets
expanded before concatenation with __GI_), so avoiding the need to
specify the hidden aliases explicitly in this case.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed stripped shared libraries is unchanged by the patch; the
mq_* symbols change from weak to strong, which is of no significance
and two of them will shortly change back to weak as part of a fix for
bug 18545).

	* sysdeps/unix/make-syscalls.sh (emit_weak_aliases): Use
	hidden_def and hidden_weak instead of libc_hidden_def and
	libc_hidden_weak.
	(top level): Refer to hidden_def in comment.
	* sysdeps/unix/syscall-template.S (syscall_hidden_def): New
	macro.  Use it instead of libc_hidden_def.
	* sysdeps/unix/sysv/linux/syscalls.list (mq_timedsend): Do not
	specify __GI_* name explicitly.
	(mq_timedreceive): Likewise.
	(mq_setattr): Likewise.
  • Loading branch information
Joseph Myers committed Jun 17, 2015
1 parent 90dd591 commit c21d37d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
@@ -1,5 +1,16 @@
2015-06-17 Joseph Myers <joseph@codesourcery.com>

* sysdeps/unix/make-syscalls.sh (emit_weak_aliases): Use
hidden_def and hidden_weak instead of libc_hidden_def and
libc_hidden_weak.
(top level): Refer to hidden_def in comment.
* sysdeps/unix/syscall-template.S (syscall_hidden_def): New
macro. Use it instead of libc_hidden_def.
* sysdeps/unix/sysv/linux/syscalls.list (mq_timedsend): Do not
specify __GI_* name explicitly.
(mq_timedreceive): Likewise.
(mq_setattr): Likewise.

[BZ #18544]
* nptl/pthread_barrier_init.c (pthread_barrier_init): Rename to
__pthread_barrier_init and define as weak alias of
Expand Down
6 changes: 3 additions & 3 deletions sysdeps/unix/make-syscalls.sh
Expand Up @@ -128,11 +128,11 @@ emit_weak_aliases()
!*)
name=`echo $name | sed 's/.//'`
echo " echo 'strong_alias ($strong, $name)'; \\"
echo " echo 'libc_hidden_def ($name)'; \\"
echo " echo 'hidden_def ($name)'; \\"
;;
*)
echo " echo 'weak_alias ($strong, $name)'; \\"
echo " echo 'libc_hidden_weak ($name)'; \\"
echo " echo 'hidden_weak ($name)'; \\"
;;
esac
done
Expand Down Expand Up @@ -287,7 +287,7 @@ while read file srcfile caller syscall args strong weak; do
echo '}'; \\
echo 'asm (".type ${strong}, %gnu_indirect_function");'; \\
EOF
# This is doing "libc_hidden_def (${strong})", but the compiler
# 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
Expand Down
5 changes: 4 additions & 1 deletion sysdeps/unix/syscall-template.S
Expand Up @@ -47,6 +47,9 @@
# include <sysdep.h>
#endif

/* This indirection is needed so that SYMBOL gets macro-expanded. */
#define syscall_hidden_def(SYMBOL) hidden_def (SYMBOL)

#define T_PSEUDO(SYMBOL, NAME, N) PSEUDO (SYMBOL, NAME, N)
#define T_PSEUDO_NOERRNO(SYMBOL, NAME, N) PSEUDO_NOERRNO (SYMBOL, NAME, N)
#define T_PSEUDO_ERRVAL(SYMBOL, NAME, N) PSEUDO_ERRVAL (SYMBOL, NAME, N)
Expand Down Expand Up @@ -84,4 +87,4 @@ T_PSEUDO_END (SYSCALL_SYMBOL)

#endif

libc_hidden_def (SYSCALL_SYMBOL)
syscall_hidden_def (SYSCALL_SYMBOL)
6 changes: 3 additions & 3 deletions sysdeps/unix/sysv/linux/syscalls.list
Expand Up @@ -106,9 +106,9 @@ removexattr - removexattr i:ss removexattr
lremovexattr - lremovexattr i:ss lremovexattr
fremovexattr - fremovexattr i:is fremovexattr

mq_timedsend - mq_timedsend Ci:ipiip __GI_mq_timedsend mq_timedsend
mq_timedreceive - mq_timedreceive Ci:ipipp __GI_mq_timedreceive mq_timedreceive
mq_setattr - mq_getsetattr i:ipp __GI_mq_setattr mq_setattr
mq_timedsend - mq_timedsend Ci:ipiip mq_timedsend
mq_timedreceive - mq_timedreceive Ci:ipipp mq_timedreceive
mq_setattr - mq_getsetattr i:ipp mq_setattr

timerfd_create EXTRA timerfd_create i:ii timerfd_create
timerfd_settime EXTRA timerfd_settime i:iipp timerfd_settime
Expand Down

0 comments on commit c21d37d

Please sign in to comment.