Auto-sync with upstream branch master

Upstream commit: aa42b3dbcb0326badf377fec2c7fb2f34fdabecd
This commit is contained in:
Carlos O'Donell 2018-08-24 22:29:27 -04:00
parent bebdebbdc3
commit 60efd153e5
6 changed files with 14 additions and 428 deletions

View File

@ -1,25 +0,0 @@
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Jul 4 16:16:57 2018 +0200
Makeconfig (ASFLAGS): Always append required assembler flags.
Submitted upstream here:
https://sourceware.org/ml/libc-alpha/2018-07/msg00077.html
Otherwise, we lose essential flags such as -Wa,--noexecstack due to
the way += works in make due to the ASFLAGS command line override.
diff --git a/Makeconfig b/Makeconfig
index b0b27f0113ac18b8..92e76d6200bbcd5b 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1047,7 +1047,7 @@ endif
ifndef ASFLAGS
ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
endif
-ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
+override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
ifndef BUILD_CC
BUILD_CC = $(CC)

View File

@ -8,14 +8,14 @@ behaviour which updates the locale archive. The Fedora install phase
in the spec file of the rpm will handle this manually.
diff --git a/localedata/Makefile b/localedata/Makefile
index a5f3c92d58954dfc..56719c7c714aa0f1 100644
index 0eea396ad86da956..54caabda33728207 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -218,6 +218,7 @@ $(INSTALL-SUPPORTED-LOCALES): install-locales-dir
@@ -413,6 +413,7 @@ define build-one-locale
echo -n '...'; \
input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
$(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
+ --no-archive \
-i locales/$$input -f charmaps/$$charset \
$(addprefix --prefix=,$(install_root)) $$locale \
&& echo ' done'; \
&& echo ' done';

View File

@ -1,254 +0,0 @@
commit 4b25485f03158959cff45379eecc1d73c7dcdd11
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Aug 10 11:19:26 2018 +0200
Linux: Rewrite __old_getdents64 [BZ #23497]
Commit 298d0e3129c0b5137f4989275b13fe30d0733c4d ("Consolidate Linux
getdents{64} implementation") broke the implementation because it does
not take into account struct offset differences.
The new implementation is close to the old one, before the
consolidation, but has been cleaned up slightly.
(cherry picked from commit 690652882b499defb3d950dfeff8fe421d13cab5)
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index f71cc39c7e257a0a..773aaea0e980bdd6 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -161,6 +161,7 @@ inhibit-glue = yes
ifeq ($(subdir),dirent)
sysdep_routines += getdirentries getdirentries64
+tests-internal += tst-readdir64-compat
endif
ifeq ($(subdir),nis)
diff --git a/sysdeps/unix/sysv/linux/getdents64.c b/sysdeps/unix/sysv/linux/getdents64.c
index 3bde0cf4f0226f95..bc140b5a7fac3040 100644
--- a/sysdeps/unix/sysv/linux/getdents64.c
+++ b/sysdeps/unix/sysv/linux/getdents64.c
@@ -33,41 +33,80 @@ strong_alias (__getdents64, __getdents)
# include <shlib-compat.h>
# if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
-# include <olddirent.h>
+# include <olddirent.h>
+# include <unistd.h>
-/* kernel definition of as of 3.2. */
-struct compat_linux_dirent
+static ssize_t
+handle_overflow (int fd, __off64_t offset, ssize_t count)
{
- /* Both d_ino and d_off are compat_ulong_t which are defined in all
- architectures as 'u32'. */
- uint32_t d_ino;
- uint32_t d_off;
- unsigned short d_reclen;
- char d_name[1];
-};
+ /* If this is the first entry in the buffer, we can report the
+ error. */
+ if (count == 0)
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ /* Otherwise, seek to the overflowing entry, so that the next call
+ will report the error, and return the data read so far.. */
+ if (__lseek64 (fd, offset, SEEK_SET) != 0)
+ return -1;
+ return count;
+}
ssize_t
__old_getdents64 (int fd, char *buf, size_t nbytes)
{
- ssize_t retval = INLINE_SYSCALL_CALL (getdents, fd, buf, nbytes);
+ /* We do not move the individual directory entries. This is only
+ possible if the target type (struct __old_dirent64) is smaller
+ than the source type. */
+ _Static_assert (offsetof (struct __old_dirent64, d_name)
+ <= offsetof (struct dirent64, d_name),
+ "__old_dirent64 is larger than dirent64");
+ _Static_assert (__alignof__ (struct __old_dirent64)
+ <= __alignof__ (struct dirent64),
+ "alignment of __old_dirent64 is larger than dirent64");
- /* The kernel added the d_type value after the name. Change this now. */
- if (retval != -1)
+ ssize_t retval = INLINE_SYSCALL_CALL (getdents64, fd, buf, nbytes);
+ if (retval > 0)
{
- union
- {
- struct compat_linux_dirent k;
- struct dirent u;
- } *kbuf = (void *) buf;
-
- while ((char *) kbuf < buf + retval)
+ char *p = buf;
+ char *end = buf + retval;
+ while (p < end)
{
- char d_type = *((char *) kbuf + kbuf->k.d_reclen - 1);
- memmove (kbuf->u.d_name, kbuf->k.d_name,
- strlen (kbuf->k.d_name) + 1);
- kbuf->u.d_type = d_type;
+ struct dirent64 *source = (struct dirent64 *) p;
+
+ /* Copy out the fixed-size data. */
+ __ino_t ino = source->d_ino;
+ __off64_t offset = source->d_off;
+ unsigned int reclen = source->d_reclen;
+ unsigned char type = source->d_type;
+
+ /* Check for ino_t overflow. */
+ if (__glibc_unlikely (ino != source->d_ino))
+ return handle_overflow (fd, offset, p - buf);
+
+ /* Convert to the target layout. Use a separate struct and
+ memcpy to side-step aliasing issues. */
+ struct __old_dirent64 result;
+ result.d_ino = ino;
+ result.d_off = offset;
+ result.d_reclen = reclen;
+ result.d_type = type;
+
+ /* Write the fixed-sized part of the result to the
+ buffer. */
+ size_t result_name_offset = offsetof (struct __old_dirent64, d_name);
+ memcpy (p, &result, result_name_offset);
+
+ /* Adjust the position of the name if necessary. Copy
+ everything until the end of the record, including the
+ terminating NUL byte. */
+ if (result_name_offset != offsetof (struct dirent64, d_name))
+ memmove (p + result_name_offset, source->d_name,
+ reclen - offsetof (struct dirent64, d_name));
- kbuf = (void *) ((char *) kbuf + kbuf->k.d_reclen);
+ p += reclen;
}
}
return retval;
diff --git a/sysdeps/unix/sysv/linux/tst-readdir64-compat.c b/sysdeps/unix/sysv/linux/tst-readdir64-compat.c
new file mode 100644
index 0000000000000000..43c4a8477c7403c5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-readdir64-compat.c
@@ -0,0 +1,111 @@
+/* Test readdir64 compatibility symbol.
+ 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/>. */
+
+#include <dirent.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <shlib-compat.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <support/check.h>
+
+/* Copied from <olddirent.h>. */
+struct __old_dirent64
+ {
+ __ino_t d_ino;
+ __off64_t d_off;
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256];
+ };
+
+typedef struct __old_dirent64 *(*compat_readdir64_type) (DIR *);
+
+#if TEST_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)
+struct __old_dirent64 *compat_readdir64 (DIR *);
+compat_symbol_reference (libc, compat_readdir64, readdir64, GLIBC_2_1);
+#endif
+
+static int
+do_test (void)
+{
+#if TEST_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)
+
+ /* Directory stream using the non-compat readdir64 symbol. The test
+ checks against this. */
+ DIR *dir_reference = opendir (".");
+ TEST_VERIFY_EXIT (dir_reference != NULL);
+ DIR *dir_test = opendir (".");
+ TEST_VERIFY_EXIT (dir_test != NULL);
+
+ /* This loop assumes that the enumeration order is consistent for
+ two different handles. Nothing should write to the current
+ directory (in the source tree) while this test runs, so there
+ should not be any difference due to races. */
+ size_t count = 0;
+ while (true)
+ {
+ errno = 0;
+ struct dirent64 *entry_reference = readdir64 (dir_reference);
+ if (entry_reference == NULL && errno != 0)
+ FAIL_EXIT1 ("readdir64 entry %zu: %m\n", count);
+ struct __old_dirent64 *entry_test = compat_readdir64 (dir_test);
+ if (entry_reference == NULL)
+ {
+ if (errno == EOVERFLOW)
+ {
+ TEST_VERIFY (entry_reference->d_ino
+ != (__ino_t) entry_reference->d_ino);
+ printf ("info: inode number overflow at entry %zu\n", count);
+ break;
+ }
+ if (errno != 0)
+ FAIL_EXIT1 ("compat readdir64 entry %zu: %m\n", count);
+ }
+
+ /* Check that both streams end at the same time. */
+ if (entry_reference == NULL)
+ {
+ TEST_VERIFY (entry_test == NULL);
+ break;
+ }
+ else
+ TEST_VERIFY_EXIT (entry_test != NULL);
+
+ /* Check that the entries are the same. */
+ TEST_COMPARE_BLOB (entry_reference->d_name,
+ strlen (entry_reference->d_name),
+ entry_test->d_name, strlen (entry_test->d_name));
+ TEST_COMPARE (entry_reference->d_ino, entry_test->d_ino);
+ TEST_COMPARE (entry_reference->d_off, entry_test->d_off);
+ TEST_COMPARE (entry_reference->d_type, entry_test->d_type);
+ TEST_COMPARE (entry_reference->d_reclen, entry_test->d_reclen);
+
+ ++count;
+ }
+ printf ("info: %zu directory entries found\n", count);
+ TEST_VERIFY (count >= 3); /* ".", "..", and some source files. */
+
+ TEST_COMPARE (closedir (dir_test), 0);
+ TEST_COMPARE (closedir (dir_reference), 0);
+#endif
+ return 0;
+}
+
+#include <support/test-driver.c>

View File

@ -1,139 +0,0 @@
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Jul 4 11:34:36 2018 +0200
Add --with-nonshared-cflags option to configure
Submitted upstream:
https://sourceware.org/ml/libc-alpha/2018-07/msg00071.html
diff --git a/INSTALL b/INSTALL
index 0a22aa7d01e6e87b..0f80d9d615db6d42 100644
--- a/INSTALL
+++ b/INSTALL
@@ -90,6 +90,15 @@ if 'CFLAGS' is specified it must enable optimization. For example:
library will still be usable, but functionality may be lost--for
example, you can't build a shared libc with old binutils.
+'--with-nonshared-cflags=CFLAGS'
+ Use additional compiler flags CFLAGS to build the parts of the
+ library which are always statically linked into applications and
+ libraries even with shared linking (that is, the object files
+ contained in 'lib*_nonshared.a' libraries). The build process will
+ automatically use the appropriate flags, but this option can be
+ used to set additional flags required for building applications and
+ libraries, to match local policy.
+
'--disable-shared'
Don't build shared libraries even if it is possible. Not all
systems support shared libraries; you need ELF support and
diff --git a/Makeconfig b/Makeconfig
index 608ffe648c80c724..b0b27f0113ac18b8 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1038,7 +1038,7 @@ object-suffixes-for-libc += .oS
# Must build the routines as PIC, though, because they can end up in (users')
# shared objects. We don't want to use CFLAGS-os because users may, for
# example, make that processor-specific.
-CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
+CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
libtype.oS = lib%_nonshared.a
endif
diff --git a/config.make.in b/config.make.in
index d9891b2cd8ec3fbf..a6fe48d31f4d2725 100644
--- a/config.make.in
+++ b/config.make.in
@@ -110,6 +110,7 @@ BUILD_CC = @BUILD_CC@
CFLAGS = @CFLAGS@
CPPFLAGS-config = @CPPFLAGS@
CPPUNDEFS = @CPPUNDEFS@
+extra-nonshared-cflags = @extra_nonshared_cflags@
ASFLAGS-config = @ASFLAGS_config@
AR = @AR@
NM = @NM@
diff --git a/configure b/configure
index ef1830221522b7a5..fec0efff8216addd 100755
--- a/configure
+++ b/configure
@@ -684,6 +684,7 @@ force_install
bindnow
hardcoded_path_in_tests
enable_timezone_tools
+extra_nonshared_cflags
use_default_link
sysheaders
ac_ct_CXX
@@ -762,6 +763,7 @@ with_binutils
with_selinux
with_headers
with_default_link
+with_nonshared_cflags
enable_sanity_checks
enable_shared
enable_profile
@@ -1479,6 +1481,8 @@ Optional Packages:
--with-headers=PATH location of system headers to use (for example
/usr/src/linux/include) [default=compiler default]
--with-default-link do not use explicit linker scripts
+ --with-nonshared-cflags=FLAGS
+ build nonshared libraries with additional FLAGS
--with-cpu=CPU select code for CPU variant
Some influential environment variables:
@@ -3336,6 +3340,16 @@ else
fi
+
+# Check whether --with-nonshared-cflags was given.
+if test "${with_nonshared_cflags+set}" = set; then :
+ withval=$with_nonshared_cflags; extra_nonshared_cflags=$withval
+else
+ extra_nonshared_cflags=
+fi
+
+
+
# Check whether --enable-sanity-checks was given.
if test "${enable_sanity_checks+set}" = set; then :
enableval=$enable_sanity_checks; enable_sanity=$enableval
diff --git a/configure.ac b/configure.ac
index dc517017f588626a..154185d70de38928 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,6 +154,14 @@ AC_ARG_WITH([default-link],
[use_default_link=$withval],
[use_default_link=default])
+dnl Additional build flags injection.
+AC_ARG_WITH([nonshared-cflags],
+ AC_HELP_STRING([--with-nonshared-cflags=FLAGS],
+ [build nonshared libraries with additional FLAGS]),
+ [extra_nonshared_cflags=$withval],
+ [extra_nonshared_cflags=])
+AC_SUBST(extra_nonshared_cflags)
+
AC_ARG_ENABLE([sanity-checks],
AC_HELP_STRING([--disable-sanity-checks],
[really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
diff --git a/manual/install.texi b/manual/install.texi
index 422da1447eb4dc68..eaf0cd09e7501b96 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -117,6 +117,15 @@ problem and suppress these constructs, so that the library will still be
usable, but functionality may be lost---for example, you can't build a
shared libc with old binutils.
+@item --with-nonshared-cflags=@var{cflags}
+Use additional compiler flags @var{cflags} to build the parts of the
+library which are always statically linked into applications and
+libraries even with shared linking (that is, the object files contained
+in @file{lib*_nonshared.a} libraries). The build process will
+automatically use the appropriate flags, but this option can be used to
+set additional flags required for building applications and libraries,
+to match local policy.
+
@c disable static doesn't work currently
@c @item --disable-static
@c Don't build static libraries. Static libraries aren't that useful these

View File

@ -1,6 +1,6 @@
%define glibcsrcdir glibc-2.28
%define glibcversion 2.28
%define glibcrelease 5%{?dist}
%define glibcsrcdir glibc-2.28.9000-79-gaa42b3dbcb
%define glibcversion 2.28.9000
%define glibcrelease 1%{?dist}
# Pre-release tarballs are pulled in from git using a command that is
# effectively:
#
@ -157,10 +157,7 @@ Patch16: glibc-nscd-sysconfig.patch
Patch17: glibc-cs-path.patch
Patch18: glibc-c-utf8-locale.patch
Patch23: glibc-python3.patch
Patch24: glibc-with-nonshared-cflags.patch
Patch25: glibc-asflags.patch
Patch26: glibc-ldflags.patch
Patch27: glibc-rh1614705.patch
Patch28: glibc-rh1615608.patch
##############################################################################
@ -1877,6 +1874,13 @@ fi
%endif
%changelog
* Tue Aug 21 2018 Carlos O'Donell <carlos@systemhalted.org> - 2.28.9000-1
- Drop glibc-asflags.patch. Applied upstream.
- Drop glibc-rh1614705.patch. Applied upstream.
- Drop glibc-with-nonshared-cflags.patch. Applied upstream.
- Auto-sync with upstream branch master,
commit aa42b3dbcb0326badf377fec2c7fb2f34fdabecd.
* Mon Aug 13 2018 Carlos O'Donell <carlos@redhat.com> - 2.28-5
- Remove abort() warning in manual (#1615608)

View File

@ -1 +1 @@
SHA512 (glibc-2.28.tar.xz) = 521f820953ff07c69ece4c2186f59fc061a7f9747932cd70ef2995c2b2deee76eeb6de700d85071cdca5949179aa8ccee75eda7feca1394121ec7b821ad0a3f3
SHA512 (glibc-2.28.9000-79-gaa42b3dbcb.tar.xz) = 76fa7ef2e1119523eba29ae9d3384c25902f907b29bbebacab3bcffb341e6992477edea955c614cdab337a1cba557549ba2107d26ad7e03aaaa93e832304be2e