1 diff --git a/ChangeLog b/ChangeLog
2 index cb9124e..ed20b9b 100644
6 +2016-01-27 Paul Eggert <eggert@cs.ucla.edu>
9 + * misc/hsearch_r.c (isprime, __hcreate_r): Protect against
10 + unsigned int wraparound.
12 +2016-01-27 Florian Weimer <fweimer@redhat.com>
15 + * misc/bug18240.c: New test.
16 + * misc/Makefile (tests): Add it.
18 +2015-08-25 Ondřej Bílka <neleai@seznam.cz>
21 + * misc/hsearch_r.c (__hcreate_r): Handle overflow.
23 +2015-10-27 Ludovic Courtès <ludo@gnu.org>
25 + * locale/loadlocale.c (_nl_intern_locale_data): Change assertion
26 + on CNT to a conditional jump to 'puntdata'.
28 +2015-08-18 Alan Modra <amodra@gmail.com>
31 + * sysdeps/hppa/start.S [SHARED]: Use .section .data.rel.ro and define
33 + (_start): Load %dp via .Lp__global.
34 + [!SHARED]: Use .section .rodata.
36 +2015-08-09 John David Anglin <danglin@gcc.gnu.org>
39 + * sysdeps/unix/sysv/linux/hppa/sysdep.h (LOAD_ARGS_0, LOAD_ARGS_1,
40 + LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4, LOAD_ARGS_5, LOAD_ARGS_6):
42 + (LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4,
43 + LOAD_REGS_5, LOAD_REGS_6): Update.
44 + (INTERNAL_SYSCALL): Update using new LOAD defines.
45 + (INTERNAL_SYSCALL_NCS): Likewise.
46 + * sysdeps/unix/sysv/linux/hppa/syscall.c (syscall): Likewise.
48 +2015-09-26 Paul Pluzhnikov <ppluzhnikov@google.com>
51 + * time/strftime_l.c (a_wkday, f_wkday, a_month, f_month): Range check.
52 + (__strftime_internal): Likewise.
53 + * time/tst-strftime.c (do_bz18985): New test.
56 +2015-08-08 Paul Pluzhnikov <ppluzhnikov@google.com>
59 + * catgets/Makefile (tst-catgets-mem): New test.
60 + * catgets/catgets.c (catopen): Don't use unbounded alloca.
61 + * catgets/open_catalog.c (__open_catalog): Likewise.
62 + * catgets/tst-catgets.c (do_bz17905): Test unbounded alloca.
64 +2015-12-31 Aurelien Jarno <aurelien@aurel32.net>
66 + * sysdeps/unix/sysv/linux/alpha/libc.abilist [GLIBC_2.22]: Move
67 + to keep the file sorted.
68 + * sysdeps/unix/sysv/linux/hppa/libc.abilist [GLIBC_2.22]: Likewise.
70 +2015-12-17 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
73 + * sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of
74 + .skip_lock_out_of_tbegin_retries.
75 + * sysdeps/unix/sysv/linux/powerpc/elision-lock.c
76 + (__lll_lock_elision): Likewise, and respect a value of
79 +2015-12-03 Andrew Senkevich <andrew.senkevich@intel.com>
81 + * math/Makefile ($(inst_libdir)/libm.so): Corrected path to
84 +2015-11-27 Andrew Senkevich <andrew.senkevich@intel.com>
87 + * math/Makefile ($(inst_libdir)/libm.so): Added libmvec_nonshared.a to
89 + * sysdeps/x86/fpu/bits/math-vector.h: Removed code with asm aliases
91 + * sysdeps/x86_64/fpu/Makefile (libmvec-support,
92 + libmvec-static-only-routines): Added new file.
93 + * sysdeps/x86_64/fpu/svml_finite_alias.S: New file.
94 + * NEWS: Mention this fix.
96 +2015-11-20 Roland McGrath <roland@hack.frob.com>
98 + * sysdeps/nacl/dl-map-segments.h (_dl_map_segments): Use
99 + __glibc_likely instead of __builtin_expect. After falling back to
100 + dyncode_create in a non-ET_DYN case, use the allocate_code_data
101 + system interface to register the code pages as occupied.
103 +2015-11-14 H.J. Lu <hongjiu.lu@intel.com>
105 + * config.make.in (have-glob-dat-reloc): New.
106 + * configure.ac (libc_cv_has_glob_dat): New. Set to yes if
107 + target supports GLOB_DAT relocaton. AC_SUBST.
108 + * configure: Regenerated.
109 + * elf/Makefile (tests): Add tst-prelink.
110 + (tests-special): Add $(objpfx)tst-prelink-cmp.out.
111 + (tst-prelink-ENV): New.
112 + ($(objpfx)tst-prelink-conflict.out): Likewise.
113 + ($(objpfx)tst-prelink-cmp.out): Likewise.
114 + * sysdeps/x86/tst-prelink.c: Moved to ...
115 + * elf/tst-prelink.c: Here.
116 + * sysdeps/x86/tst-prelink.exp: Moved to ...
117 + * elf/tst-prelink.exp: Here.
118 + * sysdeps/x86/Makefile (tests): Don't add tst-prelink.
119 + (tst-prelink-ENV): Removed.
120 + ($(objpfx)tst-prelink-conflict.out): Likewise.
121 + ($(objpfx)tst-prelink-cmp.out): Likewise.
122 + (tests-special): Don't add $(objpfx)tst-prelink-cmp.out.
124 +2015-11-10 Roland McGrath <roland@hack.frob.com>
126 + * elf/dl-load.c (open_verify): Take new argument FD.
127 + Skip __open call if passed FD is not -1.
128 + (_dl_map_object, open_path): Update callers.
129 + * elf/dl-sysdep-open.h: New file.
130 + * elf/dl-load.c: Include it.
131 + (_dl_map_object): Try _dl_sysdep_open_object before ldconfig cache.
132 + * sysdeps/nacl/dl-sysdep.c (_dl_sysdep_open_object): New function.
133 + * sysdeps/nacl/dl-sysdep-open.h: New file.
134 + * sysdeps/nacl/nacl-interface-list.h: Move nacl_irt_resource_open
137 +2015-11-10 H.J. Lu <hongjiu.lu@intel.com>
140 + * sysdeps/x86/Makefile (tests): Add tst-prelink.
141 + (tst-prelink-ENV): New.
142 + ($(objpfx)tst-prelink-conflict.out): Likewise.
143 + ($(objpfx)tst-prelink-cmp.out): Likewise.
144 + (tests-special): Add $(objpfx)tst-prelink-cmp.out.
145 + * sysdeps/x86/tst-prelink.c: New file.
146 + * sysdeps/x86/tst-prelink.exp: Likewise.
148 +2015-11-07 H.J. Lu <hongjiu.lu@intel.com>
151 + * elf/dl-lookup.c (RTYPE_CLASS_VALID): New.
152 + (RTYPE_CLASS_PLT): Likewise.
153 + (RTYPE_CLASS_COPY): Likewise.
154 + (RTYPE_CLASS_TLS): Likewise.
155 + (_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID
156 + to set relocation type class for DL_DEBUG_PRELINK. Keep only
157 + ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY bits for
160 +2015-10-20 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
163 + * sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
165 + (ELIDE_LOCK): ...here.
166 + (__get_new_count): New function with part of the code from
167 + __elide_lock that updates the value of adapt_count after a
169 + (__elided_trylock): Moved this code to...
170 + (ELIDE_TRYLOCK): ...here.
172 +2015-10-06 Florian Weimer <fweimer@redhat.com>
175 + * stdlib/cxa_thread_atexit_impl.c (__cxa_thread_atexit_impl):
176 + Mangle function pointer before storing it.
177 + (__call_tls_dtors): Demangle function pointer before calling it.
179 +2015-10-15 Florian Weimer <fweimer@redhat.com>
182 + * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
183 + _dl_pointer_guard member.
184 + * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
186 + (security_init): Always set up pointer guard.
187 + (process_envvars): Do not process LD_POINTER_GUARD.
189 +2015-10-09 Carlos O'Donell <carlos@redhat.com>
192 + * string/bug-strcoll2.c: Adjust copyright, and remove contributed by.
193 + * string/Makefile ($(objpfx)bug-strcoll2.out): Depend on
196 +2015-10-08 Carlos O'Donell <carlos@redhat.com>
199 + * string/Makefile (tests): Add bug-strcoll2.
200 + (LOCALES): Add cs_CZ.UTF-8.
202 +2015-09-28 Martin Sebor <msebor@redhat.com>
205 + * string/Makefile (LOCALES): Define.
206 + (gen-locales.mk): Include.
207 + (test-strcasecmp.out, test-strncasecmp.out, tst-strxfrm.out)
208 + (tst-strxfrm2.out): Add deppendency on $(gen-locales).
209 + * string/tst-strxfrm2.c (do_test): Print the name of the locale
210 + on setlocale failure.
212 +2015-10-08 Carlos O'Donell <carlos@redhat.com>
215 + * string/bug-strcoll2.c: New file.
216 + * locale/categories.def: Revert commit
217 + f13c2a8dff2329c6692a80176262ceaaf8a6f74e.
218 + * locale/langinfo.h: Likewise.
219 + * locale/localeinfo.h: Likewise.
220 + * locale/C-collate.c: Likewise.
221 + * programs/ld-collate.c (collate_output): Likewise.
222 + * string/strcoll_l.c (STRDIFF): Likewise.
223 + (STRCOLL): Likewise.
224 + * wcsmbs/wcscoll_l.c: Likewise.
226 +2015-09-15 Roland McGrath <roland@hack.frob.com>
228 + * misc/sys/param.h [!MAXHOSTNAMELEN && HOST_NAME_MAX]
229 + (MAXHOSTNAMELEN): Define it to HOST_NAME_MAX.
231 +2015-09-11 Roland McGrath <roland@hack.frob.com>
233 + * sysdeps/nacl/Makefile [$(subdir) = misc] (sysdep_headers):
234 + Use 'override' keyword to freeze the value here, preventing
235 + the addition of sys/mtio.h by sysdeps/gnu/Makefile.
237 +2015-09-04 Roland McGrath <roland@hack.frob.com>
240 + * sysdeps/posix/opendir.c (need_isdir_precheck) [O_DIRECTORY]:
241 + Fix inverted sense of test of 'o_directory_works' value.
242 + Reported by Pádraig Brady <P@draigBrady.com>, diagnosed by
243 + Bernhard Voelker <mail@bernhard-voelker.de>.
245 +2015-08-31 Brett Neumeier <brett@neumeier.us>
248 + * sysdeps/sparc/sparc32/sem_open.c: Add missing #include
250 +2015-08-28 Mike Frysinger <vapier@gentoo.org>
253 + * misc/Makefile (tests): Add tst-mntent-blank-corrupt and
254 + tst-mntent-blank-passno.
255 + * misc/mntent_r.c (__getmntent_r): Do not read past buffer[0].
256 + * misc/tst-mntent-blank-corrupt.c: New test.
257 + * misc/tst-mntent-blank-passno.c: New test ripped from ...
258 + * misc/tst-mntent.c (do_test): ... here.
260 +2015-08-25 Roland McGrath <roland@hack.frob.com>
262 + * sysdeps/nacl/start.c (_start): Call __nacl_main instead of main
263 + if the weak reference is not null.
265 +2015-08-19 Andrew Senkevich <andrew.senkevich@intel.com>
268 + * scripts/test-installation.pl: Don't add -lmvec to build options
269 + if libmvec wasn't built.
270 + * NEWS: Mention this fix.
272 +2015-08-10 Maxim Ostapenko <m.ostapenko@partner.samsung.com>
275 + * elf/Makefile (tests): Add Add tst-nodelete2.
276 + (modules-names): Add tst-nodelete2mod.
277 + (tst-nodelete2mod.so-no-z-defs): New.
278 + ($(objpfx)tst-nodelete2): Likewise.
279 + ($(objpfx)tst-nodelete2.out): Likewise.
280 + (LDFLAGS-tst-nodelete2): Likewise.
281 + * elf/dl-close.c (_dl_close_worker): Move DF_1_NODELETE clearing
282 + out of loop through all loaded libraries.
283 + * elf/tst-nodelete2.c: New file.
284 + * elf/tst-nodelete2mod.c: Likewise.
286 +2015-08-10 Andreas Schwab <schwab@suse.de>
289 + * sysdeps/unix/sysv/linux/openat.c (__OPENAT) [MORE_OFLAGS]: Add
290 + MORE_OFLAGS to oflag.
291 + * io/test-lfs.c (do_test): Test openat64.
293 +2015-08-08 John David Anglin <danglin@gcc.gnu.org>
296 + * sysdeps/unix/sysv/linux/hppa/bits/atomic.h (_LWS_CLOBBER): Revise
298 + (atomic_compare_and_exchange_val_acq): Use register asms to assign
299 + operand registers. Use register %r20 for EAGAIN and EDEADLOCK checks.
300 + Cast return to __typeof (oldval).
302 +2015-08-08 Mike Frysinger <vapier@gentoo.org>
304 + * sysdeps/unix/sysv/linux/microblaze/sysdep.h: Wrap the whole file
305 + in _LINUX_MICROBLAZE_SYSDEP_H defines. Include sysdeps/unix/sysdep.h
306 + and delete sys/syscall.h include.
308 +2015-08-07 Mike Frysinger <vapier@gentoo.org>
310 + * sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Add rtld_hidden_def.
312 +2015-08-05 Zack Weinberg <zackw@panix.com>
314 + * misc/regexp.h: Update comments.
316 2015-08-05 Carlos O'Donell <carlos@systemhalted.org>
318 * version.h (RELEASE): Set to "stable".
319 diff --git a/NEWS b/NEWS
320 index 4c31de7..d1daf9b 100644
323 @@ -5,6 +5,16 @@ See the end for copying conditions.
324 Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
325 using `glibc' in the "product" field.
329 +* The following bugs are resolved with this release:
331 + 17905, 18420, 18421, 18480, 18589, 18743, 18778, 18781, 18787, 18796,
332 + 18870, 18887, 18921, 18928, 18969, 18985, 19018, 19058, 19174, 19178.
334 +* The LD_POINTER_GUARD environment variable can no longer be used to
335 + disable the pointer guard feature. It is always enabled.
339 * The following bugs are resolved with this release:
340 @@ -84,7 +94,7 @@ Version 2.22
341 release. Use of this header will trigger a deprecation warning.
342 Application developers should update their code to use <regex.h> instead.
344 - This header was formerly part of SUSv2, but was deprecated in 1997 and
345 + This header was formerly part of SUS, but was deprecated in 1994 and
346 removed from the standard in 2001. Also, the glibc implementation
347 leaks memory. See BZ#18681 for more details.
349 diff --git a/catgets/Makefile b/catgets/Makefile
350 index 4624a88..56de38b 100644
351 --- a/catgets/Makefile
352 +++ b/catgets/Makefile
353 @@ -34,6 +34,7 @@ test-srcs = test-gencat
354 ifeq ($(run-built-tests),yes)
355 tests-special += $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
356 $(objpfx)sample.SJIS.cat $(objpfx)test-gencat.out
357 +tests-special += $(objpfx)tst-catgets-mem.out
360 gencat-modules = xmalloc
361 @@ -50,9 +51,11 @@ catgets-CPPFLAGS := -DNLSPATH='"$(msgcatdir)/%L/%N:$(msgcatdir)/%L/LC_MESSAGES/%
363 generated += de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
365 +generated += tst-catgets.mtrace tst-catgets-mem.out
369 -tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
370 +tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de MALLOC_TRACE=$(objpfx)tst-catgets.mtrace
372 ifeq ($(run-built-tests),yes)
373 # This test just checks whether the program produces any error or not.
374 @@ -86,4 +89,8 @@ $(objpfx)test-gencat.out: test-gencat.sh $(objpfx)test-gencat \
375 $(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
376 $(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@; \
379 +$(objpfx)tst-catgets-mem.out: $(objpfx)tst-catgets.out
380 + $(common-objpfx)malloc/mtrace $(objpfx)tst-catgets.mtrace > $@; \
383 diff --git a/catgets/catgets.c b/catgets/catgets.c
384 index cf93d56..4be452d 100644
385 --- a/catgets/catgets.c
386 +++ b/catgets/catgets.c
388 License along with the GNU C Library; if not, see
389 <http://www.gnu.org/licenses/>. */
394 #include <nl_types.h>
395 @@ -35,6 +34,7 @@ catopen (const char *cat_name, int flag)
397 const char *env_var = NULL;
398 const char *nlspath = NULL;
401 if (strchr (cat_name, '/') == NULL)
403 @@ -54,7 +54,10 @@ catopen (const char *cat_name, int flag)
405 /* Append the system dependent directory. */
406 size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
407 - char *tmp = alloca (len);
408 + tmp = malloc (len);
410 + if (__glibc_unlikely (tmp == NULL))
411 + return (nl_catd) -1;
413 __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
415 @@ -65,16 +68,18 @@ catopen (const char *cat_name, int flag)
417 result = (__nl_catd) malloc (sizeof (*result));
419 - /* We cannot get enough memory. */
420 - return (nl_catd) -1;
422 - if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
424 + /* We cannot get enough memory. */
425 + result = (nl_catd) -1;
427 + else if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
429 /* Couldn't open the file. */
430 free ((void *) result);
431 - return (nl_catd) -1;
432 + result = (nl_catd) -1;
436 return (nl_catd) result;
439 diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
440 index e069416..9f4d776 100644
441 --- a/catgets/open_catalog.c
442 +++ b/catgets/open_catalog.c
443 @@ -47,6 +47,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
449 if (strchr (cat_name, '/') != NULL || nlspath == NULL)
450 fd = open_not_cancel_2 (cat_name, O_RDONLY);
451 @@ -57,23 +58,23 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
452 if (__glibc_unlikely (bufact + (n) >= bufmax)) \
454 char *old_buf = buf; \
455 - bufmax += 256 + (n); \
456 - buf = (char *) alloca (bufmax); \
457 - memcpy (buf, old_buf, bufact); \
458 + bufmax += (bufmax < 256 + (n)) ? 256 + (n) : bufmax; \
459 + buf = realloc (buf, bufmax); \
460 + if (__glibc_unlikely (buf == NULL)) \
467 /* The RUN_NLSPATH variable contains a colon separated list of
468 descriptions where we expect to find catalogs. We have to
469 recognize certain % substitutions and stop when we found the
470 first existing file. */
481 while (*run_nlspath != '\0')
483 @@ -188,7 +189,10 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
485 /* Avoid dealing with directories and block devices */
486 if (__builtin_expect (fd, 0) < 0)
493 if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
494 goto close_unlock_return;
495 @@ -325,6 +329,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
496 /* Release the lock again. */
498 close_not_cancel_no_status (fd);
503 diff --git a/catgets/tst-catgets.c b/catgets/tst-catgets.c
504 index a0a4089..0886938 100644
505 --- a/catgets/tst-catgets.c
506 +++ b/catgets/tst-catgets.c
510 #include <nl_types.h>
514 +#include <sys/resource.h>
517 static const char *msgs[] =
518 @@ -12,6 +15,33 @@ static const char *msgs[] =
520 #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
523 +/* Test for unbounded alloca. */
531 + const int sz = 1024 * 1024;
533 + getrlimit (RLIMIT_STACK, &rl);
535 + setrlimit (RLIMIT_STACK, &rl);
537 + buf = malloc (sz + 1);
538 + memset (buf, 'A', sz);
540 + setenv ("NLSPATH", buf, 1);
542 + result = catopen (buf, NL_CAT_LOCALE);
543 + assert (result == (nl_catd) -1);
552 @@ -62,6 +92,7 @@ do_test (void)
556 + result += do_bz17905 ();
560 diff --git a/config.make.in b/config.make.in
561 index a9f5696..46cd9bb 100644
564 @@ -51,6 +51,7 @@ have-z-combreloc = @libc_cv_z_combreloc@
565 have-z-execstack = @libc_cv_z_execstack@
566 have-Bgroup = @libc_cv_Bgroup@
567 have-protected-data = @libc_cv_protected_data@
568 +have-glob-dat-reloc = @libc_cv_has_glob_dat@
570 old-glibc-headers = @old_glibc_headers@
571 unwind-find-fde = @libc_cv_gcc_unwind_find_fde@
572 diff --git a/configure b/configure
573 index 45cc7cb..4f87b31 100755
576 @@ -628,6 +628,7 @@ gnu89_inline
579 libc_cv_output_format
580 +libc_cv_has_glob_dat
584 @@ -6335,6 +6336,39 @@ $as_echo "$libc_cv_use_default_link" >&6; }
585 use_default_link=$libc_cv_use_default_link
588 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
589 +$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
590 +if ${libc_cv_has_glob_dat+:} false; then :
591 + $as_echo_n "(cached) " >&6
593 + cat > conftest.c <<EOF
595 +int foo (void) { return mumble; }
597 +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
598 + -fPIC -shared -o conftest.so conftest.c
599 + -nostdlib -nostartfiles
601 + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
602 + (eval $ac_try) 2>&5
604 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
605 + test $ac_status = 0; }; }
607 + if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
608 + libc_cv_has_glob_dat=yes
610 + libc_cv_has_glob_dat=no
613 + libc_cv_has_glob_dat=no
617 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_has_glob_dat" >&5
618 +$as_echo "$libc_cv_has_glob_dat" >&6; }
621 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
622 $as_echo_n "checking linker output format... " >&6; }
623 if ${libc_cv_output_format+:} false; then :
624 diff --git a/configure.ac b/configure.ac
625 index 7e9383a..8be612d 100644
628 @@ -1535,6 +1535,29 @@ $ac_try"
629 use_default_link=$libc_cv_use_default_link
632 +AC_CACHE_CHECK(for GLOB_DAT reloc,
633 + libc_cv_has_glob_dat, [dnl
634 +cat > conftest.c <<EOF
636 +int foo (void) { return mumble; }
638 +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
639 + -fPIC -shared -o conftest.so conftest.c
640 + -nostdlib -nostartfiles
641 + 1>&AS_MESSAGE_LOG_FD])
643 +dnl look for GLOB_DAT relocation.
644 + if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
645 + libc_cv_has_glob_dat=yes
647 + libc_cv_has_glob_dat=no
650 + libc_cv_has_glob_dat=no
653 +AC_SUBST(libc_cv_has_glob_dat)
655 AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
656 if libc_cv_output_format=`
657 ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
658 diff --git a/elf/Makefile b/elf/Makefile
659 index 4ceeaf8..a2c43bc 100644
662 @@ -148,7 +148,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
663 tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
665 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
666 - tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened
667 + tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
670 ifeq ($(build-hardcoded-path-in-tests),yes)
671 tests += tst-dlopen-aout
672 @@ -218,7 +219,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
674 tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
675 tst-array5dep tst-null-argv-lib \
676 - tst-tlsalign-lib tst-nodelete-opened-lib
677 + tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod
678 ifeq (yes,$(have-protected-data))
679 modules-names += tst-protected1moda tst-protected1modb
680 tests += tst-protected1a tst-protected1b
681 @@ -292,6 +293,13 @@ check-abi: $(objpfx)check-abi-ld.out
682 tests-special += $(objpfx)check-abi-ld.out
683 update-abi: update-abi-ld
685 +ifeq ($(have-glob-dat-reloc),yes)
686 +tests += tst-prelink
687 +ifeq ($(run-built-tests),yes)
688 +tests-special += $(objpfx)tst-prelink-cmp.out
694 ifeq (yes,$(build-shared))
695 @@ -594,6 +602,7 @@ tst-auditmod9b.so-no-z-defs = yes
696 tst-nodelete-uniquemod.so-no-z-defs = yes
697 tst-nodelete-rtldmod.so-no-z-defs = yes
698 tst-nodelete-zmod.so-no-z-defs = yes
699 +tst-nodelete2mod.so-no-z-defs = yes
701 ifeq ($(build-shared),yes)
702 # Build all the modules even when not actually running test programs.
703 @@ -1164,6 +1173,11 @@ $(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
704 LDFLAGS-tst-nodelete = -rdynamic
705 LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
707 +$(objpfx)tst-nodelete2: $(libdl)
708 +$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
710 +LDFLAGS-tst-nodelete2 = -rdynamic
712 $(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
715 @@ -1205,3 +1219,13 @@ $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
716 $(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
717 cmp $< /dev/null > $@; \
720 +tst-prelink-ENV = LD_TRACE_PRELINKING=1
722 +$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
723 + grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
725 +$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
726 + $(objpfx)tst-prelink-conflict.out
729 diff --git a/elf/dl-close.c b/elf/dl-close.c
730 index 9105277..c897247 100644
733 @@ -144,6 +144,14 @@ _dl_close_worker (struct link_map *map, bool force)
735 struct link_map *maps[nloaded];
737 + /* Clear DF_1_NODELETE to force object deletion. We don't need to touch
738 + l_tls_dtor_count because forced object deletion only happens when an
739 + error occurs during object load. Destructor registration for TLS
740 + non-POD objects should not have happened till then for this
743 + map->l_flags_1 &= ~DF_1_NODELETE;
745 /* Run over the list and assign indexes to the link maps and enter
746 them into the MAPS array. */
748 @@ -153,13 +161,6 @@ _dl_close_worker (struct link_map *map, bool force)
752 - /* Clear DF_1_NODELETE to force object deletion. We don't need to touch
753 - l_tls_dtor_count because forced object deletion only happens when an
754 - error occurs during object load. Destructor registration for TLS
755 - non-POD objects should not have happened till then for this
758 - l->l_flags_1 &= ~DF_1_NODELETE;
760 assert (idx == nloaded);
762 diff --git a/elf/dl-load.c b/elf/dl-load.c
763 index 0c052e4..7e6f4c5 100644
767 #include <dl-map-segments.h>
768 #include <dl-unmap-segments.h>
769 #include <dl-machine-reject-phdr.h>
770 +#include <dl-sysdep-open.h>
774 @@ -1471,9 +1472,13 @@ print_search_path (struct r_search_path_elem **list,
775 ignore only ELF files for other architectures. Non-ELF files and
776 ELF files with different header information cause fatal errors since
777 this could mean there is something wrong in the installation and the
778 - user might want to know about this. */
779 + user might want to know about this.
781 + If FD is not -1, then the file is already open and FD refers to it.
782 + In that case, FD is consumed for both successful and error returns. */
784 -open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
785 +open_verify (const char *name, int fd,
786 + struct filebuf *fbp, struct link_map *loader,
787 int whatcode, int mode, bool *found_other_class, bool free_name)
789 /* This is the expected ELF header. */
790 @@ -1514,6 +1519,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
791 if (__glibc_unlikely (GLRO(dl_naudit) > 0) && whatcode != 0
792 && loader->l_auditing == 0)
794 + const char *original_name = name;
795 struct audit_ifaces *afct = GLRO(dl_audit);
796 for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
798 @@ -1528,11 +1534,21 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
803 + if (fd != -1 && name != original_name && strcmp (name, original_name))
805 + /* An audit library changed what we're supposed to open,
806 + so FD no longer matches it. */
813 - /* Open the file. We always open files read-only. */
814 - int fd = __open (name, O_RDONLY | O_CLOEXEC);
816 + /* Open the file. We always open files read-only. */
817 + fd = __open (name, O_RDONLY | O_CLOEXEC);
822 @@ -1801,7 +1817,7 @@ open_path (const char *name, size_t namelen, int mode,
823 if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
824 _dl_debug_printf (" trying file=%s\n", buf);
826 - fd = open_verify (buf, fbp, loader, whatcode, mode,
827 + fd = open_verify (buf, -1, fbp, loader, whatcode, mode,
828 found_other_class, false);
829 if (this_dir->status[cnt] == unknown)
831 @@ -2041,6 +2057,20 @@ _dl_map_object (struct link_map *loader, const char *name,
832 &loader->l_runpath_dirs, &realname, &fb, loader,
833 LA_SER_RUNPATH, &found_other_class);
837 + realname = _dl_sysdep_open_object (name, namelen, &fd);
838 + if (realname != NULL)
840 + fd = open_verify (realname, fd,
841 + &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
842 + LA_SER_CONFIG, mode, &found_other_class,
851 && (__glibc_likely ((mode & __RTLD_SECURE) == 0)
852 @@ -2086,7 +2116,7 @@ _dl_map_object (struct link_map *loader, const char *name,
856 - fd = open_verify (cached,
857 + fd = open_verify (cached, -1,
858 &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
859 LA_SER_CONFIG, mode, &found_other_class,
861 @@ -2121,7 +2151,7 @@ _dl_map_object (struct link_map *loader, const char *name,
865 - fd = open_verify (realname, &fb,
866 + fd = open_verify (realname, -1, &fb,
867 loader ?: GL(dl_ns)[nsid]._ns_loaded, 0, mode,
868 &found_other_class, true);
869 if (__glibc_unlikely (fd == -1))
870 diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
871 index 11cb44b..acf5280 100644
872 --- a/elf/dl-lookup.c
873 +++ b/elf/dl-lookup.c
874 @@ -1016,6 +1016,18 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
876 if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
878 +/* ELF_RTYPE_CLASS_XXX must match RTYPE_CLASS_XXX used by prelink with
879 + LD_TRACE_PRELINKING. */
880 +#define RTYPE_CLASS_VALID 8
881 +#define RTYPE_CLASS_PLT (8|1)
882 +#define RTYPE_CLASS_COPY (8|2)
883 +#define RTYPE_CLASS_TLS (8|4)
884 +#if ELF_RTYPE_CLASS_PLT != 0 && ELF_RTYPE_CLASS_PLT != 1
885 +# error ELF_RTYPE_CLASS_PLT must be 0 or 1!
887 +#if ELF_RTYPE_CLASS_COPY != 0 && ELF_RTYPE_CLASS_COPY != 2
888 +# error ELF_RTYPE_CLASS_COPY must be 0 or 2!
891 struct sym_val val = { NULL, NULL };
893 @@ -1071,12 +1083,17 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
897 + /* Keep only ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY
898 + bits since since prelink only uses them. */
899 + type_class &= ELF_RTYPE_CLASS_PLT | ELF_RTYPE_CLASS_COPY;
900 if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
903 + /* Clear the RTYPE_CLASS_VALID bit in RTYPE_CLASS_TLS. */
904 + type_class = RTYPE_CLASS_TLS & ~RTYPE_CLASS_VALID;
905 else if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
908 + /* Set the RTYPE_CLASS_VALID bit. */
909 + type_class |= RTYPE_CLASS_VALID;
913 diff --git a/elf/dl-sysdep-open.h b/elf/dl-sysdep-open.h
915 index 0000000..a63d9f5
917 +++ b/elf/dl-sysdep-open.h
919 +/* System-specific call to open a shared object by name. Stub version.
920 + Copyright (C) 2015 Free Software Foundation, Inc.
921 + This file is part of the GNU C Library.
923 + The GNU C Library is free software; you can redistribute it and/or
924 + modify it under the terms of the GNU Lesser General Public
925 + License as published by the Free Software Foundation; either
926 + version 2.1 of the License, or (at your option) any later version.
928 + The GNU C Library is distributed in the hope that it will be useful,
929 + but WITHOUT ANY WARRANTY; without even the implied warranty of
930 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
931 + Lesser General Public License for more details.
933 + You should have received a copy of the GNU Lesser General Public
934 + License along with the GNU C Library; if not, see
935 + <http://www.gnu.org/licenses/>. */
937 +#ifndef _DL_SYSDEP_OPEN_H
938 +#define _DL_SYSDEP_OPEN_H 1
943 +/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
944 + or a dlopen call's argument or suchlike. NAMELEN is (strlen (NAME) + 1).
946 + Find NAME in an OS-dependent fashion, and return its "real" name.
947 + Optionally fill in *FD with a file descriptor open on that file (or
948 + else leave its initial value of -1). The return value is a new
949 + malloc'd string, which will be free'd by the caller. If NAME is
950 + resolved to an actual file that can be opened, then the return
951 + value should name that file (and if *FD was not set, then a normal
952 + __open call on that string will be made). If *FD was set by some
953 + other means than a normal open and there is no "real" name to use,
954 + then __strdup (NAME) is fine (modulo error checking). */
956 +static inline char *
957 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
959 + assert (*fd == -1);
963 +#endif /* dl-sysdep-open.h */
964 diff --git a/elf/rtld.c b/elf/rtld.c
965 index 69873c2..07e741c 100644
968 @@ -162,7 +162,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
969 ._dl_hwcap_mask = HWCAP_IMPORTANT,
971 ._dl_fpu_control = _FPU_DEFAULT,
972 - ._dl_pointer_guard = 1,
973 ._dl_pagesize = EXEC_PAGESIZE,
974 ._dl_inhibit_cache = 0,
976 @@ -709,15 +708,12 @@ security_init (void)
979 /* Set up the pointer guard as well, if necessary. */
980 - if (GLRO(dl_pointer_guard))
982 - uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
984 + uintptr_t pointer_chk_guard
985 + = _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
986 #ifdef THREAD_SET_POINTER_GUARD
987 - THREAD_SET_POINTER_GUARD (pointer_chk_guard);
988 + THREAD_SET_POINTER_GUARD (pointer_chk_guard);
990 - __pointer_chk_guard_local = pointer_chk_guard;
992 + __pointer_chk_guard_local = pointer_chk_guard;
994 /* We do not need the _dl_random value anymore. The less
995 information we leave behind, the better, so clear the
996 @@ -2471,9 +2467,6 @@ process_envvars (enum mode *modep)
997 GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
1001 - if (memcmp (envline, "POINTER_GUARD", 13) == 0)
1002 - GLRO(dl_pointer_guard) = envline[14] != '0';
1006 diff --git a/elf/tst-nodelete2.c b/elf/tst-nodelete2.c
1007 new file mode 100644
1008 index 0000000..388e8af
1010 +++ b/elf/tst-nodelete2.c
1012 +#include "../dlfcn/dlfcn.h"
1014 +#include <stdlib.h>
1015 +#include <gnu/lib-names.h>
1022 + printf ("\nOpening pthread library.\n");
1023 + void *pthread = dlopen (LIBPTHREAD_SO, RTLD_LAZY);
1025 + /* This is a test for correct DF_1_NODELETE clearing when dlopen failure
1026 + happens. We should clear DF_1_NODELETE for failed library only, because
1027 + doing this for others (e.g. libpthread) might cause them to be unloaded,
1028 + that may lead to some global references (e.g. __rtld_lock_unlock) to be
1029 + broken. The dlopen should fail because of undefined symbols in shared
1030 + library, that cause DF_1_NODELETE to be cleared. For libpthread, this
1031 + flag should be set, because if not, SIGSEGV will happen in dlclose. */
1032 + if (dlopen ("tst-nodelete2mod.so", RTLD_NOW) != NULL)
1034 + printf ("Unique symbols test failed\n");
1039 + dlclose (pthread);
1042 + printf ("SUCCESS\n");
1047 +#define TEST_FUNCTION do_test ()
1048 +#include "../test-skeleton.c"
1049 diff --git a/elf/tst-nodelete2mod.c b/elf/tst-nodelete2mod.c
1050 new file mode 100644
1051 index 0000000..e88c756
1053 +++ b/elf/tst-nodelete2mod.c
1055 +/* Undefined symbol. */
1056 +extern int not_exist (void);
1060 + return not_exist ();
1062 diff --git a/elf/tst-prelink.c b/elf/tst-prelink.c
1063 new file mode 100644
1064 index 0000000..ab61c4e
1066 +++ b/elf/tst-prelink.c
1068 +/* Test the output from the environment variable, LD_TRACE_PRELINKING,
1070 + Copyright (C) 2015 Free Software Foundation, Inc.
1071 + This file is part of the GNU C Library.
1073 + The GNU C Library is free software; you can redistribute it and/or
1074 + modify it under the terms of the GNU Lesser General Public
1075 + License as published by the Free Software Foundation; either
1076 + version 2.1 of the License, or (at your option) any later version.
1078 + The GNU C Library is distributed in the hope that it will be useful,
1079 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1080 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1081 + Lesser General Public License for more details.
1083 + You should have received a copy of the GNU Lesser General Public
1084 + License along with the GNU C Library; if not, see
1085 + <http://www.gnu.org/licenses/>. */
1092 + fprintf (stdout, "hello\n");
1096 +#define TEST_FUNCTION do_test ()
1097 +#include "../test-skeleton.c"
1098 diff --git a/elf/tst-prelink.exp b/elf/tst-prelink.exp
1099 new file mode 100644
1100 index 0000000..b35b4c9
1102 +++ b/elf/tst-prelink.exp
1105 diff --git a/elf/tst-znodelete-zlib.cc b/elf/tst-znodelete-zlib.cc
1106 deleted file mode 100644
1107 index 1e8f368..0000000
1108 --- a/elf/tst-znodelete-zlib.cc
1111 -extern int not_exist (void);
1115 - return not_exist ();
1117 diff --git a/io/test-lfs.c b/io/test-lfs.c
1118 index 539c2a2..b6ebae4 100644
1121 @@ -144,7 +144,7 @@ test_ftello (void)
1123 do_test (int argc, char *argv[])
1127 struct stat64 statbuf;
1129 ret = lseek64 (fd, TWO_GB+100, SEEK_SET);
1130 @@ -195,6 +195,25 @@ do_test (int argc, char *argv[])
1131 error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
1132 (long long int) statbuf.st_size, (TWO_GB + 100 + 5));
1134 + fd2 = openat64 (AT_FDCWD, name, O_RDWR);
1137 + if (errno == ENOSYS)
1139 + /* Silently ignore this test. */
1140 + error (0, 0, "openat64 is not supported");
1143 + error (EXIT_FAILURE, errno, "openat64 failed to open big file");
1147 + ret = close (fd2);
1150 + error (EXIT_FAILURE, errno, "error closing file");
1156 diff --git a/locale/C-collate.c b/locale/C-collate.c
1157 index d7f3c55..06dfdfa 100644
1158 --- a/locale/C-collate.c
1159 +++ b/locale/C-collate.c
1160 @@ -144,8 +144,6 @@ const struct __locale_data _nl_C_LC_COLLATE attribute_hidden =
1161 /* _NL_COLLATE_COLLSEQWC */
1162 { .string = (const char *) collseqwc },
1163 /* _NL_COLLATE_CODESET */
1164 - { .string = _nl_C_codeset },
1165 - /* _NL_COLLATE_ENCODING_TYPE */
1166 - { .word = __cet_8bit }
1167 + { .string = _nl_C_codeset }
1170 diff --git a/locale/categories.def b/locale/categories.def
1171 index 045489d..a8dda53 100644
1172 --- a/locale/categories.def
1173 +++ b/locale/categories.def
1174 @@ -58,7 +58,6 @@ DEFINE_CATEGORY
1175 DEFINE_ELEMENT (_NL_COLLATE_COLLSEQMB, "collate-collseqmb", std, wstring)
1176 DEFINE_ELEMENT (_NL_COLLATE_COLLSEQWC, "collate-collseqwc", std, wstring)
1177 DEFINE_ELEMENT (_NL_COLLATE_CODESET, "collate-codeset", std, string)
1178 - DEFINE_ELEMENT (_NL_COLLATE_ENCODING_TYPE, "collate-encoding-type", std, word)
1182 diff --git a/locale/langinfo.h b/locale/langinfo.h
1183 index ffc5c7f..a565d9d 100644
1184 --- a/locale/langinfo.h
1185 +++ b/locale/langinfo.h
1186 @@ -255,7 +255,6 @@ enum
1187 _NL_COLLATE_COLLSEQMB,
1188 _NL_COLLATE_COLLSEQWC,
1189 _NL_COLLATE_CODESET,
1190 - _NL_COLLATE_ENCODING_TYPE,
1193 /* LC_CTYPE category: character classification.
1194 diff --git a/locale/loadlocale.c b/locale/loadlocale.c
1195 index fdba6e9..dcbb833 100644
1196 --- a/locale/loadlocale.c
1197 +++ b/locale/loadlocale.c
1198 @@ -121,9 +121,10 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize)
1201 #define CATTEST(cat) \
1203 - assert (cnt < (sizeof (_nl_value_type_LC_##cat) \
1204 - / sizeof (_nl_value_type_LC_##cat[0]))); \
1206 + if (cnt >= (sizeof (_nl_value_type_LC_##cat) \
1207 + / sizeof (_nl_value_type_LC_##cat[0]))) \
1212 diff --git a/locale/localeinfo.h b/locale/localeinfo.h
1213 index bdab9fe..1d2ee00 100644
1214 --- a/locale/localeinfo.h
1215 +++ b/locale/localeinfo.h
1216 @@ -110,14 +110,6 @@ enum coll_sort_rule
1220 -/* Collation encoding type. */
1221 -enum collation_encoding_type
1228 /* We can map the types of the entries into a few categories. */
1231 diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
1232 index a39a94f..dc0fe30 100644
1233 --- a/locale/programs/ld-collate.c
1234 +++ b/locale/programs/ld-collate.c
1236 #include "linereader.h"
1237 #include "locfile.h"
1238 #include "elem-hash.h"
1239 -#include "../localeinfo.h"
1241 /* Uncomment the following line in the production version. */
1242 /* #define NDEBUG 1 */
1243 @@ -2131,8 +2130,6 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
1244 /* The words have to be handled specially. */
1245 if (idx == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
1246 add_locale_uint32 (&file, 0);
1247 - else if (idx == _NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE))
1248 - add_locale_uint32 (&file, __cet_other);
1250 add_locale_empty (&file);
1252 @@ -2496,12 +2493,6 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
1253 add_locale_raw_data (&file, collate->mbseqorder, 256);
1254 add_locale_collseq_table (&file, &collate->wcseqorder);
1255 add_locale_string (&file, charmap->code_set_name);
1256 - if (strcmp (charmap->code_set_name, "UTF-8") == 0)
1257 - add_locale_uint32 (&file, __cet_utf8);
1258 - else if (charmap->mb_cur_max == 1)
1259 - add_locale_uint32 (&file, __cet_8bit);
1261 - add_locale_uint32 (&file, __cet_other);
1262 write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", &file);
1264 obstack_free (&weightpool, NULL);
1265 diff --git a/math/Makefile b/math/Makefile
1266 index 6388bae..2c9d72d 100644
1269 @@ -98,7 +98,7 @@ $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
1270 (echo '/* GNU ld script'; echo '*/';\
1272 echo 'GROUP ( $(slibdir)/libm.so$(libm.so-version) ' \
1273 - 'AS_NEEDED ( $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
1274 + 'AS_NEEDED ( $(libdir)/libmvec_nonshared.a $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
1278 diff --git a/misc/Makefile b/misc/Makefile
1279 index aecb0da..12055ce 100644
1282 @@ -76,7 +76,8 @@ install-lib := libg.a
1283 gpl2lgpl := error.c error.h
1285 tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
1286 - tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1
1287 + tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
1288 + tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240
1289 ifeq ($(run-built-tests),yes)
1290 tests-special += $(objpfx)tst-error1-mem.out
1292 diff --git a/misc/bug18240.c b/misc/bug18240.c
1293 new file mode 100644
1294 index 0000000..4b26865
1296 +++ b/misc/bug18240.c
1298 +/* Test integer wraparound in hcreate.
1299 + Copyright (C) 2016 Free Software Foundation, Inc.
1300 + This file is part of the GNU C Library.
1302 + The GNU C Library is free software; you can redistribute it and/or
1303 + modify it under the terms of the GNU Lesser General Public
1304 + License as published by the Free Software Foundation; either
1305 + version 2.1 of the License, or (at your option) any later version.
1307 + The GNU C Library is distributed in the hope that it will be useful,
1308 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1309 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1310 + Lesser General Public License for more details.
1312 + You should have received a copy of the GNU Lesser General Public
1313 + License along with the GNU C Library; if not, see
1314 + <http://www.gnu.org/licenses/>. */
1317 +#include <limits.h>
1318 +#include <search.h>
1319 +#include <stdbool.h>
1321 +#include <stdlib.h>
1324 +test_size (size_t size)
1326 + int res = hcreate (size);
1329 + if (errno == ENOMEM)
1331 + printf ("error: hcreate (%zu): %m\n", size);
1335 + for (int i = 0; i < 100; ++i)
1337 + if (asprintf (keys + i, "%d", i) < 0)
1339 + printf ("error: asprintf: %m\n");
1342 + ENTRY e = { keys[i], (char *) "value" };
1343 + if (hsearch (e, ENTER) == NULL)
1345 + printf ("error: hsearch (\"%s\"): %m\n", keys[i]);
1351 + for (int i = 0; i < 100; ++i)
1361 + test_size (INT_MAX - 2);
1362 + test_size (INT_MAX - 1);
1363 + test_size (INT_MAX);
1364 + test_size (((unsigned) INT_MAX) + 1);
1365 + test_size (UINT_MAX - 2);
1366 + test_size (UINT_MAX - 1);
1367 + test_size (UINT_MAX);
1371 +#define TEST_FUNCTION do_test ()
1372 +#include "../test-skeleton.c"
1373 diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
1374 index 9f55e84..661f0f6 100644
1375 --- a/misc/hsearch_r.c
1376 +++ b/misc/hsearch_r.c
1382 +#include <stdint.h>
1385 /* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
1386 @@ -46,15 +46,12 @@ static int
1387 isprime (unsigned int number)
1389 /* no even number will be passed */
1390 - unsigned int div = 3;
1392 - while (div * div < number && number % div != 0)
1395 - return number % div != 0;
1396 + for (unsigned int div = 3; div <= number / div; div += 2)
1397 + if (number % div == 0)
1403 /* Before using the hash table we must allocate memory for it.
1404 Test for an existing table are done. We allocate one element
1405 more as the found prime number says. This is done for more effective
1406 @@ -81,10 +78,19 @@ __hcreate_r (nel, htab)
1407 use will not work. */
1410 - /* Change nel to the first prime number not smaller as nel. */
1411 - nel |= 1; /* make odd */
1412 - while (!isprime (nel))
1415 + /* Change nel to the first prime number in the range [nel, UINT_MAX - 2],
1416 + The '- 2' means 'nel += 2' cannot overflow. */
1417 + for (nel |= 1; ; nel += 2)
1419 + if (UINT_MAX - 2 < nel)
1421 + __set_errno (ENOMEM);
1424 + if (isprime (nel))
1430 diff --git a/misc/mntent_r.c b/misc/mntent_r.c
1431 index 6159873..4f26998 100644
1432 --- a/misc/mntent_r.c
1433 +++ b/misc/mntent_r.c
1434 @@ -136,7 +136,9 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
1435 end_ptr = strchr (buffer, '\n');
1436 if (end_ptr != NULL) /* chop newline */
1438 - while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
1439 + /* Do not walk past the start of buffer if it's all whitespace. */
1440 + while (end_ptr != buffer
1441 + && (end_ptr[-1] == ' ' || end_ptr[-1] == '\t'))
1445 diff --git a/misc/regexp.h b/misc/regexp.h
1446 index 3460989..42394f7 100644
1453 -/* The contents of this header file were standardized in the
1454 - Single Unix Specification, Version 2 (1997) but marked as
1455 - LEGACY; new applications were already being encouraged to
1456 - use <regex.h> instead. POSIX.1-2001 removed this header.
1457 +/* The contents of this header file were originally standardized in
1458 + the Single Unix Specification, Issue 3 (1992). In Issue 4 (1994)
1459 + the header was marked as TO BE WITHDRAWN, and new applications
1460 + were encouraged to use <regex.h> instead. It was officially
1461 + withdrawn from the standard in Issue 6 (aka POSIX.1-2001).
1463 This header is provided only for backward compatibility.
1464 It will be removed in the next release of the GNU C Library.
1465 diff --git a/misc/sys/param.h b/misc/sys/param.h
1466 index 62b7ed2..1908b93 100644
1467 --- a/misc/sys/param.h
1468 +++ b/misc/sys/param.h
1470 #if !defined NOFILE && defined OPEN_MAX
1471 # define NOFILE OPEN_MAX
1473 +#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
1474 +# define MAXHOSTNAMELEN HOST_NAME_MAX
1478 # define NCARGS ARG_MAX
1479 diff --git a/misc/tst-mntent-blank-corrupt.c b/misc/tst-mntent-blank-corrupt.c
1480 new file mode 100644
1481 index 0000000..92266a3
1483 +++ b/misc/tst-mntent-blank-corrupt.c
1485 +/* Make sure blank lines does not cause memory corruption BZ #18887.
1487 + Copyright (C) 2009-2015 Free Software Foundation, Inc.
1488 + This file is part of the GNU C Library.
1490 + The GNU C Library is free software; you can redistribute it and/or
1491 + modify it under the terms of the GNU Lesser General Public
1492 + License as published by the Free Software Foundation; either
1493 + version 2.1 of the License, or (at your option) any later version.
1495 + The GNU C Library is distributed in the hope that it will be useful,
1496 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1497 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1498 + Lesser General Public License for more details.
1500 + You should have received a copy of the GNU Lesser General Public
1501 + License along with the GNU C Library; if not, see
1502 + <http://www.gnu.org/licenses/>. */
1504 +#include <mntent.h>
1506 +#include <string.h>
1508 +/* Make sure blank lines don't trigger memory corruption. This doesn't happen
1509 + for all targets though, so it's a best effort test BZ #18887. */
1516 + fputs ("\n \n/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1519 + /* The corruption happens here ... */
1521 + /* ... but trigers here. */
1524 + /* If the test failed, we would crash, and not hit this point. */
1528 +#define TEST_FUNCTION do_test ()
1529 +#include "../test-skeleton.c"
1530 diff --git a/misc/tst-mntent-blank-passno.c b/misc/tst-mntent-blank-passno.c
1531 new file mode 100644
1532 index 0000000..fc04291
1534 +++ b/misc/tst-mntent-blank-passno.c
1536 +/* Make sure trailing whitespace is handled properly BZ #17273.
1538 + Copyright (C) 2009-2015 Free Software Foundation, Inc.
1539 + This file is part of the GNU C Library.
1541 + The GNU C Library is free software; you can redistribute it and/or
1542 + modify it under the terms of the GNU Lesser General Public
1543 + License as published by the Free Software Foundation; either
1544 + version 2.1 of the License, or (at your option) any later version.
1546 + The GNU C Library is distributed in the hope that it will be useful,
1547 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1548 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1549 + Lesser General Public License for more details.
1551 + You should have received a copy of the GNU Lesser General Public
1552 + License along with the GNU C Library; if not, see
1553 + <http://www.gnu.org/licenses/>. */
1555 +#include <mntent.h>
1557 +#include <string.h>
1559 +/* Check entries to make sure trailing whitespace is ignored and we return the
1560 + correct passno value BZ #17273. */
1566 + struct mntent *mnt;
1569 + fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1572 + mnt = getmntent (fp);
1573 + if (strcmp (mnt->mnt_fsname, "/foo dir") != 0
1574 + || strcmp (mnt->mnt_dir, "/bar dir") != 0
1575 + || strcmp (mnt->mnt_type, "auto") != 0
1576 + || strcmp (mnt->mnt_opts, "bind") != 0
1577 + || mnt->mnt_freq != 0
1578 + || mnt->mnt_passno != 0)
1580 + puts ("Error while reading entry with trailing whitespaces");
1587 +#define TEST_FUNCTION do_test ()
1588 +#include "../test-skeleton.c"
1589 diff --git a/misc/tst-mntent.c b/misc/tst-mntent.c
1590 index 876c89f..820b354 100644
1591 --- a/misc/tst-mntent.c
1592 +++ b/misc/tst-mntent.c
1593 @@ -73,26 +73,6 @@ main (int argc, char *argv[])
1594 puts ("Error while reading written entry back in");
1598 - /* Part III: Entry with whitespaces at the end of a line. */
1601 - fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1605 - mnt = getmntent (fp);
1607 - if (strcmp (mnt->mnt_fsname, "/foo dir") != 0
1608 - || strcmp (mnt->mnt_dir, "/bar dir") != 0
1609 - || strcmp (mnt->mnt_type, "auto") != 0
1610 - || strcmp (mnt->mnt_opts, "bind") != 0
1611 - || mnt->mnt_freq != 0
1612 - || mnt->mnt_passno != 0)
1614 - puts ("Error while reading entry with trailing whitespaces");
1620 diff --git a/scripts/test-installation.pl b/scripts/test-installation.pl
1621 index cac1562..79b2b3e 100755
1622 --- a/scripts/test-installation.pl
1623 +++ b/scripts/test-installation.pl
1624 @@ -80,16 +80,25 @@ arglist: while (@ARGV) {
1625 # We expect none or one argument.
1627 $soversions="soversions.mk";
1628 + $config="config.make";
1629 } elsif ($#ARGV == 0) {
1631 $soversions = "$ARGV[0]/soversions.mk";
1632 + $config = "$ARGV[0]/config.make";
1634 - $soversions = $ARGV[0];
1635 + $soversions = $dir = $ARGV[0];
1636 + $dir =~ s!/?[^/]*/*$!!;
1637 + $config = $dir . "/config.make";
1640 die "Wrong number of arguments.";
1643 +if (system ("grep -q \"build-mathvec = yes\" $config") == 0) {
1644 + $build_mathvec = 1;
1646 + $build_mathvec = 0;
1649 # Read names and versions of all shared libraries that are part of
1651 @@ -111,6 +120,8 @@ while (<SOVERSIONS>) {
1652 # - libthread_db since it contains unresolved references
1653 # - it's just a test NSS module
1654 # - We don't provide the libgcc so we don't test it
1655 + # - libmvec if it wasn't built
1656 + next if ($build_mathvec == 0 && $name eq "mvec");
1657 if ($name ne "nss_ldap" && $name ne "db1"
1658 && !($name =~/^nss1_/) && $name ne "thread_db"
1659 && $name ne "nss_test1" && $name ne "libgcc_s") {
1660 diff --git a/stdlib/cxa_thread_atexit_impl.c b/stdlib/cxa_thread_atexit_impl.c
1661 index 2d5d56a..5717f09 100644
1662 --- a/stdlib/cxa_thread_atexit_impl.c
1663 +++ b/stdlib/cxa_thread_atexit_impl.c
1664 @@ -98,6 +98,10 @@ static __thread struct link_map *lm_cache;
1666 __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
1669 + PTR_MANGLE (func);
1673 struct dtor_list *new = calloc (1, sizeof (struct dtor_list));
1675 @@ -142,9 +146,13 @@ __call_tls_dtors (void)
1676 while (tls_dtor_list)
1678 struct dtor_list *cur = tls_dtor_list;
1679 + dtor_func func = cur->func;
1680 +#ifdef PTR_DEMANGLE
1681 + PTR_DEMANGLE (func);
1684 tls_dtor_list = tls_dtor_list->next;
1685 - cur->func (cur->obj);
1688 /* Ensure that the MAP dereference happens before
1689 l_tls_dtor_count decrement. That way, we protect this access from a
1690 diff --git a/string/Makefile b/string/Makefile
1691 index 8424a61..ebe9354 100644
1692 --- a/string/Makefile
1693 +++ b/string/Makefile
1694 @@ -54,7 +54,7 @@ tests := tester inl-tester noinl-tester testcopy test-ffs \
1695 tst-strtok tst-strxfrm bug-strcoll1 tst-strfry \
1696 bug-strtok1 $(addprefix test-,$(strop-tests)) \
1697 bug-envz1 tst-strxfrm2 tst-endian tst-svc2 \
1699 + tst-strtok_r bug-strcoll2
1701 xtests = tst-strcoll-overflow
1703 @@ -75,4 +75,17 @@ ifeq ($(run-built-tests),yes)
1704 $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
1708 +LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
1709 + tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
1711 +include ../gen-locales.mk
1713 +$(objpfx)test-strcasecmp.out: $(gen-locales)
1714 +$(objpfx)test-strncasecmp.out: $(gen-locales)
1715 +$(objpfx)tst-strxfrm.out: $(gen-locales)
1716 +$(objpfx)tst-strxfrm2.out: $(gen-locales)
1717 +# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
1718 +$(objpfx)bug-strcoll2.out: $(gen-locales)
1721 diff --git a/string/bug-strcoll2.c b/string/bug-strcoll2.c
1722 new file mode 100644
1723 index 0000000..72a9ff2
1725 +++ b/string/bug-strcoll2.c
1727 +/* Bug 18589: sort-test.sh fails at random.
1728 + Copyright (C) 2015 Free Software Foundation, Inc.
1729 + This file is part of the GNU C Library.
1731 + The GNU C Library is free software; you can redistribute it and/or
1732 + modify it under the terms of the GNU Lesser General Public
1733 + License as published by the Free Software Foundation; either
1734 + version 2.1 of the License, or (at your option) any later version.
1736 + The GNU C Library is distributed in the hope that it will be useful,
1737 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1738 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1739 + Lesser General Public License for more details.
1741 + You should have received a copy of the GNU Lesser General Public
1742 + License along with the GNU C Library; if not, see
1743 + <http://www.gnu.org/licenses/>. */
1746 +#include <string.h>
1747 +#include <locale.h>
1749 +/* An incorrect strcoll optimization resulted in incorrect
1750 + results from strcoll for cs_CZ and da_DK. */
1755 + const char t1[] = "config";
1756 + const char t2[] = "choose";
1757 + if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
1759 + perror ("setlocale");
1762 + /* In Czech the digraph ch sorts after c, therefore we expect
1763 + config to sort before choose. */
1764 + int a = strcoll (t1, t2);
1765 + int b = strcoll (t2, t1);
1766 + printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a);
1767 + printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b);
1768 + if (a < 0 && b > 0)
1770 + puts ("PASS: config < choose");
1775 + puts ("FAIL: Wrong sorting in cs_CZ.UTF-8.");
1783 + const char t1[] = "AS";
1784 + const char t2[] = "AA";
1785 + if (setlocale (LC_ALL, "da_DK.ISO-8859-1") == NULL)
1787 + perror ("setlocale");
1790 + /* AA should be treated as the last letter of the Danish alphabet,
1791 + hence sorting after AS. */
1792 + int a = strcoll (t1, t2);
1793 + int b = strcoll (t2, t1);
1794 + printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a);
1795 + printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b);
1796 + if (a < 0 && b > 0)
1798 + puts ("PASS: AS < AA");
1803 + puts ("FAIL: Wrong sorting in da_DK.ISO-8859-1");
1812 + err |= test_cs_CZ ();
1813 + err |= test_da_DK ();
1817 +#define TEST_FUNCTION do_test ()
1818 +#include "../test-skeleton.c"
1819 diff --git a/string/strcoll_l.c b/string/strcoll_l.c
1820 index 8f1225f..35bc0e4 100644
1821 --- a/string/strcoll_l.c
1822 +++ b/string/strcoll_l.c
1824 # define STRING_TYPE char
1825 # define USTRING_TYPE unsigned char
1826 # define STRCOLL __strcoll_l
1827 -# define STRDIFF __strdiff
1828 # define STRCMP strcmp
1829 # define WEIGHT_H "../locale/weight.h"
1832 #include "../locale/localeinfo.h"
1835 -#define MASK_UTF8_7BIT (1 << 7)
1836 -#define MASK_UTF8_START (3 << 6)
1839 -STRDIFF (const STRING_TYPE *s, const STRING_TYPE *t)
1843 - for (n = 0; *s != '\0' && *s++ == *t++; ++n)
1849 /* Track status while looking for sequences in a string. */
1852 @@ -269,29 +254,9 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
1853 const USTRING_TYPE *extra;
1854 const int32_t *indirect;
1856 - /* In case there is no locale specific sort order (C / POSIX). */
1858 return STRCMP (s1, s2);
1860 - /* Fast forward to the position of the first difference. Needs to be
1861 - encoding aware as the byte-by-byte comparison can stop in the middle
1862 - of a char sequence for multibyte encodings like UTF-8. */
1863 - uint_fast32_t encoding =
1864 - current->values[_NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE)].word;
1865 - if (encoding != __cet_other)
1867 - size_t diff = STRDIFF (s1, s2);
1870 - if (encoding == __cet_utf8 && (*(s1 + diff) & MASK_UTF8_7BIT) != 0)
1873 - while (diff > 0 && (*(s1 + diff) & MASK_UTF8_START) != MASK_UTF8_START);
1879 /* Catch empty strings. */
1880 if (__glibc_unlikely (*s1 == '\0') || __glibc_unlikely (*s2 == '\0'))
1881 return (*s1 != '\0') - (*s2 != '\0');
1882 @@ -358,8 +323,7 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
1883 byte-level comparison to ensure that we don't waste time
1884 going through multiple passes for totally equal strings
1885 before proceeding to subsequent passes. */
1886 - if (pass == 0 && encoding == __cet_other &&
1887 - STRCMP (s1, s2) == 0)
1888 + if (pass == 0 && STRCMP (s1, s2) == 0)
1892 diff --git a/string/tst-strxfrm2.c b/string/tst-strxfrm2.c
1893 index d5a1115..bea5aa2 100644
1894 --- a/string/tst-strxfrm2.c
1895 +++ b/string/tst-strxfrm2.c
1900 + static const char test_locale[] = "de_DE.UTF-8";
1905 @@ -38,9 +40,9 @@ do_test (void)
1909 - if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
1910 + if (setlocale (LC_ALL, test_locale) == NULL)
1912 - puts ("setlocale failed");
1913 + printf ("cannot set locale \"%s\"\n", test_locale);
1917 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
1918 index 7a0fe8d..78e3a97 100644
1919 --- a/sysdeps/generic/ldsodefs.h
1920 +++ b/sysdeps/generic/ldsodefs.h
1921 @@ -592,9 +592,6 @@ struct rtld_global_ro
1922 /* List of auditing interfaces. */
1923 struct audit_ifaces *_dl_audit;
1924 unsigned int _dl_naudit;
1926 - /* 0 if internal pointer values should not be guarded, 1 if they should. */
1927 - EXTERN int _dl_pointer_guard;
1929 # define __rtld_global_attribute__
1931 diff --git a/sysdeps/hppa/dl-symaddr.c b/sysdeps/hppa/dl-symaddr.c
1932 index b707c19..89d8baf 100644
1933 --- a/sysdeps/hppa/dl-symaddr.c
1934 +++ b/sysdeps/hppa/dl-symaddr.c
1935 @@ -33,3 +33,4 @@ _dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref)
1937 return (void *) value;
1939 +rtld_hidden_def (_dl_symbol_address)
1940 diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
1941 index 64d8c3e..cc4f243 100644
1942 --- a/sysdeps/hppa/start.S
1943 +++ b/sysdeps/hppa/start.S
1945 /* Have the linker create plabel words so we get PLABEL32
1946 relocs and not 21/14. The use of 21/14 relocs is only
1947 supported in the latest dynamic linker. */
1950 + .section .data.rel.ro,"aw",@progbits
1952 + .section .rodata,"a",@progbits
1958 .word P%__libc_csu_fini
1960 .word P%__libc_csu_init
1968 @@ -122,10 +130,14 @@ _start:
1969 /* void *stack_end (7th argument) */
1973 + addil LT'.Lp__global, %r19
1974 + ldw RT'.Lp__global(%r1), %dp
1977 ldil L%$global$, %dp
1978 ldo R%$global$(%dp), %dp
1981 bl __libc_start_main,%r2
1983 /* die horribly if it returned (it shouldn't) */
1984 diff --git a/sysdeps/nacl/Makefile b/sysdeps/nacl/Makefile
1985 index 6749a44..1748886 100644
1986 --- a/sysdeps/nacl/Makefile
1987 +++ b/sysdeps/nacl/Makefile
1988 @@ -132,4 +132,13 @@ ifeq ($(subdir),misc)
1989 # sysdeps/.../linux/ directories, but it's still a sysdeps decision to
1991 sysdep_headers += bits/mman-linux.h
1993 +# This defeats sysdeps/gnu/Makefile's addition of sys/mtio.h, which
1994 +# we do not want. This is a total kludge, but it seems no worse for
1995 +# now than making the sysdeps/gnu/Makefile code conditional on a
1996 +# variable we set here. If some sysdeps/.../Makefile that is later
1997 +# in the list than sysdeps/gnu needed to add to sysdep_headers, this
1998 +# would break it. But sysdeps/gnu is close to last in the list and
1999 +# this coming up seems unlikely.
2000 +override sysdep_headers := $(sysdep_headers)
2002 diff --git a/sysdeps/nacl/dl-map-segments.h b/sysdeps/nacl/dl-map-segments.h
2003 index f305da3..f2d5d84 100644
2004 --- a/sysdeps/nacl/dl-map-segments.h
2005 +++ b/sysdeps/nacl/dl-map-segments.h
2006 @@ -53,7 +53,7 @@ _dl_map_segments (struct link_map *l, int fd,
2007 const size_t maplength, bool has_holes,
2008 struct link_map *loader)
2010 - if (__builtin_expect (type, ET_DYN) == ET_DYN)
2011 + if (__glibc_likely (type == ET_DYN))
2013 /* This is a position-independent shared object. Let the system
2014 choose where to place it.
2015 @@ -165,6 +165,32 @@ _dl_map_segments (struct link_map *l, int fd,
2017 return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
2019 + if (__glibc_unlikely (type != ET_DYN))
2021 + /* A successful PROT_EXEC mmap would have implicitly
2022 + updated the bookkeeping so that a future
2023 + allocate_code_data call would know that this range
2024 + of the address space is already occupied. That
2025 + doesn't happen implicitly with dyncode_create, so
2026 + it's necessary to do an explicit call to update the
2028 + uintptr_t allocated_address;
2029 + error = __nacl_irt_code_data_alloc.allocate_code_data
2030 + (l->l_addr + c->mapstart, len, 0, 0, &allocated_address);
2031 + if (__glibc_unlikely (error))
2034 + return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
2036 + if (__glibc_unlikely
2037 + (allocated_address != l->l_addr + c->mapstart))
2039 + /* This is not a very helpful error for this case,
2040 + but there isn't really anything better to use. */
2042 + return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
2048 diff --git a/sysdeps/nacl/dl-sysdep-open.h b/sysdeps/nacl/dl-sysdep-open.h
2049 new file mode 100644
2050 index 0000000..38b0f9e
2052 +++ b/sysdeps/nacl/dl-sysdep-open.h
2054 +/* System-specific call to open a shared object by name. NaCl version.
2055 + Copyright (C) 2015 Free Software Foundation, Inc.
2056 + This file is part of the GNU C Library.
2058 + The GNU C Library is free software; you can redistribute it and/or
2059 + modify it under the terms of the GNU Lesser General Public
2060 + License as published by the Free Software Foundation; either
2061 + version 2.1 of the License, or (at your option) any later version.
2063 + The GNU C Library is distributed in the hope that it will be useful,
2064 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2065 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2066 + Lesser General Public License for more details.
2068 + You should have received a copy of the GNU Lesser General Public
2069 + License along with the GNU C Library; if not, see
2070 + <http://www.gnu.org/licenses/>. */
2072 +#ifndef _DL_SYSDEP_OPEN_H
2073 +#define _DL_SYSDEP_OPEN_H 1
2075 +#include <stddef.h>
2077 +/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
2078 + or a dlopen call's argument or suchlike. NAMELEN is (strlen (NAME) + 1).
2080 + Find NAME in an OS-dependent fashion, and return its "real" name.
2081 + Optionally fill in *FD with a file descriptor open on that file (or
2082 + else leave its initial value of -1). The return value is a new
2083 + malloc'd string, which will be free'd by the caller. If NAME is
2084 + resolved to an actual file that can be opened, then the return
2085 + value should name that file (and if *FD was not set, then a normal
2086 + __open call on that string will be made). If *FD was set by some
2087 + other means than a normal open and there is no "real" name to use,
2088 + then __strdup (NAME) is fine (modulo error checking). */
2090 +extern char *_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
2091 + internal_function attribute_hidden;
2093 +#endif /* dl-sysdep-open.h */
2094 diff --git a/sysdeps/nacl/dl-sysdep.c b/sysdeps/nacl/dl-sysdep.c
2095 index 3e902c2..3a04aa1 100644
2096 --- a/sysdeps/nacl/dl-sysdep.c
2097 +++ b/sysdeps/nacl/dl-sysdep.c
2098 @@ -87,3 +87,26 @@ _dl_start_user (void (*user_entry) (uint32_t info[]), uint32_t info[])
2101 #include <elf/dl-sysdep.c>
2103 +#include <dl-sysdep-open.h>
2104 +#include <nacl-interfaces.h>
2105 +#include <assert.h>
2106 +#include <string.h>
2107 +#include <unistd.h>
2111 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
2113 + int error = __nacl_irt_resource_open.open_resource (name, fd);
2116 + assert (*fd != -1);
2117 + char *realname = __strdup (name);
2118 + if (__glibc_unlikely (realname == NULL))
2125 diff --git a/sysdeps/nacl/nacl-interface-list.h b/sysdeps/nacl/nacl-interface-list.h
2126 index cb33751..c68faed 100644
2127 --- a/sysdeps/nacl/nacl-interface-list.h
2128 +++ b/sysdeps/nacl/nacl-interface-list.h
2129 @@ -28,7 +28,7 @@ NACL_MANDATORY_INTERFACE (rtld,
2130 NACL_IRT_FUTEX_v0_1, nacl_irt_futex)
2131 NACL_MANDATORY_INTERFACE (rtld,
2132 NACL_IRT_TLS_v0_1, nacl_irt_tls)
2133 -NACL_MANDATORY_INTERFACE (libc,
2134 +NACL_MANDATORY_INTERFACE (rtld,
2135 NACL_IRT_RESOURCE_OPEN_v0_1, nacl_irt_resource_open)
2136 NACL_MANDATORY_INTERFACE (rtld,
2137 NACL_IRT_CODE_DATA_ALLOC_v0_1,
2138 diff --git a/sysdeps/nacl/start.c b/sysdeps/nacl/start.c
2139 index a4b6dd3..8e8bc1a 100644
2140 --- a/sysdeps/nacl/start.c
2141 +++ b/sysdeps/nacl/start.c
2143 /* The application defines this, of course. */
2144 extern int main (int argc, char **argv, char **envp);
2146 +/* But maybe it defines this too, in which case it takes precedence. */
2147 +extern int __nacl_main (int argc, char **argv, char **envp)
2148 + __attribute__ ((weak));
2150 /* These are defined in libc. */
2151 extern int __libc_csu_init (int argc, char **argv, char **envp);
2152 extern void __libc_csu_fini (void);
2153 @@ -59,7 +63,7 @@ _start (uint32_t info[])
2155 /* The generic code actually assumes that envp follows argv. */
2157 - __libc_start_main (&main,
2158 + __libc_start_main (&__nacl_main ?: &main,
2159 nacl_startup_argc (info),
2160 nacl_startup_argv (info),
2161 nacl_startup_auxv (info),
2162 diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
2163 index 6509f5c..9edf056 100644
2164 --- a/sysdeps/posix/opendir.c
2165 +++ b/sysdeps/posix/opendir.c
2166 @@ -105,7 +105,7 @@ need_isdir_precheck (void)
2167 tryopen_o_directory ();
2169 /* We can skip the expensive `stat' call if O_DIRECTORY works. */
2170 - return o_directory_works > 0;
2171 + return o_directory_works < 0;
2175 diff --git a/sysdeps/powerpc/nptl/elide.h b/sysdeps/powerpc/nptl/elide.h
2176 index 389f5a5..2e1e443 100644
2177 --- a/sysdeps/powerpc/nptl/elide.h
2178 +++ b/sysdeps/powerpc/nptl/elide.h
2181 # include <elision-conf.h>
2183 -/* Returns true if the lock defined by is_lock_free as elided.
2184 - ADAPT_COUNT is a pointer to per-lock state variable. */
2186 +/* Get the new value of adapt_count according to the elision
2187 + configurations. Returns true if the system should retry again or false
2190 -__elide_lock (uint8_t *adapt_count, int is_lock_free)
2191 +__get_new_count (uint8_t *adapt_count, int attempt)
2193 - if (*adapt_count > 0)
2194 + /* A persistent failure indicates that a retry will probably
2195 + result in another failure. Use normal locking now and
2196 + for the next couple of calls. */
2197 + if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2200 + if (__elision_aconf.skip_lock_internal_abort > 0)
2201 + *adapt_count = __elision_aconf.skip_lock_internal_abort;
2205 - for (int i = __elision_aconf.try_tbegin; i > 0; i--)
2207 - if (__builtin_tbegin (0))
2211 - /* Lock was busy. */
2212 - __builtin_tabort (_ABORT_LOCK_BUSY);
2216 - /* A persistent failure indicates that a retry will probably
2217 - result in another failure. Use normal locking now and
2218 - for the next couple of calls. */
2219 - if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2221 - if (__elision_aconf.skip_lock_internal_abort > 0)
2222 - *adapt_count = __elision_aconf.skip_lock_internal_abort;
2225 - /* Same logic as above, but for a number of temporary failures in a
2227 - else if (__elision_aconf.skip_lock_out_of_tbegin_retries > 0
2228 - && __elision_aconf.try_tbegin > 0)
2229 - *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries;
2234 + /* Same logic as above, but for a number of temporary failures in a
2236 + else if (attempt <= 1 && __elision_aconf.skip_lock_out_of_tbegin_retries > 0
2237 + && __elision_aconf.try_tbegin > 0)
2238 + *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries;
2242 -# define ELIDE_LOCK(adapt_count, is_lock_free) \
2243 - __elide_lock (&(adapt_count), is_lock_free)
2247 -__elide_trylock (uint8_t *adapt_count, int is_lock_free, int write)
2249 - if (__elision_aconf.try_tbegin > 0)
2252 - __builtin_tabort (_ABORT_NESTED_TRYLOCK);
2253 - return __elide_lock (adapt_count, is_lock_free);
2257 +/* CONCURRENCY NOTES:
2259 + The evaluation of the macro expression is_lock_free encompasses one or
2260 + more loads from memory locations that are concurrently modified by other
2261 + threads. For lock elision to work, this evaluation and the rest of the
2262 + critical section protected by the lock must be atomic because an
2263 + execution with lock elision must be equivalent to an execution in which
2264 + the lock would have been actually acquired and released. Therefore, we
2265 + evaluate is_lock_free inside of the transaction that represents the
2266 + critical section for which we want to use lock elision, which ensures
2267 + the atomicity that we require. */
2269 +/* Returns 0 if the lock defined by is_lock_free was elided.
2270 + ADAPT_COUNT is a per-lock state variable. */
2271 +# define ELIDE_LOCK(adapt_count, is_lock_free) \
2274 + if (adapt_count > 0) \
2275 + (adapt_count)--; \
2277 + for (int i = __elision_aconf.try_tbegin; i > 0; i--) \
2279 + if (__builtin_tbegin (0)) \
2281 + if (is_lock_free) \
2286 + __builtin_tabort (_ABORT_LOCK_BUSY); \
2289 + if (!__get_new_count (&adapt_count,i)) \
2295 # define ELIDE_TRYLOCK(adapt_count, is_lock_free, write) \
2296 - __elide_trylock (&(adapt_count), is_lock_free, write)
2299 + if (__elision_aconf.try_tbegin > 0) \
2302 + __builtin_tabort (_ABORT_NESTED_TRYLOCK); \
2303 + ret = ELIDE_LOCK (adapt_count, is_lock_free); \
2310 diff --git a/sysdeps/sparc/sparc32/sem_open.c b/sysdeps/sparc/sparc32/sem_open.c
2311 index 16cb9ad..59df2d7 100644
2312 --- a/sysdeps/sparc/sparc32/sem_open.c
2313 +++ b/sysdeps/sparc/sparc32/sem_open.c
2315 #include <sys/mman.h>
2316 #include <sys/stat.h>
2317 #include "semaphoreP.h"
2318 +#include <futex-internal.h>
2319 #include <shm-directory.h>
2322 diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
2323 index 58c8b32..aa20e22 100644
2324 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
2325 +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
2326 @@ -1822,9 +1822,6 @@ GLIBC_2.17
2329 __cxa_thread_atexit_impl F
2335 _IO_adjust_wcolumn F
2336 @@ -2015,6 +2012,9 @@ GLIBC_2.2.4
2346 diff --git a/sysdeps/unix/sysv/linux/hppa/bits/atomic.h b/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
2347 index abde83e..6e73504 100644
2348 --- a/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
2349 +++ b/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
2350 @@ -56,42 +56,41 @@ typedef uintmax_t uatomic_max_t;
2352 #define _LWS_CAS "0"
2353 /* Note r31 is the link register. */
2354 -#define _LWS_CLOBBER "r1", "r26", "r25", "r24", "r23", "r22", "r21", "r20", "r28", "r31", "memory"
2355 +#define _LWS_CLOBBER "r1", "r23", "r22", "r20", "r31", "memory"
2356 /* String constant for -EAGAIN. */
2357 #define _ASM_EAGAIN "-11"
2358 /* String constant for -EDEADLOCK. */
2359 #define _ASM_EDEADLOCK "-45"
2361 #if __ASSUME_LWS_CAS
2362 -/* The only basic operation needed is compare and exchange. */
2363 +/* The only basic operation needed is compare and exchange. The mem
2364 + pointer must be word aligned. */
2365 # define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
2367 - volatile int lws_errno; \
2368 - __typeof__ (*mem) lws_ret; \
2370 + register long lws_errno asm("r21"); \
2371 + register unsigned long lws_ret asm("r28"); \
2372 + register unsigned long lws_mem asm("r26") = (unsigned long)(mem); \
2373 + register unsigned long lws_old asm("r25") = (unsigned long)(oldval);\
2374 + register unsigned long lws_new asm("r24") = (unsigned long)(newval);\
2375 + __asm__ __volatile__( \
2377 - "copy %2, %%r26 \n\t" \
2378 - "copy %3, %%r25 \n\t" \
2379 - "copy %4, %%r24 \n\t" \
2380 "ble " _LWS "(%%sr2, %%r0) \n\t" \
2381 "ldi " _LWS_CAS ", %%r20 \n\t" \
2382 - "ldi " _ASM_EAGAIN ", %%r24 \n\t" \
2383 - "cmpb,=,n %%r24, %%r21, 0b \n\t" \
2384 + "ldi " _ASM_EAGAIN ", %%r20 \n\t" \
2385 + "cmpb,=,n %%r20, %%r21, 0b \n\t" \
2387 - "ldi " _ASM_EDEADLOCK ", %%r25 \n\t" \
2388 - "cmpb,=,n %%r25, %%r21, 0b \n\t" \
2389 + "ldi " _ASM_EDEADLOCK ", %%r20 \n\t" \
2390 + "cmpb,=,n %%r20, %%r21, 0b \n\t" \
2392 - "stw %%r28, %0 \n\t" \
2393 - "stw %%r21, %1 \n\t" \
2394 - : "=m" (lws_ret), "=m" (lws_errno) \
2395 - : "r" (mem), "r" (oldval), "r" (newval) \
2396 + : "=r" (lws_ret), "=r" (lws_errno) \
2397 + : "r" (lws_mem), "r" (lws_old), "r" (lws_new) \
2401 - if(lws_errno == -EFAULT || lws_errno == -ENOSYS) \
2402 + if (lws_errno == -EFAULT || lws_errno == -ENOSYS) \
2403 ABORT_INSTRUCTION; \
2406 + (__typeof (oldval)) lws_ret; \
2409 # define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
2410 diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
2411 index cf0ad90..224e1f3 100644
2412 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
2413 +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
2414 @@ -95,9 +95,6 @@ GLIBC_2.18
2424 @@ -1863,6 +1860,9 @@ GLIBC_2.2.4
2434 diff --git a/sysdeps/unix/sysv/linux/hppa/syscall.c b/sysdeps/unix/sysv/linux/hppa/syscall.c
2435 index aff67a8..958fa47 100644
2436 --- a/sysdeps/unix/sysv/linux/hppa/syscall.c
2437 +++ b/sysdeps/unix/sysv/linux/hppa/syscall.c
2438 @@ -43,9 +43,10 @@ syscall (long int __sysno, ...)
2442 + LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
2443 register unsigned long int __res asm("r28");
2445 - LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
2447 asm volatile (SAVE_ASM_PIC
2448 " ble 0x100(%%sr2, %%r0) \n"
2449 " copy %1, %%r20 \n"
2450 diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
2451 index d20a04b..cb1f163 100644
2452 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
2453 +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
2454 @@ -400,9 +400,10 @@ L(pre_end): ASM_LINE_SEP \
2458 + LOAD_ARGS_##nr(args) \
2459 register unsigned long __res asm("r28"); \
2461 - LOAD_ARGS_##nr(args) \
2463 /* FIXME: HACK save/load r19 around syscall */ \
2466 @@ -425,9 +426,10 @@ L(pre_end): ASM_LINE_SEP \
2470 + LOAD_ARGS_##nr(args) \
2471 register unsigned long __res asm("r28"); \
2473 - LOAD_ARGS_##nr(args) \
2475 /* FIXME: HACK save/load r19 around syscall */ \
2478 @@ -443,27 +445,44 @@ L(pre_end): ASM_LINE_SEP \
2484 #define LOAD_ARGS_0()
2485 -#define LOAD_ARGS_1(r26) \
2486 - register unsigned long __r26 __asm__("r26") = (unsigned long)(r26); \
2487 +#define LOAD_REGS_0
2488 +#define LOAD_ARGS_1(a1) \
2489 + register unsigned long __x26 = (unsigned long)(a1); \
2491 -#define LOAD_ARGS_2(r26,r25) \
2492 - register unsigned long __r25 __asm__("r25") = (unsigned long)(r25); \
2494 -#define LOAD_ARGS_3(r26,r25,r24) \
2495 - register unsigned long __r24 __asm__("r24") = (unsigned long)(r24); \
2496 - LOAD_ARGS_2(r26,r25)
2497 -#define LOAD_ARGS_4(r26,r25,r24,r23) \
2498 - register unsigned long __r23 __asm__("r23") = (unsigned long)(r23); \
2499 - LOAD_ARGS_3(r26,r25,r24)
2500 -#define LOAD_ARGS_5(r26,r25,r24,r23,r22) \
2501 - register unsigned long __r22 __asm__("r22") = (unsigned long)(r22); \
2502 - LOAD_ARGS_4(r26,r25,r24,r23)
2503 -#define LOAD_ARGS_6(r26,r25,r24,r23,r22,r21) \
2504 - register unsigned long __r21 __asm__("r21") = (unsigned long)(r21); \
2505 - LOAD_ARGS_5(r26,r25,r24,r23,r22)
2506 +#define LOAD_REGS_1 \
2507 + register unsigned long __r26 __asm__("r26") = __x26; \
2509 +#define LOAD_ARGS_2(a1,a2) \
2510 + register unsigned long __x25 = (unsigned long)(a2); \
2512 +#define LOAD_REGS_2 \
2513 + register unsigned long __r25 __asm__("r25") = __x25; \
2515 +#define LOAD_ARGS_3(a1,a2,a3) \
2516 + register unsigned long __x24 = (unsigned long)(a3); \
2517 + LOAD_ARGS_2(a1,a2)
2518 +#define LOAD_REGS_3 \
2519 + register unsigned long __r24 __asm__("r24") = __x24; \
2521 +#define LOAD_ARGS_4(a1,a2,a3,a4) \
2522 + register unsigned long __x23 = (unsigned long)(a4); \
2523 + LOAD_ARGS_3(a1,a2,a3)
2524 +#define LOAD_REGS_4 \
2525 + register unsigned long __r23 __asm__("r23") = __x23; \
2527 +#define LOAD_ARGS_5(a1,a2,a3,a4,a5) \
2528 + register unsigned long __x22 = (unsigned long)(a5); \
2529 + LOAD_ARGS_4(a1,a2,a3,a4)
2530 +#define LOAD_REGS_5 \
2531 + register unsigned long __r22 __asm__("r22") = __x22; \
2533 +#define LOAD_ARGS_6(a1,a2,a3,a4,a5,a6) \
2534 + register unsigned long __x21 = (unsigned long)(a6); \
2535 + LOAD_ARGS_5(a1,a2,a3,a4,a5)
2536 +#define LOAD_REGS_6 \
2537 + register unsigned long __r21 __asm__("r21") = __x21; \
2540 /* Even with zero args we use r20 for the syscall number */
2542 diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
2543 index 83c0340..9d5c542 100644
2544 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
2545 +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
2547 License along with the GNU C Library; if not, see
2548 <http://www.gnu.org/licenses/>. */
2550 +#ifndef _LINUX_MICROBLAZE_SYSDEP_H
2551 +#define _LINUX_MICROBLAZE_SYSDEP_H 1
2553 +#include <sysdeps/unix/sysdep.h>
2554 #include <sysdeps/microblaze/sysdep.h>
2555 -#include <sys/syscall.h>
2557 /* Defines RTLD_PRIVATE_ERRNO. */
2558 #include <dl-sysdep.h>
2559 @@ -305,3 +308,5 @@ SYSCALL_ERROR_LABEL_DCL: \
2560 # define PTR_DEMANGLE(var) (void) (var)
2562 #endif /* not __ASSEMBLER__ */
2564 +#endif /* _LINUX_MICROBLAZE_SYSDEP_H */
2565 diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c
2566 index 6777123..ad8e31d 100644
2567 --- a/sysdeps/unix/sysv/linux/openat.c
2568 +++ b/sysdeps/unix/sysv/linux/openat.c
2569 @@ -68,6 +68,11 @@ __OPENAT (int fd, const char *file, int oflag, ...)
2573 + /* We have to add the O_LARGEFILE flag for openat64. */
2575 + oflag |= MORE_OFLAGS;
2578 return SYSCALL_CANCEL (openat, fd, file, oflag, mode);
2580 libc_hidden_def (__OPENAT)
2581 diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
2582 index 7f9bcc2..c6731ca 100644
2583 --- a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
2584 +++ b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
2585 @@ -72,8 +72,7 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
2589 - int try_begin = aconf.try_tbegin;
2591 + for (int i = aconf.try_tbegin; i > 0; i--)
2593 if (__builtin_tbegin (0))
2595 @@ -87,21 +86,19 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
2596 /* A persistent failure indicates that a retry will probably
2597 result in another failure. Use normal locking now and
2598 for the next couple of calls. */
2599 - if (try_begin-- <= 0
2600 - || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2601 + if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2603 if (aconf.skip_lock_internal_abort > 0)
2604 *adapt_count = aconf.skip_lock_internal_abort;
2607 - /* Same logic as above, but for for a number of temporary failures
2609 - else if (aconf.skip_lock_out_of_tbegin_retries > 0
2610 - && aconf.try_tbegin > 0)
2611 - *adapt_count = aconf.skip_lock_out_of_tbegin_retries;
2615 + /* Fall back to locks for a bit if retries have been exhausted */
2616 + if (aconf.try_tbegin > 0 && aconf.skip_lock_out_of_tbegin_retries > 0)
2617 + *adapt_count = aconf.skip_lock_out_of_tbegin_retries;
2620 return LLL_LOCK ((*lock), pshared);
2622 diff --git a/sysdeps/x86/fpu/bits/math-vector.h b/sysdeps/x86/fpu/bits/math-vector.h
2623 index f9e798b..f3bfb86 100644
2624 --- a/sysdeps/x86/fpu/bits/math-vector.h
2625 +++ b/sysdeps/x86/fpu/bits/math-vector.h
2627 # undef __DECL_SIMD_powf
2628 # define __DECL_SIMD_powf __DECL_SIMD_x86_64
2630 -/* Workaround to exclude unnecessary symbol aliases in libmvec
2631 - while GCC creates the vector names based on scalar asm name.
2632 - Corresponding discussion started at
2633 - <https://gcc.gnu.org/ml/gcc/2015-06/msg00173.html>. */
2634 -__asm__ ("_ZGVbN2v___log_finite = _ZGVbN2v_log");
2635 -__asm__ ("_ZGVcN4v___log_finite = _ZGVcN4v_log");
2636 -__asm__ ("_ZGVdN4v___log_finite = _ZGVdN4v_log");
2637 -__asm__ ("_ZGVeN8v___log_finite = _ZGVeN8v_log");
2638 -__asm__ ("_ZGVbN4v___logf_finite = _ZGVbN4v_logf");
2639 -__asm__ ("_ZGVcN8v___logf_finite = _ZGVcN8v_logf");
2640 -__asm__ ("_ZGVdN8v___logf_finite = _ZGVdN8v_logf");
2641 -__asm__ ("_ZGVeN16v___logf_finite = _ZGVeN16v_logf");
2642 -__asm__ ("_ZGVbN2v___exp_finite = _ZGVbN2v_exp");
2643 -__asm__ ("_ZGVcN4v___exp_finite = _ZGVcN4v_exp");
2644 -__asm__ ("_ZGVdN4v___exp_finite = _ZGVdN4v_exp");
2645 -__asm__ ("_ZGVeN8v___exp_finite = _ZGVeN8v_exp");
2646 -__asm__ ("_ZGVbN4v___expf_finite = _ZGVbN4v_expf");
2647 -__asm__ ("_ZGVcN8v___expf_finite = _ZGVcN8v_expf");
2648 -__asm__ ("_ZGVdN8v___expf_finite = _ZGVdN8v_expf");
2649 -__asm__ ("_ZGVeN16v___expf_finite = _ZGVeN16v_expf");
2650 -__asm__ ("_ZGVbN2vv___pow_finite = _ZGVbN2vv_pow");
2651 -__asm__ ("_ZGVcN4vv___pow_finite = _ZGVcN4vv_pow");
2652 -__asm__ ("_ZGVdN4vv___pow_finite = _ZGVdN4vv_pow");
2653 -__asm__ ("_ZGVeN8vv___pow_finite = _ZGVeN8vv_pow");
2654 -__asm__ ("_ZGVbN4vv___powf_finite = _ZGVbN4vv_powf");
2655 -__asm__ ("_ZGVcN8vv___powf_finite = _ZGVcN8vv_powf");
2656 -__asm__ ("_ZGVdN8vv___powf_finite = _ZGVdN8vv_powf");
2657 -__asm__ ("_ZGVeN16vv___powf_finite = _ZGVeN16vv_powf");
2661 diff --git a/sysdeps/x86_64/fpu/Makefile b/sysdeps/x86_64/fpu/Makefile
2662 index 1ebe511..b32b852 100644
2663 --- a/sysdeps/x86_64/fpu/Makefile
2664 +++ b/sysdeps/x86_64/fpu/Makefile
2665 @@ -20,7 +20,10 @@ libmvec-support += svml_d_cos2_core svml_d_cos4_core_avx \
2666 svml_d_pow_data svml_s_powf4_core svml_s_powf8_core_avx \
2667 svml_s_powf8_core svml_s_powf16_core svml_s_powf_data \
2668 svml_s_sincosf4_core svml_s_sincosf8_core_avx \
2669 - svml_s_sincosf8_core svml_s_sincosf16_core init-arch
2670 + svml_s_sincosf8_core svml_s_sincosf16_core init-arch \
2673 +libmvec-static-only-routines = svml_finite_alias
2676 # Variables for libmvec tests.
2677 diff --git a/sysdeps/x86_64/fpu/svml_finite_alias.S b/sysdeps/x86_64/fpu/svml_finite_alias.S
2678 new file mode 100644
2679 index 0000000..f8bcfeb
2681 +++ b/sysdeps/x86_64/fpu/svml_finite_alias.S
2683 +/* These aliases added as workaround to exclude unnecessary symbol
2684 + aliases in libmvec.so while compiler creates the vector names
2685 + based on scalar asm name. Corresponding discussion is at
2686 + <https://gcc.gnu.org/ml/gcc/2015-06/msg00173.html>.
2687 + Copyright (C) 2015 Free Software Foundation, Inc.
2688 + This file is part of the GNU C Library.
2690 + The GNU C Library is free software; you can redistribute it and/or
2691 + modify it under the terms of the GNU Lesser General Public
2692 + License as published by the Free Software Foundation; either
2693 + version 2.1 of the License, or (at your option) any later version.
2695 + The GNU C Library is distributed in the hope that it will be useful,
2696 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2697 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2698 + Lesser General Public License for more details.
2700 + You should have received a copy of the GNU Lesser General Public
2701 + License along with the GNU C Library; if not, see
2702 + <http://www.gnu.org/licenses/>. */
2704 +#include <sysdep.h>
2706 +#define ALIAS_IMPL(alias, target) \
2713 +ALIAS_IMPL (_ZGVbN2v___log_finite, _ZGVbN2v_log)
2714 +ALIAS_IMPL (_ZGVcN4v___log_finite, _ZGVcN4v_log)
2715 +ALIAS_IMPL (_ZGVdN4v___log_finite, _ZGVdN4v_log)
2716 +ALIAS_IMPL (_ZGVeN8v___log_finite, _ZGVeN8v_log)
2718 +ALIAS_IMPL (_ZGVbN4v___logf_finite, _ZGVbN4v_logf)
2719 +ALIAS_IMPL (_ZGVcN8v___logf_finite, _ZGVcN8v_logf)
2720 +ALIAS_IMPL (_ZGVdN8v___logf_finite, _ZGVdN8v_logf)
2721 +ALIAS_IMPL (_ZGVeN16v___logf_finite, _ZGVeN16v_logf)
2723 +ALIAS_IMPL (_ZGVbN2v___exp_finite, _ZGVbN2v_exp)
2724 +ALIAS_IMPL (_ZGVcN4v___exp_finite, _ZGVcN4v_exp)
2725 +ALIAS_IMPL (_ZGVdN4v___exp_finite, _ZGVdN4v_exp)
2726 +ALIAS_IMPL (_ZGVeN8v___exp_finite, _ZGVeN8v_exp)
2728 +ALIAS_IMPL (_ZGVbN4v___expf_finite, _ZGVbN4v_expf)
2729 +ALIAS_IMPL (_ZGVcN8v___expf_finite, _ZGVcN8v_expf)
2730 +ALIAS_IMPL (_ZGVdN8v___expf_finite, _ZGVdN8v_expf)
2731 +ALIAS_IMPL (_ZGVeN16v___expf_finite, _ZGVeN16v_expf)
2733 +ALIAS_IMPL (_ZGVbN2vv___pow_finite, _ZGVbN2vv_pow)
2734 +ALIAS_IMPL (_ZGVcN4vv___pow_finite, _ZGVcN4vv_pow)
2735 +ALIAS_IMPL (_ZGVdN4vv___pow_finite, _ZGVdN4vv_pow)
2736 +ALIAS_IMPL (_ZGVeN8vv___pow_finite, _ZGVeN8vv_pow)
2738 +ALIAS_IMPL (_ZGVbN4vv___powf_finite, _ZGVbN4vv_powf)
2739 +ALIAS_IMPL (_ZGVcN8vv___powf_finite, _ZGVcN8vv_powf)
2740 +ALIAS_IMPL (_ZGVdN8vv___powf_finite, _ZGVdN8vv_powf)
2741 +ALIAS_IMPL (_ZGVeN16vv___powf_finite, _ZGVeN16vv_powf)
2742 diff --git a/time/strftime_l.c b/time/strftime_l.c
2743 index b48ef34..4eb647c 100644
2744 --- a/time/strftime_l.c
2745 +++ b/time/strftime_l.c
2746 @@ -510,13 +510,17 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
2747 only a few elements. Dereference the pointers only if the format
2748 requires this. Then it is ok to fail if the pointers are invalid. */
2750 - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday))
2751 + ((const CHAR_T *) (tp->tm_wday < 0 || tp->tm_wday > 6 \
2752 + ? "?" : _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)))
2754 - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday))
2755 + ((const CHAR_T *) (tp->tm_wday < 0 || tp->tm_wday > 6 \
2756 + ? "?" : _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)))
2758 - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon))
2759 + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
2760 + ? "?" : _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)))
2762 - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))
2763 + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
2764 + ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
2766 ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \
2767 ? NLW(PM_STR) : NLW(AM_STR)))
2768 @@ -526,8 +530,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
2769 # define ap_len STRLEN (ampm)
2772 -# define f_wkday (weekday_name[tp->tm_wday])
2773 -# define f_month (month_name[tp->tm_mon])
2774 +# define f_wkday (tp->tm_wday < 0 || tp->tm_wday > 6 \
2775 + ? "?" : weekday_name[tp->tm_wday])
2776 +# define f_month (tp->tm_mon < 0 || tp->tm_mon > 11 \
2777 + ? "?" : month_name[tp->tm_mon])
2778 # define a_wkday f_wkday
2779 # define a_month f_month
2780 # define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
2781 @@ -1321,7 +1327,7 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
2782 *tzset_called = true;
2785 - zone = tzname[tp->tm_isdst];
2786 + zone = tp->tm_isdst <= 1 ? tzname[tp->tm_isdst] : "?";
2790 diff --git a/time/tst-strftime.c b/time/tst-strftime.c
2791 index 374fba4..af3ff72 100644
2792 --- a/time/tst-strftime.c
2793 +++ b/time/tst-strftime.c
2805 + memset (&ttm, 1, sizeof (ttm));
2806 + ttm.tm_zone = NULL; /* Dereferenced directly if non-NULL. */
2807 + rc = strftime (buf, sizeof (buf), "%a %A %b %B %c %z %Z", &ttm);
2811 + const char expected[]
2812 + = "? ? ? ? ? ? 16843009 16843009:16843009:16843009 16844909 +467836 ?";
2813 + if (0 != strcmp (buf, expected))
2815 + printf ("expected:\n %s\ngot:\n %s\n", expected, buf);
2821 + printf ("expected 66, got %d\n", rc);
2825 + /* Check negative values as well. */
2826 + memset (&ttm, 0xFF, sizeof (ttm));
2827 + ttm.tm_zone = NULL; /* Dereferenced directly if non-NULL. */
2828 + rc = strftime (buf, sizeof (buf), "%a %A %b %B %c %z %Z", &ttm);
2832 + const char expected[] = "? ? ? ? ? ? -1 -1:-1:-1 1899 ";
2833 + if (0 != strcmp (buf, expected))
2835 + printf ("expected:\n %s\ngot:\n %s\n", expected, buf);
2841 + printf ("expected 30, got %d\n", rc);
2851 @@ -104,7 +154,7 @@ do_test (void)
2856 + return result + do_bz18985 ();
2859 #define TEST_FUNCTION do_test ()
2860 diff --git a/wcsmbs/wcscoll_l.c b/wcsmbs/wcscoll_l.c
2861 index 6d9384a..87f240d 100644
2862 --- a/wcsmbs/wcscoll_l.c
2863 +++ b/wcsmbs/wcscoll_l.c
2865 #define STRING_TYPE wchar_t
2866 #define USTRING_TYPE wint_t
2867 #define STRCOLL __wcscoll_l
2868 -#define STRDIFF __wcsdiff
2869 #define STRCMP __wcscmp
2870 #define WEIGHT_H "../locale/weightwc.h"