glibc/sysdeps/nacl
Joseph Myers d709042a6e Fix lgamma setting signgam for ISO C (bug 15421).
The lgamma (and likewise lgammaf, lgammal) function wrongly sets the
signgam variable even when building for strict ISO C conformance
(-std=c99 / -std=c11), although the user may define such a variable
and it's only in the implementation namespace for POSIX with XSI
extensions enabled.

Following discussions starting at
<https://sourceware.org/ml/libc-alpha/2013-04/msg00767.html> and
<https://sourceware.org/ml/libc-alpha/2015-10/msg00844.html>, it seems
that the safest approach for fixing this particular issue is for
signgam to become a weak alias for a newly exported symbol __signgam,
with the library functions only setting __signgam, at which point
static linker magic will preserve the alias for newly linked binaries
that refer to the library's signgam rather than defining their own,
while breaking the alias for programs that define their own signgam,
with new symbol versions for lgamma functions and with compat symbols
for existing binaries that set both signgam and __signgam.

This patch implements that approach for the fix.  signgam is made into
a weak alias.  The four symbols __signgam, lgamma, lgammaf, lgammal
get new symbol versions at version GLIBC_2.23, with the existing
versions of lgamma, lgammaf and lgammal becoming compat symbols.

When the compat versions are built, gamma, gammaf and gammal are
aliases for the compat versions (i.e. always set signgam); this is OK
as they are not ISO C functions, and avoids adding new symbol versions
for them unnecessarily.  When the compat versions are not built
(i.e. for static linking and for future glibc ports), gamma, gammaf
and gammal are aliases for the new versions that set __signgam.  The
ldbl-opt versions are updated accordingly.

The lgamma wrappers are adjusted so that the same source files,
included from different files with different definitions of
USE_AS_COMPAT, can build either the new versions or the compat
versions.  Similar changes are made to the ia64 versions (untested).

Tests are added that the lgamma functions do not interfere with a user
variable called signgam for ISO C, with various choices for the size
of that variable, whether it is initialized, and for static and
dynamic linking.  The conformtest whitelist entry is removed as well.

