aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2018-10-04 12:16:05 +0000
committerJoseph Myers <joseph@codesourcery.com>2018-10-04 12:16:05 +0000
commita19876214aa9a82ab5fe3e94f6cd3ddad88f3abc (patch)
treeb53b3f31874734ad740a2b5b4070d1a6da856ef8
parente7624d708d12c608daf179d90c0d6de74c24dd2c (diff)
downloadglibc-a19876214aa9a82ab5fe3e94f6cd3ddad88f3abc.zip
glibc-a19876214aa9a82ab5fe3e94f6cd3ddad88f3abc.tar.gz
glibc-a19876214aa9a82ab5fe3e94f6cd3ddad88f3abc.tar.bz2
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.
-rw-r--r--ChangeLog12
-rw-r--r--sysdeps/ieee754/ldbl-opt/Makefile5
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.h4
-rw-r--r--sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c42
4 files changed, 62 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f770e14..8f9bac2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2018-10-04 Joseph Myers <joseph@codesourcery.com>
+
+ [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 <stli@linux.ibm.com>
* support/support.h (support_objdir_elf_ldso): New variable.
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index ef790ad..6854413 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 888f561..b7e938f 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 <stdarg.h>
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 0000000..22dc057
--- /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
+ <http://www.gnu.org/licenses/>. */
+
+/* To use the wrappers, this file deliberately does not include
+ <math.h>. */
+
+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 <support/test-driver.c>