From a19876214aa9a82ab5fe3e94f6cd3ddad88f3abc Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 4 Oct 2018 12:16:05 +0000 Subject: [PATCH] Fix libnldbl_nonshared.a references to internal libm symbols (bug 23735). The redirection of built-in functions such as sqrt in include/math.h applies when the wrappers for those functions in libnldbl_nonshared.a are built, resulting in references to internal names such as __ieee754_sqrt that aren't actually exported from the shared libm. (This applies for sqrt in 2.28, also for the round-to-integer functions in current master because of my changes there.) This patch arranges for NO_MATH_REDIRECT to be used for all the affected functions, and adds a test for those functions in libnldbl_nonshared.a. (We could of course choose to obsolete libnldbl_nonshared.a and require that people building with -mlong-double-64 either include the relevant headers and have a compiler supporting asm redirection, or have some other means of achieving that redirection at compile time if not including those headers. But while we have libnldbl_nonshared.a, it seems appropriate to fix such bugs in it.) Tested for powerpc, and with build-many-glibcs.py. [BZ #23735] * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (NO_MATH_REDIRECT): Define. * sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c: New file. * sysdeps/ieee754/ldbl-opt/Makefile [$(subdir) = math] (tests): Add test-nldbl-redirect. [$(subdir) = math] (CFLAGS-test-nldbl-redirect.c): New variable. [$(subdir) = math] ($(objpfx)test-nldbl-redirect): Depend on $(objpfx)libnldbl_nonshared.a. --- ChangeLog | 12 ++++++++ sysdeps/ieee754/ldbl-opt/Makefile | 5 ++- sysdeps/ieee754/ldbl-opt/nldbl-compat.h | 4 +++ sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c | 42 ++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c diff --git a/ChangeLog b/ChangeLog index f770e14e74..8f9bac2565 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2018-10-04 Joseph Myers + + [BZ #23735] + * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (NO_MATH_REDIRECT): + Define. + * sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c: New file. + * sysdeps/ieee754/ldbl-opt/Makefile [$(subdir) = math] (tests): + Add test-nldbl-redirect. + [$(subdir) = math] (CFLAGS-test-nldbl-redirect.c): New variable. + [$(subdir) = math] ($(objpfx)test-nldbl-redirect): Depend on + $(objpfx)libnldbl_nonshared.a. + 2018-10-04 Stefan Liebler * support/support.h (support_objdir_elf_ldso): New variable. diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile index ef790adc77..6854413fa3 100644 --- a/sysdeps/ieee754/ldbl-opt/Makefile +++ b/sysdeps/ieee754/ldbl-opt/Makefile @@ -172,7 +172,10 @@ CFLAGS-nldbl-y0.c = -fno-builtin-y0l CFLAGS-nldbl-y1.c = -fno-builtin-y1l CFLAGS-nldbl-yn.c = -fno-builtin-ynl -tests += test-narrow-macros-ldbl-64 +tests += test-narrow-macros-ldbl-64 test-nldbl-redirect CFLAGS-test-narrow-macros-ldbl-64.c += -mlong-double-64 +CFLAGS-test-nldbl-redirect.c += -mlong-double-64 + +$(objpfx)test-nldbl-redirect: $(objpfx)libnldbl_nonshared.a endif diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h index 888f561cac..b7e938f785 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h @@ -20,6 +20,10 @@ #ifndef __NLDBL_COMPAT_H #define __NLDBL_COMPAT_H 1 +/* Ensure calls to libm functions from libnldbl_nonshared.a call + public names, not libm-internal names. */ +#define NO_MATH_REDIRECT + /* Avoid long double prototypes. */ #define __NO_LONG_DOUBLE_MATH 1 #include diff --git a/sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c b/sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c new file mode 100644 index 0000000000..22dc0572aa --- /dev/null +++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c @@ -0,0 +1,42 @@ +/* Test libnldbl_nonshared.a wrappers call visible functions (bug 23735). + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* To use the wrappers, this file deliberately does not include + . */ + +long double sqrtl (long double); +long double ceill (long double); +long double floorl (long double); +long double rintl (long double); +long double truncl (long double); +long double roundl (long double); + +volatile long double x = 2.25L; + +static int +do_test (void) +{ + return (sqrtl (x) != 1.5L + || ceill (x) != 3.0L + || floorl (x) != 2.0L + || rintl (x) != 2.0L + || truncl (x) != 2.0L + || roundl (x) != 2.0L); +} + +#include -- 2.11.4.GIT