Tested for x86_64, x86, mips64 and powerpc, including looking at
objdump --dynamic-syms output to make sure the expected sets of
symbols were aliases.  Also spot-tested that a binary built with old
glibc works properly (i.e. gets signgam set) when run with new glibc.

	[BZ #15421]
	* sysdeps/ieee754/s_signgam.c (signgam): Rename to __signgam,
	initialize with 0 and define as weak alias of __signgam.
	* include/math.h [!_ISOMAC] (__signgam): Declare.
	* math/Makefile (libm-calls): Add w_lgamma_compat.
	(tests): Add test-signgam-uchar, test-signgam-uchar-init,
	test-signgam-uint, test-signgam-uint-init, test-signgam-ullong and
	test-signgam-ullong-init.
	(tests-static): Add test-signgam-uchar-static,
	test-signgam-uchar-init-static, test-signgam-uint-static,
	test-signgam-uint-init-static, test-signgam-ullong-static and
	test-signgam-ullong-init-static.
	(CFLAGS-test-signgam-uchar.c): New variable.
	(CFLAGS-test-signgam-uchar-init.c): Likewise.
	(CFLAGS-test-signgam-uchar-static.c): Likewise.
	(CFLAGS-test-signgam-uchar-init-static.c): Likewise.
	(CFLAGS-test-signgam-uint.c): Likewise.
	(CFLAGS-test-signgam-uint-init.c): Likewise.
	(CFLAGS-test-signgam-uint-static.c): Likewise.
	(CFLAGS-test-signgam-uint-init-static.c): Likewise.
	(CFLAGS-test-signgam-ullong.c): Likewise.
	(CFLAGS-test-signgam-ullong-init.c): Likewise.
	(CFLAGS-test-signgam-ullong-static.c): Likewise.
	(CFLAGS-test-signgam-ullong-init-static.c): Likewise.
	* math/Versions (libm): Add GLIBC_2.23.
	* math/lgamma-compat.h: New file.
	* math/test-signgam-main.c: Likewise.
	* math/test-signgam-uchar-init-static.c: Likewise.
	* math/test-signgam-uchar-init.c: Likewise.
	* math/test-signgam-uchar-static.c: Likewise.
	* math/test-signgam-uchar.c: Likewise.
	* math/test-signgam-uint-init-static.c: Likewise.
	* math/test-signgam-uint-init.c: Likewise.
	* math/test-signgam-uint-static.c: Likewise.
	* math/test-signgam-uint.c: Likewise.
	* math/test-signgam-ullong-init-static.c: Likewise.
	* math/test-signgam-ullong-init.c: Likewise.
	* math/test-signgam-ullong-static.c: Likewise.
	* math/test-signgam-ullong.c: Likewise.
	* math/w_lgamma.c: Rename to w_lgamma_main.c and replace by
	wrapper of w_lgamma_main.c.
	* math/w_lgamma_compat.c: New file.
	* math/w_lgamma_compatf.c: Likewise.
	* math/w_lgamma_compatl.c: Likewise.
	* math/w_lgamma_main.c: New file.  Based on w_lgamma.c.  Include
	<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
	defining compatibility symbols.
	(__lgamma): Change to LGFUNC (__lgamma).  Use CALL_LGAMMA.
	* math/w_lgammaf.c: Rename to w_lgammaf_main.c and replace by
	wrapper of w_lgammaf_main.c.
	* math/w_lgammaf_main.c: New file.  Based on w_lgammaf.c.  Include
	<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
	defining compatibility symbols.
	(__lgammaf): Change to LGFUNC (__lgammaf).  Use CALL_LGAMMA.
	* math/w_lgammal.c: Rename to w_lgammal_main.c and replace by
	wrapper of w_lgammal_main.c.
	* math/w_lgammal_main.c: New file.  Based on w_lgammal.c.  Include
	<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
	defining compatibility symbols.
	(__lgammal): Change to LGFUNC (__lgammal).  Use CALL_LGAMMA.
	* sysdeps/ia64/fpu/lgamma-compat.h: New file.
	* sysdeps/ia64/fpu/w_lgamma.c: Move to ....
	* sysdeps/ia64/fpu/w_lgamma_main.c: ...here.  Include
	<lgamma-compat.h>.
	(__ieee754_lgamma): Change to LGFUNC (lgamma).  Use CALL_LGAMMA.
	(__ieee754_gamma): Define as alias.
	* sysdeps/ia64/fpu/w_lgammaf.c: Move to ....
	* sysdeps/ia64/fpu/w_lgammaf_main.c: ...here.  Include
	<lgamma-compat.h>.
	(__ieee754_lgammaf): Change to LGFUNC (lgammaf).  Use CALL_LGAMMA.
	(__ieee754_gammaf): Define as alias.
	* sysdeps/ia64/fpu/w_lgammal.c: Move to ....
	* sysdeps/ia64/fpu/w_lgammal_main.c: ...here.  Include
	<lgamma-compat.h>.
	(__ieee754_lgammal): Change to LGFUNC (lgammal).  Use CALL_LGAMMA.
	(__ieee754_gammal): Define as alias.
	* sysdeps/ieee754/ldbl-opt/w_lgamma.c: Move to ....
	* sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c: ...here.  Include
	<math/w_lgamma_compat.c>.
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (__lgammal_dbl_compat):
	Define as alias of __lgamma_compat and use in defining lgammal.
	* sysdeps/ieee754/ldbl-opt/w_lgammal.c: Move to ....
	* sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c: ...here.  Include
	<math/lgamma-compat.h> and <math/w_lgamma_compatl.c>.
	(USE_AS_COMPAT): New macro.
	(LGAMMA_OLD_VER): Undefine and redefine.
	(lgammal): Do not define here.
	(gammal): Only define here if [GAMMA_ALIAS].
	* conform/linknamespace.pl (@whitelist): Remove signgam.
	* sysdeps/nacl/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2015-11-20 22:49:59 +00:00
..
bits NaCl: Remove bogus O_SHLOCK, O_EXLOCK definitions. 2015-07-24 12:31:23 -07:00
_exit.c PLT avoidance for _exit in rtld. 2015-07-09 15:25:47 -07:00
access.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
backtrace.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
brk.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
chdir.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
check_fds.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
chmod.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
clock_getres.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
clock_gettime.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
clock.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
close.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
configure Add arm-nacl port. 2015-04-17 09:02:19 -07:00
configure.ac Add arm-nacl port. 2015-04-17 09:02:19 -07:00
createthread.c NaCl: Set tid field to a unique value. 2015-05-20 14:52:05 -07:00
dl-fileid.h Factor file identity rules out of generic rtld code. 2015-07-14 13:15:26 -07:00
dl-map-segments.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
dl-osinfo.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
dl-sysdep-open.h NaCl: Use open_resource API for shared objects 2015-11-10 19:44:48 -08:00
dl-sysdep.c NaCl: Use open_resource API for shared objects 2015-11-10 19:44:48 -08:00
dl-sysdep.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
dl-unmap-segments.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
dl-writev.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
dup2.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
dup.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
entry.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
errnos.awk Add arm-nacl port. 2015-04-17 09:02:19 -07:00
euidaccess.c NaCl: Fix symbol names for euidaccess. 2015-04-29 14:43:41 -07:00
exit-thread.h Add and use new glibc-internal futex API. 2015-07-10 13:47:09 +02:00
fchdir.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
fchmod.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
fdatasync.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
fdopendir.c NaCl: Make fdopendir skip fcntl check. 2015-05-13 12:50:25 -07:00
fork.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
fsync.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
ftruncate64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
ftruncate.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
futex-internal.h Add and use new glibc-internal futex API. 2015-07-10 13:47:09 +02:00
fxstat64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
fxstat.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
getcwd.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
getdents64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
getdents.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
getdtsz.c NaCl: Fix missing getdtablesize symbol. 2015-07-23 15:54:21 -07:00
gethostname.c NaCl: Implement gethostname. 2015-05-08 13:06:41 -07:00
getpagesize.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
getpid.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
getsysstats.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
gettimeofday.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
glob64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
glob.c Make sysdeps/posix bring in login subdir. 2015-07-23 17:04:22 -07:00
ifaddrs.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
Implies Add arm-nacl port. 2015-04-17 09:02:19 -07:00
init-first.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
iofdopen.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
irt.sed Add arm-nacl port. 2015-04-17 09:02:19 -07:00
isatty.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
kernel-features.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
ld.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
ldsodefs.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
libanl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libBrokenLocale.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libc-start.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
libcrypt.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libdl.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libm.abilist Fix lgamma setting signgam for ISO C (bug 15421). 2015-11-20 22:49:59 +00:00
libpthread.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libresolv.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
librt.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
libutil.abilist Simplify the abilist format 2015-11-06 13:58:53 +01:00
link.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
lll_timedlock_wait.c NaCl: Fix thinko in last change. 2015-05-26 16:11:46 -07:00
lll_timedwait_tid.c Clean up BUSY_WAIT_NOP and atomic_delay. 2015-06-30 15:57:15 +02:00
lowlevellock-futex.h NaCl: Fix lll_futex_timed_wait timeout calculation. 2015-05-28 15:35:45 -07:00
lowlevellock.h Clean up BUSY_WAIT_NOP and atomic_delay. 2015-06-30 15:57:15 +02:00
lseek64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
lseek.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
lxstat64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
lxstat.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
Makefile NaCl: Do not install <sys/mtio.h>. 2015-09-11 14:16:18 -07:00
mkdir.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
mmap64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
mmap.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
mprotect.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
munmap.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
nacl_interface_ext_supply.c NaCl: Implement nacl_interface_ext_supply entry point. 2015-06-03 13:51:11 -07:00
nacl_interface_query.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
nacl-after-link.sh Add arm-nacl port. 2015-04-17 09:02:19 -07:00
nacl-interface-list.h NaCl: Use open_resource API for shared objects 2015-11-10 19:44:48 -08:00
nacl-interface-table.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
nacl-interfaces.c NaCl: Implement nacl_interface_ext_supply entry point. 2015-06-03 13:51:11 -07:00
nacl-interfaces.h NaCl: Implement nacl_interface_ext_supply entry point. 2015-06-03 13:51:11 -07:00
nacl-interfaces.mk.in Add arm-nacl port. 2015-04-17 09:02:19 -07:00
nacl-test-wrapper.sh NaCl: Fix elf_loader file name in nacl-test-wrapper.sh 2015-05-06 12:55:58 -07:00
nanosleep.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
open64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
open.c NaCl: Use only nacl_irt_dev_filename, never nacl_irt_filename. 2015-07-21 15:48:56 -07:00
preconfigure Add arm-nacl port. 2015-04-17 09:02:19 -07:00
profil.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
pthread_condattr_setclock.c NaCl: Make pthread_condattr_setclock reject CLOCK_MONOTONIC. 2015-07-10 14:18:14 -07:00
pthread-pids.h NaCl: Make thread exit wake pthread_join. 2015-05-28 15:37:31 -07:00
read.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
readdir64_r.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
readdir64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
readdir_r.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
readdir.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
readlink.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
rename.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
rmdir.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
sched_yield.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
shlib-versions Add arm-nacl port. 2015-04-17 09:02:19 -07:00
sigaction.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
sprofil.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
start.c NaCl: Call __nacl_main in preference to main. 2015-08-25 13:37:07 -07:00
Subdirs Add arm-nacl port. 2015-04-17 09:02:19 -07:00
symlink.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
tls.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00
truncate64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
truncate.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
uname-values.h NaCl: Provide non-default values for uname. 2015-05-12 10:54:47 -07:00
unlink.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
utimes.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
Versions NaCl: Implement nacl_interface_ext_supply entry point. 2015-06-03 13:51:11 -07:00
write.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
xstat64.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
xstat.c NaCl: Use only nacl_irt_dev_filename, never nacl_irt_filename. 2015-07-21 15:48:56 -07:00
xstatconv.c Add arm-nacl port. 2015-04-17 09:02:19 -07:00
xstatconv.h Add arm-nacl port. 2015-04-17 09:02:19 -07:00