This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix libnldbl_nonshared.a references to internal libm symbols (bug 23735) [committed]

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

(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  Committed.

2018-10-04  Joseph Myers  <>

	[BZ #23735]
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (NO_MATH_REDIRECT):
	* 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

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
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.  */
 /* 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 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
+   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
+   <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>

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]