@@ -241,7 +241,12 @@ tests += \
tst-nldbl-scanf-binary-c23 \
tst-nldbl-scanf-binary-gnu11 \
tst-nldbl-scanf-binary-gnu89 \
+ test-nldbl-fscanf-redirect \
+ test-nldbl-fscanf-redirect-static \
# tests
+tests-static += \
+ test-nldbl-fscanf-redirect-static \
+# tests-static
# Some versions of GCC supported for building glibc do not support -std=c23
# (added in GCC 14), or the older name -std=c2x (added in GCC 9), so
@@ -255,6 +260,12 @@ CFLAGS-tst-nldbl-scanf-binary-gnu11.c += -mlong-double-64 -std=gnu11 \
-DOBJPFX=\"$(objpfx)\"
CFLAGS-tst-nldbl-scanf-binary-gnu89.c += -mlong-double-64 -std=gnu89 \
-DOBJPFX=\"$(objpfx)\"
+CFLAGS-test-nldbl-fscanf-redirect.c += -mlong-double-64
+CFLAGS-test-nldbl-fscanf-redirect-static.c += -mlong-double-64
+$(objpfx)test-nldbl-fscanf-redirect: \
+ $(common-objpfx)math/libnldbl_nonshared.a
+$(objpfx)test-nldbl-fscanf-redirect-static: \
+ $(common-objpfx)math/libnldbl_nonshared.a
endif
@@ -274,7 +274,9 @@ __nldbl_wprintf (const wchar_t *fmt, ...)
return ret;
}
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
+/* Always define __nldbl__IO_vfscanf in libc.a since it is used in
+ libnldbl_nonshared.a. */
+#if !defined SHARED || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
int
attribute_compat_text_section
__nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp)
new file mode 100644
@@ -0,0 +1 @@
+#include "test-nldbl-fscanf-redirect.c"
new file mode 100644
@@ -0,0 +1 @@
+25 54.32E-1 thompson
new file mode 100644
@@ -0,0 +1,37 @@
+/* Test fscanf of long double as double without <stdio.h>.
+ Copyright (C) 2024 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <string.h>
+
+struct FILE;
+extern struct FILE *stdin;
+extern int fscanf (struct FILE *, const char *, ...);
+
+int
+main (void)
+{
+ int n, i;
+ long double x;
+ char name[50];
+ n = fscanf (stdin, "%d%Lf%s", &i, &x, name);
+
+ if (n != 3 || i != 25 || x != 5.432 || strcmp (name, "thompson"))
+ return 1;
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1 @@
+25 54.32E-1 thompson
Fix BZ #31776 by always defining __nldbl__IO_vfscanf in libc.a since it is used in libnldbl_nonshared.a. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> --- sysdeps/ieee754/ldbl-opt/Makefile | 11 ++++++ sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 4 +- .../test-nldbl-fscanf-redirect-static.c | 1 + .../test-nldbl-fscanf-redirect-static.input | 1 + .../ldbl-opt/test-nldbl-fscanf-redirect.c | 37 +++++++++++++++++++ .../ldbl-opt/test-nldbl-fscanf-redirect.input | 1 + 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.c create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.input create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input