]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-git.patch
- update from upstream
[packages/glibc.git] / glibc-git.patch
1 diff --git a/ChangeLog b/ChangeLog
2 index cb9124e..ed20b9b 100644
3 --- a/ChangeLog
4 +++ b/ChangeLog
5 @@ -1,3 +1,313 @@
6 +2016-01-27  Paul Eggert  <eggert@cs.ucla.edu>
7 +
8 +       [BZ #18240]
9 +       * misc/hsearch_r.c (isprime, __hcreate_r): Protect against
10 +       unsigned int wraparound.
11 +
12 +2016-01-27  Florian Weimer  <fweimer@redhat.com>
13 +
14 +       [BZ #18240]
15 +       * misc/bug18240.c: New test.
16 +       * misc/Makefile (tests): Add it.
17 +
18 +2015-08-25  Ondřej Bílka  <neleai@seznam.cz>
19 +
20 +       [BZ #18240]
21 +       * misc/hsearch_r.c (__hcreate_r): Handle overflow.
22 +
23 +2015-10-27  Ludovic Courtès  <ludo@gnu.org>
24 +
25 +       * locale/loadlocale.c (_nl_intern_locale_data): Change assertion
26 +       on CNT to a conditional jump to 'puntdata'.
27 +
28 +2015-08-18  Alan Modra  <amodra@gmail.com>
29 +
30 +       [BZ #18421]
31 +       * sysdeps/hppa/start.S [SHARED]: Use .section .data.rel.ro and define
32 +       .Lp__global.
33 +       (_start): Load %dp via .Lp__global.
34 +       [!SHARED]: Use .section .rodata.
35 +
36 +2015-08-09  John David Anglin  <danglin@gcc.gnu.org>
37 +
38 +       [BZ #18480]
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):
41 +       Define.
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.
47 +
48 +2015-09-26  Paul Pluzhnikov  <ppluzhnikov@google.com>
49 +
50 +       [BZ #18985]
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.
54 +       (do_test): Call it.
55 +
56 +2015-08-08  Paul Pluzhnikov  <ppluzhnikov@google.com>
57 +
58 +       [BZ #17905]
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.
63 +
64 +2015-12-31  Aurelien Jarno  <aurelien@aurel32.net>
65 +
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.
69 +
70 +2015-12-17  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
71 +
72 +       [BZ #19174]
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
77 +       try_tbegin <= 0.
78 +
79 +2015-12-03  Andrew Senkevich  <andrew.senkevich@intel.com>
80 +
81 +       * math/Makefile ($(inst_libdir)/libm.so): Corrected path to
82 +       libmvec_nonshared.a
83 +
84 +2015-11-27  Andrew Senkevich  <andrew.senkevich@intel.com>
85 +
86 +       [BZ #19058]
87 +       * math/Makefile ($(inst_libdir)/libm.so): Added libmvec_nonshared.a to
88 +       AS_NEEDED.
89 +       * sysdeps/x86/fpu/bits/math-vector.h: Removed code with asm aliases
90 +       workaround.
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.
95 +
96 +2015-11-20  Roland McGrath  <roland@hack.frob.com>
97 +
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.
102 +
103 +2015-11-14  H.J. Lu  <hongjiu.lu@intel.com>
104 +
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.
123 +
124 +2015-11-10  Roland McGrath  <roland@hack.frob.com>
125 +
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
135 +       from libc to rtld.
136 +
137 +2015-11-10  H.J. Lu  <hongjiu.lu@intel.com>
138 +
139 +       [BZ #19178]
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.
147 +
148 +2015-11-07  H.J. Lu  <hongjiu.lu@intel.com>
149 +
150 +       [BZ #19178]
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
158 +       DL_DEBUG_PRELINK.
159 +
160 +2015-10-20  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
161 +
162 +       [BZ #18743]
163 +       * sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
164 +       code to...
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
168 +       transaction abort.
169 +       (__elided_trylock): Moved this code to...
170 +       (ELIDE_TRYLOCK): ...here.
171 +
172 +2015-10-06  Florian Weimer  <fweimer@redhat.com>
173 +
174 +       [BZ #19018]
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.
178 +
179 +2015-10-15  Florian Weimer  <fweimer@redhat.com>
180 +
181 +       [BZ #18928]
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
185 +       initializer.
186 +       (security_init): Always set up pointer guard.
187 +       (process_envvars): Do not process LD_POINTER_GUARD.
188 +
189 +2015-10-09  Carlos O'Donell  <carlos@redhat.com>
190 +
191 +       [BZ #18589]
192 +       * string/bug-strcoll2.c: Adjust copyright, and remove contributed by.
193 +       * string/Makefile ($(objpfx)bug-strcoll2.out): Depend on
194 +       $(gen-locales).
195 +
196 +2015-10-08  Carlos O'Donell  <carlos@redhat.com>
197 +
198 +       [BZ #18589]
199 +       * string/Makefile (tests): Add bug-strcoll2.
200 +       (LOCALES): Add cs_CZ.UTF-8.
201 +
202 +2015-09-28  Martin Sebor  <msebor@redhat.com>
203 +
204 +       [BZ #18969]
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.
211 +
212 +2015-10-08  Carlos O'Donell  <carlos@redhat.com>
213 +
214 +       [BZ #18589]
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.
225 +
226 +2015-09-15  Roland McGrath  <roland@hack.frob.com>
227 +
228 +       * misc/sys/param.h [!MAXHOSTNAMELEN && HOST_NAME_MAX]
229 +       (MAXHOSTNAMELEN): Define it to HOST_NAME_MAX.
230 +
231 +2015-09-11  Roland McGrath  <roland@hack.frob.com>
232 +
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.
236 +
237 +2015-09-04  Roland McGrath  <roland@hack.frob.com>
238 +
239 +       [BZ #18921]
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>.
244 +
245 +2015-08-31  Brett Neumeier <brett@neumeier.us>
246 +
247 +       [BZ #18870]
248 +       * sysdeps/sparc/sparc32/sem_open.c: Add missing #include
249 +
250 +2015-08-28  Mike Frysinger  <vapier@gentoo.org>
251 +
252 +       [BZ #18887]
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.
259 +
260 +2015-08-25  Roland McGrath  <roland@hack.frob.com>
261 +
262 +       * sysdeps/nacl/start.c (_start): Call __nacl_main instead of main
263 +       if the weak reference is not null.
264 +
265 +2015-08-19  Andrew Senkevich  <andrew.senkevich@intel.com>
266 +
267 +       [BZ #18796]
268 +       * scripts/test-installation.pl: Don't add -lmvec to build options
269 +       if libmvec wasn't built.
270 +       * NEWS: Mention this fix.
271 +
272 +2015-08-10  Maxim Ostapenko  <m.ostapenko@partner.samsung.com>
273 +
274 +       [BZ #18778]
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.
285 +
286 +2015-08-10  Andreas Schwab  <schwab@suse.de>
287 +
288 +       [BZ #18781]
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.
292 +
293 +2015-08-08  John David Anglin  <danglin@gcc.gnu.org>
294 +
295 +       [BZ #18787]
296 +       * sysdeps/unix/sysv/linux/hppa/bits/atomic.h (_LWS_CLOBBER): Revise
297 +       clobber registers.
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).
301 +
302 +2015-08-08  Mike Frysinger  <vapier@gentoo.org>
303 +
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.
307 +
308 +2015-08-07  Mike Frysinger  <vapier@gentoo.org>
309 +
310 +       * sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Add rtld_hidden_def.
311 +
312 +2015-08-05  Zack Weinberg  <zackw@panix.com>
313 +
314 +       * misc/regexp.h: Update comments.
315 +
316  2015-08-05  Carlos O'Donell  <carlos@systemhalted.org>
317  
318         * version.h (RELEASE): Set to "stable".
319 diff --git a/NEWS b/NEWS
320 index 4c31de7..d1daf9b 100644
321 --- a/NEWS
322 +++ b/NEWS
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.
326  \f
327 +Version 2.22.1
328 +
329 +* The following bugs are resolved with this release:
330 +
331 +  17905, 18420, 18421, 18480, 18589, 18743, 18778, 18781, 18787, 18796,
332 +  18870, 18887, 18921, 18928, 18969, 18985, 19018, 19058, 19174, 19178.
333 +
334 +* The LD_POINTER_GUARD environment variable can no longer be used to
335 +  disable the pointer guard feature.  It is always enabled.
336 +\f
337  Version 2.22
338  
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.
343  
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.
348  \f
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
358  endif
359  
360  gencat-modules = xmalloc
361 @@ -50,9 +51,11 @@ catgets-CPPFLAGS := -DNLSPATH='"$(msgcatdir)/%L/%N:$(msgcatdir)/%L/LC_MESSAGES/%
362  
363  generated += de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
364              test-gencat.h
365 +generated += tst-catgets.mtrace tst-catgets-mem.out
366 +
367  generated-dirs += de
368  
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
371  
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,$^) > $@; \
377         $(evaluate-test)
378 +
379 +$(objpfx)tst-catgets-mem.out: $(objpfx)tst-catgets.out
380 +       $(common-objpfx)malloc/mtrace $(objpfx)tst-catgets.mtrace > $@; \
381 +       $(evaluate-test)
382  endif
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
387 @@ -16,7 +16,6 @@
388     License along with the GNU C Library; if not, see
389     <http://www.gnu.org/licenses/>.  */
390  
391 -#include <alloca.h>
392  #include <errno.h>
393  #include <locale.h>
394  #include <nl_types.h>
395 @@ -35,6 +34,7 @@ catopen (const char *cat_name, int flag)
396    __nl_catd result;
397    const char *env_var = NULL;
398    const char *nlspath = NULL;
399 +  char *tmp = NULL;
400  
401    if (strchr (cat_name, '/') == NULL)
402      {
403 @@ -54,7 +54,10 @@ catopen (const char *cat_name, int flag)
404         {
405           /* Append the system dependent directory.  */
406           size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
407 -         char *tmp = alloca (len);
408 +         tmp = malloc (len);
409 +
410 +         if (__glibc_unlikely (tmp == NULL))
411 +           return (nl_catd) -1;
412  
413           __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
414           nlspath = tmp;
415 @@ -65,16 +68,18 @@ catopen (const char *cat_name, int flag)
416  
417    result = (__nl_catd) malloc (sizeof (*result));
418    if (result == NULL)
419 -    /* We cannot get enough memory.  */
420 -    return (nl_catd) -1;
421 -
422 -  if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
423 +    {
424 +      /* We cannot get enough memory.  */
425 +      result = (nl_catd) -1;
426 +    }
427 +  else if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
428      {
429        /* Couldn't open the file.  */
430        free ((void *) result);
431 -      return (nl_catd) -1;
432 +      result = (nl_catd) -1;
433      }
434  
435 +  free (tmp);
436    return (nl_catd) result;
437  }
438  
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,
444    size_t tab_size;
445    const char *lastp;
446    int result = -1;
447 +  char *buf = NULL;
448  
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))                             \
453      {                                                                        \
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))                                    \
461 +       {                                                                     \
462 +         free (old_buf);                                                     \
463 +         return -1;                                                          \
464 +       }                                                                     \
465      }
466  
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.  */
471 -      char *buf;
472        size_t bufact;
473 -      size_t bufmax;
474 +      size_t bufmax = 0;
475        size_t len;
476  
477 -      buf = NULL;
478 -      bufmax = 0;
479 -
480        fd = -1;
481        while (*run_nlspath != '\0')
482         {
483 @@ -188,7 +189,10 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
484  
485    /* Avoid dealing with directories and block devices */
486    if (__builtin_expect (fd, 0) < 0)
487 -    return -1;
488 +    {
489 +      free (buf);
490 +      return -1;
491 +    }
492  
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.  */
497   close_unlock_return:
498    close_not_cancel_no_status (fd);
499 +  free (buf);
500  
501    return result;
502  }
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
507 @@ -1,7 +1,10 @@
508 +#include <assert.h>
509  #include <mcheck.h>
510  #include <nl_types.h>
511  #include <stdio.h>
512 +#include <stdlib.h>
513  #include <string.h>
514 +#include <sys/resource.h>
515  
516  
517  static const char *msgs[] =
518 @@ -12,6 +15,33 @@ static const char *msgs[] =
519  };
520  #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
521  
522 +
523 +/* Test for unbounded alloca.  */
524 +static int
525 +do_bz17905 (void)
526 +{
527 +  char *buf;
528 +  struct rlimit rl;
529 +  nl_catd result;
530 +
531 +  const int sz = 1024 * 1024;
532 +
533 +  getrlimit (RLIMIT_STACK, &rl);
534 +  rl.rlim_cur = sz;
535 +  setrlimit (RLIMIT_STACK, &rl);
536 +
537 +  buf = malloc (sz + 1);
538 +  memset (buf, 'A', sz);
539 +  buf[sz] = '\0';
540 +  setenv ("NLSPATH", buf, 1);
541 +
542 +  result = catopen (buf, NL_CAT_LOCALE);
543 +  assert (result == (nl_catd) -1);
544 +
545 +  free (buf);
546 +  return 0;
547 +}
548 +
549  #define ROUNDS 5
550  
551  static int
552 @@ -62,6 +92,7 @@ do_test (void)
553         }
554      }
555  
556 +  result += do_bz17905 ();
557    return result;
558  }
559  
560 diff --git a/config.make.in b/config.make.in
561 index a9f5696..46cd9bb 100644
562 --- a/config.make.in
563 +++ b/config.make.in
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@
569  with-fp = @with_fp@
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
574 --- a/configure
575 +++ b/configure
576 @@ -628,6 +628,7 @@ gnu89_inline
577  libc_cv_ssp
578  fno_unit_at_a_time
579  libc_cv_output_format
580 +libc_cv_has_glob_dat
581  libc_cv_hashstyle
582  libc_cv_fpie
583  libc_cv_z_execstack
584 @@ -6335,6 +6336,39 @@ $as_echo "$libc_cv_use_default_link" >&6; }
585    use_default_link=$libc_cv_use_default_link
586  fi
587  
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
592 +else
593 +  cat > conftest.c <<EOF
594 +extern int mumble;
595 +int foo (void) { return mumble; }
596 +EOF
597 +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
598 +                       -fPIC -shared -o conftest.so conftest.c
599 +                       -nostdlib -nostartfiles
600 +                       1>&5'
601 +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
602 +  (eval $ac_try) 2>&5
603 +  ac_status=$?
604 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
605 +  test $ac_status = 0; }; }
606 +then
607 +  if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
608 +    libc_cv_has_glob_dat=yes
609 +  else
610 +    libc_cv_has_glob_dat=no
611 +  fi
612 +else
613 +  libc_cv_has_glob_dat=no
614 +fi
615 +rm -f conftest*
616 +fi
617 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_has_glob_dat" >&5
618 +$as_echo "$libc_cv_has_glob_dat" >&6; }
619 +
620 +
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
626 --- a/configure.ac
627 +++ b/configure.ac
628 @@ -1535,6 +1535,29 @@ $ac_try"
629    use_default_link=$libc_cv_use_default_link
630  fi
631  
632 +AC_CACHE_CHECK(for GLOB_DAT reloc,
633 +              libc_cv_has_glob_dat, [dnl
634 +cat > conftest.c <<EOF
635 +extern int mumble;
636 +int foo (void) { return mumble; }
637 +EOF
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])
642 +then
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
646 +  else
647 +    libc_cv_has_glob_dat=no
648 +  fi
649 +else
650 +  libc_cv_has_glob_dat=no
651 +fi
652 +rm -f conftest*])
653 +AC_SUBST(libc_cv_has_glob_dat)
654 +
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
660 --- a/elf/Makefile
661 +++ b/elf/Makefile
662 @@ -148,7 +148,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
663          tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
664          tst-nodelete) \
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 \
668 +        tst-nodelete2
669  #       reldep9
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 \
673                 tst-initorder2d \
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
684  
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
689 +endif
690 +endif
691 +
692  include ../Rules
693  
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
700  
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
706  
707 +$(objpfx)tst-nodelete2: $(libdl)
708 +$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
709 +
710 +LDFLAGS-tst-nodelete2 = -rdynamic
711 +
712  $(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
713         cmp $^ > $@; \
714         $(evaluate-test)
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 > $@; \
718         $(evaluate-test)
719 +
720 +tst-prelink-ENV = LD_TRACE_PRELINKING=1
721 +
722 +$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
723 +       grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
724 +
725 +$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
726 +                             $(objpfx)tst-prelink-conflict.out
727 +       cmp $^ > $@; \
728 +       $(evaluate-test)
729 diff --git a/elf/dl-close.c b/elf/dl-close.c
730 index 9105277..c897247 100644
731 --- a/elf/dl-close.c
732 +++ b/elf/dl-close.c
733 @@ -144,6 +144,14 @@ _dl_close_worker (struct link_map *map, bool force)
734    char done[nloaded];
735    struct link_map *maps[nloaded];
736  
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
741 +     object.  */
742 +  if (force)
743 +    map->l_flags_1 &= ~DF_1_NODELETE;
744 +
745    /* Run over the list and assign indexes to the link maps and enter
746       them into the MAPS array.  */
747    int idx = 0;
748 @@ -153,13 +161,6 @@ _dl_close_worker (struct link_map *map, bool force)
749        maps[idx] = l;
750        ++idx;
751  
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
756 -        object.  */
757 -      if (force)
758 -       l->l_flags_1 &= ~DF_1_NODELETE;
759      }
760    assert (idx == nloaded);
761  
762 diff --git a/elf/dl-load.c b/elf/dl-load.c
763 index 0c052e4..7e6f4c5 100644
764 --- a/elf/dl-load.c
765 +++ b/elf/dl-load.c
766 @@ -42,6 +42,7 @@
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>
771  
772  
773  #include <endian.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.
780 +
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.  */
783  static int
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)
788  {
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)
793      {
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)
797         {
798 @@ -1528,11 +1534,21 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
799  
800           afct = afct->next;
801         }
802 +
803 +      if (fd != -1 && name != original_name && strcmp (name, original_name))
804 +        {
805 +          /* An audit library changed what we're supposed to open,
806 +             so FD no longer matches it.  */
807 +          __close (fd);
808 +          fd = -1;
809 +        }
810      }
811  #endif
812  
813 -  /* Open the file.  We always open files read-only.  */
814 -  int fd = __open (name, O_RDONLY | O_CLOEXEC);
815 +  if (fd == -1)
816 +    /* Open the file.  We always open files read-only.  */
817 +    fd = __open (name, O_RDONLY | O_CLOEXEC);
818 +
819    if (fd != -1)
820      {
821        ElfW(Ehdr) *ehdr;
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);
825  
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)
830             {
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);
834  
835 +      if (fd == -1)
836 +        {
837 +          realname = _dl_sysdep_open_object (name, namelen, &fd);
838 +          if (realname != NULL)
839 +            {
840 +              fd = open_verify (realname, fd,
841 +                                &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
842 +                                LA_SER_CONFIG, mode, &found_other_class,
843 +                                false);
844 +              if (fd == -1)
845 +                free (realname);
846 +            }
847 +        }
848 +
849  #ifdef USE_LDCONFIG
850        if (fd == -1
851           && (__glibc_likely ((mode & __RTLD_SECURE) == 0)
852 @@ -2086,7 +2116,7 @@ _dl_map_object (struct link_map *loader, const char *name,
853  
854               if (cached != NULL)
855                 {
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,
860                                     false);
861 @@ -2121,7 +2151,7 @@ _dl_map_object (struct link_map *loader, const char *name,
862         fd = -1;
863        else
864         {
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,
875  #ifdef SHARED
876    if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
877      {
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!
886 +#endif
887 +#if ELF_RTYPE_CLASS_COPY != 0 && ELF_RTYPE_CLASS_COPY != 2
888 +# error ELF_RTYPE_CLASS_COPY must be 0 or 2!
889 +#endif
890        int conflict = 0;
891        struct sym_val val = { NULL, NULL };
892  
893 @@ -1071,12 +1083,17 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
894  
895        if (value->s)
896         {
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)
901                                 == STT_TLS))
902 -           type_class = 4;
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)
906                                      == STT_GNU_IFUNC))
907 -           type_class |= 8;
908 +           /* Set the RTYPE_CLASS_VALID bit.  */
909 +           type_class |= RTYPE_CLASS_VALID;
910         }
911  
912        if (conflict
913 diff --git a/elf/dl-sysdep-open.h b/elf/dl-sysdep-open.h
914 new file mode 100644
915 index 0000000..a63d9f5
916 --- /dev/null
917 +++ b/elf/dl-sysdep-open.h
918 @@ -0,0 +1,45 @@
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.
922 +
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.
927 +
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.
932 +
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/>.  */
936 +
937 +#ifndef _DL_SYSDEP_OPEN_H
938 +#define _DL_SYSDEP_OPEN_H      1
939 +
940 +#include <assert.h>
941 +#include <stddef.h>
942 +
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).
945 +
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).  */
955 +
956 +static inline char *
957 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
958 +{
959 +  assert (*fd == -1);
960 +  return NULL;
961 +}
962 +
963 +#endif  /* dl-sysdep-open.h */
964 diff --git a/elf/rtld.c b/elf/rtld.c
965 index 69873c2..07e741c 100644
966 --- a/elf/rtld.c
967 +++ b/elf/rtld.c
968 @@ -162,7 +162,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
969      ._dl_hwcap_mask = HWCAP_IMPORTANT,
970      ._dl_lazy = 1,
971      ._dl_fpu_control = _FPU_DEFAULT,
972 -    ._dl_pointer_guard = 1,
973      ._dl_pagesize = EXEC_PAGESIZE,
974      ._dl_inhibit_cache = 0,
975  
976 @@ -709,15 +708,12 @@ security_init (void)
977  #endif
978  
979    /* Set up the pointer guard as well, if necessary.  */
980 -  if (GLRO(dl_pointer_guard))
981 -    {
982 -      uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
983 -                                                            stack_chk_guard);
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);
989  #endif
990 -      __pointer_chk_guard_local = pointer_chk_guard;
991 -    }
992 +  __pointer_chk_guard_local = pointer_chk_guard;
993  
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;
998               break;
999             }
1000 -
1001 -         if (memcmp (envline, "POINTER_GUARD", 13) == 0)
1002 -           GLRO(dl_pointer_guard) = envline[14] != '0';
1003           break;
1004  
1005         case 14:
1006 diff --git a/elf/tst-nodelete2.c b/elf/tst-nodelete2.c
1007 new file mode 100644
1008 index 0000000..388e8af
1009 --- /dev/null
1010 +++ b/elf/tst-nodelete2.c
1011 @@ -0,0 +1,37 @@
1012 +#include "../dlfcn/dlfcn.h"
1013 +#include <stdio.h>
1014 +#include <stdlib.h>
1015 +#include <gnu/lib-names.h>
1016 +
1017 +static int
1018 +do_test (void)
1019 +{
1020 +  int result = 0;
1021 +
1022 +  printf ("\nOpening pthread library.\n");
1023 +  void *pthread = dlopen (LIBPTHREAD_SO, RTLD_LAZY);
1024 +
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)
1033 +    {
1034 +      printf ("Unique symbols test failed\n");
1035 +      result = 1;
1036 +    }
1037 +
1038 +  if (pthread)
1039 +    dlclose (pthread);
1040 +
1041 +  if (result == 0)
1042 +    printf ("SUCCESS\n");
1043 +
1044 +  return result;
1045 +}
1046 +
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
1052 --- /dev/null
1053 +++ b/elf/tst-nodelete2mod.c
1054 @@ -0,0 +1,7 @@
1055 +/* Undefined symbol.  */
1056 +extern int not_exist (void);
1057 +
1058 +int foo (void)
1059 +{
1060 +  return not_exist ();
1061 +}
1062 diff --git a/elf/tst-prelink.c b/elf/tst-prelink.c
1063 new file mode 100644
1064 index 0000000..ab61c4e
1065 --- /dev/null
1066 +++ b/elf/tst-prelink.c
1067 @@ -0,0 +1,30 @@
1068 +/* Test the output from the environment variable, LD_TRACE_PRELINKING,
1069 +   for prelink.
1070 +   Copyright (C) 2015 Free Software Foundation, Inc.
1071 +   This file is part of the GNU C Library.
1072 +
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.
1077 +
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.
1082 +
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/>.  */
1086 +
1087 +#include <stdio.h>
1088 +
1089 +static int
1090 +do_test (void)
1091 +{
1092 +  fprintf (stdout, "hello\n");
1093 +  return 0;
1094 +}
1095 +
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
1101 --- /dev/null
1102 +++ b/elf/tst-prelink.exp
1103 @@ -0,0 +1 @@
1104 +/0 stdout
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
1109 +++ /dev/null
1110 @@ -1,6 +0,0 @@
1111 -extern int not_exist (void);
1112 -
1113 -int foo (void)
1114 -{
1115 -  return  not_exist ();
1116 -}
1117 diff --git a/io/test-lfs.c b/io/test-lfs.c
1118 index 539c2a2..b6ebae4 100644
1119 --- a/io/test-lfs.c
1120 +++ b/io/test-lfs.c
1121 @@ -144,7 +144,7 @@ test_ftello (void)
1122  int
1123  do_test (int argc, char *argv[])
1124  {
1125 -  int ret;
1126 +  int ret, fd2;
1127    struct stat64 statbuf;
1128  
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));
1133  
1134 +  fd2 = openat64 (AT_FDCWD, name, O_RDWR);
1135 +  if (fd2 == -1)
1136 +    {
1137 +      if (errno == ENOSYS)
1138 +       {
1139 +         /* Silently ignore this test.  */
1140 +         error (0, 0, "openat64 is not supported");
1141 +       }
1142 +      else
1143 +       error (EXIT_FAILURE, errno, "openat64 failed to open big file");
1144 +    }
1145 +  else
1146 +    {
1147 +      ret = close (fd2);
1148 +
1149 +      if (ret == -1)
1150 +       error (EXIT_FAILURE, errno, "error closing file");
1151 +    }
1152 +
1153    test_ftello ();
1154  
1155    return 0;
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 }
1168    }
1169  };
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)
1179    ), NO_POSTLOAD)
1180  
1181  
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,
1191    _NL_NUM_LC_COLLATE,
1192  
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)
1199        switch (category)
1200         {
1201  #define CATTEST(cat) \
1202 -       case LC_##cat:                                                        \
1203 -         assert (cnt < (sizeof (_nl_value_type_LC_##cat)                     \
1204 -                        / sizeof (_nl_value_type_LC_##cat[0])));             \
1205 +       case LC_##cat:                                          \
1206 +         if (cnt >= (sizeof (_nl_value_type_LC_##cat)          \
1207 +                     / sizeof (_nl_value_type_LC_##cat[0])))   \
1208 +           goto puntdata;                                      \
1209           break
1210           CATTEST (NUMERIC);
1211           CATTEST (TIME);
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
1217    sort_mask
1218  };
1219  
1220 -/* Collation encoding type.  */
1221 -enum collation_encoding_type
1222 -{
1223 -  __cet_other,
1224 -  __cet_8bit,
1225 -  __cet_utf8
1226 -};
1227 -
1228  /* We can map the types of the entries into a few categories.  */
1229  enum value_type
1230  {
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
1235 @@ -32,7 +32,6 @@
1236  #include "linereader.h"
1237  #include "locfile.h"
1238  #include "elem-hash.h"
1239 -#include "../localeinfo.h"
1240  
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);
1249           else
1250             add_locale_empty (&file);
1251         }
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);
1260 -  else
1261 -    add_locale_uint32 (&file, __cet_other);
1262    write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", &file);
1263  
1264    obstack_free (&weightpool, NULL);
1265 diff --git a/math/Makefile b/math/Makefile
1266 index 6388bae..2c9d72d 100644
1267 --- a/math/Makefile
1268 +++ b/math/Makefile
1269 @@ -98,7 +98,7 @@ $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
1270         (echo '/* GNU ld script'; echo '*/';\
1271          cat $<; \
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) ) )' \
1275         ) > $@
1276  endif
1277  
1278 diff --git a/misc/Makefile b/misc/Makefile
1279 index aecb0da..12055ce 100644
1280 --- a/misc/Makefile
1281 +++ b/misc/Makefile
1282 @@ -76,7 +76,8 @@ install-lib := libg.a
1283  gpl2lgpl := error.c error.h
1284  
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
1291  endif
1292 diff --git a/misc/bug18240.c b/misc/bug18240.c
1293 new file mode 100644
1294 index 0000000..4b26865
1295 --- /dev/null
1296 +++ b/misc/bug18240.c
1297 @@ -0,0 +1,75 @@
1298 +/* Test integer wraparound in hcreate.
1299 +   Copyright (C) 2016 Free Software Foundation, Inc.
1300 +   This file is part of the GNU C Library.
1301 +
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.
1306 +
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.
1311 +
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/>.  */
1315 +
1316 +#include <errno.h>
1317 +#include <limits.h>
1318 +#include <search.h>
1319 +#include <stdbool.h>
1320 +#include <stdio.h>
1321 +#include <stdlib.h>
1322 +
1323 +static void
1324 +test_size (size_t size)
1325 +{
1326 +  int res = hcreate (size);
1327 +  if (res == 0)
1328 +    {
1329 +      if (errno == ENOMEM)
1330 +        return;
1331 +      printf ("error: hcreate (%zu): %m\n", size);
1332 +      exit (1);
1333 +    }
1334 +  char *keys[100];
1335 +  for (int i = 0; i < 100; ++i)
1336 +    {
1337 +      if (asprintf (keys + i, "%d", i) < 0)
1338 +        {
1339 +          printf ("error: asprintf: %m\n");
1340 +          exit (1);
1341 +        }
1342 +      ENTRY e = { keys[i], (char *) "value" };
1343 +      if (hsearch (e, ENTER) == NULL)
1344 +        {
1345 +          printf ("error: hsearch (\"%s\"): %m\n", keys[i]);
1346 +          exit (1);
1347 +        }
1348 +    }
1349 +  hdestroy ();
1350 +
1351 +  for (int i = 0; i < 100; ++i)
1352 +    free (keys[i]);
1353 +}
1354 +
1355 +static int
1356 +do_test (void)
1357 +{
1358 +  test_size (500);
1359 +  test_size (-1);
1360 +  test_size (-3);
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);
1368 +  return 0;
1369 +}
1370 +
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
1377 @@ -19,7 +19,7 @@
1378  #include <errno.h>
1379  #include <malloc.h>
1380  #include <string.h>
1381 -
1382 +#include <stdint.h>
1383  #include <search.h>
1384  
1385  /* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
1386 @@ -46,15 +46,12 @@ static int
1387  isprime (unsigned int number)
1388  {
1389    /* no even number will be passed */
1390 -  unsigned int div = 3;
1391 -
1392 -  while (div * div < number && number % div != 0)
1393 -    div += 2;
1394 -
1395 -  return number % div != 0;
1396 +  for (unsigned int div = 3; div <= number / div; div += 2)
1397 +    if (number % div == 0)
1398 +      return 0;
1399 +  return 1;
1400  }
1401  
1402 -
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.  */
1408    if (nel < 3)
1409      nel = 3;
1410 -  /* Change nel to the first prime number not smaller as nel. */
1411 -  nel |= 1;      /* make odd */
1412 -  while (!isprime (nel))
1413 -    nel += 2;
1414 +
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)
1418 +    {
1419 +      if (UINT_MAX - 2 < nel)
1420 +       {
1421 +         __set_errno (ENOMEM);
1422 +         return 0;
1423 +       }
1424 +      if (isprime (nel))
1425 +       break;
1426 +    }
1427  
1428    htab->size = nel;
1429    htab->filled = 0;
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 */
1437         {
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'))
1442              end_ptr--;
1443           *end_ptr = '\0';
1444         }
1445 diff --git a/misc/regexp.h b/misc/regexp.h
1446 index 3460989..42394f7 100644
1447 --- a/misc/regexp.h
1448 +++ b/misc/regexp.h
1449 @@ -19,10 +19,11 @@
1450  #ifndef _REGEXP_H
1451  #define _REGEXP_H      1
1452  
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).
1462  
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
1469 @@ -50,6 +50,9 @@
1470  #if !defined NOFILE && defined OPEN_MAX
1471  # define NOFILE                OPEN_MAX
1472  #endif
1473 +#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
1474 +# define MAXHOSTNAMELEN        HOST_NAME_MAX
1475 +#endif
1476  #ifndef NCARGS
1477  # ifdef ARG_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
1482 --- /dev/null
1483 +++ b/misc/tst-mntent-blank-corrupt.c
1484 @@ -0,0 +1,45 @@
1485 +/* Make sure blank lines does not cause memory corruption BZ #18887.
1486 +
1487 +   Copyright (C) 2009-2015 Free Software Foundation, Inc.
1488 +   This file is part of the GNU C Library.
1489 +
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.
1494 +
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.
1499 +
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/>.  */
1503 +
1504 +#include <mntent.h>
1505 +#include <stdio.h>
1506 +#include <string.h>
1507 +
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.  */
1510 +static int
1511 +do_test (void)
1512 +{
1513 +  FILE *fp;
1514 +
1515 +  fp = tmpfile ();
1516 +  fputs ("\n \n/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1517 +  rewind (fp);
1518 +
1519 +  /* The corruption happens here ...  */
1520 +  getmntent (fp);
1521 +  /* ... but trigers here.  */
1522 +  endmntent (fp);
1523 +
1524 +  /* If the test failed, we would crash, and not hit this point.  */
1525 +  return 0;
1526 +}
1527 +
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
1533 --- /dev/null
1534 +++ b/misc/tst-mntent-blank-passno.c
1535 @@ -0,0 +1,53 @@
1536 +/* Make sure trailing whitespace is handled properly BZ #17273.
1537 +
1538 +   Copyright (C) 2009-2015 Free Software Foundation, Inc.
1539 +   This file is part of the GNU C Library.
1540 +
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.
1545 +
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.
1550 +
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/>.  */
1554 +
1555 +#include <mntent.h>
1556 +#include <stdio.h>
1557 +#include <string.h>
1558 +
1559 +/* Check entries to make sure trailing whitespace is ignored and we return the
1560 +   correct passno value BZ #17273.  */
1561 +static int
1562 +do_test (void)
1563 +{
1564 +  int result = 0;
1565 +  FILE *fp;
1566 +  struct mntent *mnt;
1567 +
1568 +  fp = tmpfile ();
1569 +  fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1570 +  rewind (fp);
1571 +
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)
1579 +    {
1580 +      puts ("Error while reading entry with trailing whitespaces");
1581 +      result = 1;
1582 +    }
1583 +
1584 +  return result;
1585 +}
1586 +
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");
1595           result = 1;
1596         }
1597 -
1598 -      /* Part III: Entry with whitespaces at the end of a line. */
1599 -      rewind (fp);
1600 -
1601 -      fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1602 -
1603 -      rewind (fp);
1604 -
1605 -      mnt = getmntent (fp);
1606 -
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)
1613 -       {
1614 -         puts ("Error while reading entry with trailing whitespaces");
1615 -         result = 1;
1616 -       }
1617     }
1618  
1619    return result;
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.
1626  if ($#ARGV == -1) {
1627      $soversions="soversions.mk";
1628 +    $config="config.make";
1629  } elsif ($#ARGV == 0) {
1630      if (-d $ARGV[0]) {
1631        $soversions = "$ARGV[0]/soversions.mk";
1632 +      $config = "$ARGV[0]/config.make";
1633      } else {
1634 -      $soversions = $ARGV[0];
1635 +      $soversions = $dir = $ARGV[0];
1636 +      $dir =~ s!/?[^/]*/*$!!;
1637 +      $config = $dir . "/config.make";
1638      }
1639  } else {
1640      die "Wrong number of arguments.";
1641  }
1642  
1643 +if (system ("grep -q \"build-mathvec = yes\" $config") == 0) {
1644 +    $build_mathvec = 1;
1645 +} else {
1646 +    $build_mathvec = 0;
1647 +}
1648  
1649  # Read names and versions of all shared libraries that are part of
1650  # glibc
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;
1665  int
1666  __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
1667  {
1668 +#ifdef PTR_MANGLE
1669 +  PTR_MANGLE (func);
1670 +#endif
1671 +
1672    /* Prepend.  */
1673    struct dtor_list *new = calloc (1, sizeof (struct dtor_list));
1674    new->func = func;
1675 @@ -142,9 +146,13 @@ __call_tls_dtors (void)
1676    while (tls_dtor_list)
1677      {
1678        struct dtor_list *cur = tls_dtor_list;
1679 +      dtor_func func = cur->func;
1680 +#ifdef PTR_DEMANGLE
1681 +      PTR_DEMANGLE (func);
1682 +#endif
1683  
1684        tls_dtor_list = tls_dtor_list->next;
1685 -      cur->func (cur->obj);
1686 +      func (cur->obj);
1687  
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           \
1698 -                  tst-strtok_r
1699 +                  tst-strtok_r bug-strcoll2
1700  
1701  xtests = tst-strcoll-overflow
1702  
1703 @@ -75,4 +75,17 @@ ifeq ($(run-built-tests),yes)
1704  $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
1705         cmp $^ > $@; \
1706         $(evaluate-test)
1707 +
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 \
1710 +          da_DK.ISO-8859-1
1711 +include ../gen-locales.mk
1712 +
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)
1719 +
1720  endif
1721 diff --git a/string/bug-strcoll2.c b/string/bug-strcoll2.c
1722 new file mode 100644
1723 index 0000000..72a9ff2
1724 --- /dev/null
1725 +++ b/string/bug-strcoll2.c
1726 @@ -0,0 +1,92 @@
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.
1730 +
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.
1735 +
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.
1740 +
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/>.  */
1744 +
1745 +#include <stdio.h>
1746 +#include <string.h>
1747 +#include <locale.h>
1748 +
1749 +/* An incorrect strcoll optimization resulted in incorrect
1750 +   results from strcoll for cs_CZ and da_DK.  */
1751 +
1752 +int
1753 +test_cs_CZ (void)
1754 +{
1755 +  const char t1[] = "config";
1756 +  const char t2[] = "choose";
1757 +  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
1758 +    {
1759 +      perror ("setlocale");
1760 +      return 1;
1761 +    }
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)
1769 +    {
1770 +      puts ("PASS: config < choose");
1771 +      return 0;
1772 +    }
1773 +  else
1774 +    {
1775 +      puts ("FAIL: Wrong sorting in cs_CZ.UTF-8.");
1776 +      return 1;
1777 +    }
1778 +}
1779 +
1780 +int
1781 +test_da_DK (void)
1782 +{
1783 +  const char t1[] = "AS";
1784 +  const char t2[] = "AA";
1785 +  if (setlocale (LC_ALL, "da_DK.ISO-8859-1") == NULL)
1786 +    {
1787 +      perror ("setlocale");
1788 +      return 1;
1789 +    }
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)
1797 +    {
1798 +      puts ("PASS: AS < AA");
1799 +      return 0;
1800 +    }
1801 +  else
1802 +    {
1803 +      puts ("FAIL: Wrong sorting in da_DK.ISO-8859-1");
1804 +      return 1;
1805 +    }
1806 +}
1807 +
1808 +static int
1809 +do_test (void)
1810 +{
1811 +  int err = 0;
1812 +  err |= test_cs_CZ ();
1813 +  err |= test_da_DK ();
1814 +  return err;
1815 +}
1816 +
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
1823 @@ -29,7 +29,6 @@
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"
1830  # define SUFFIX        MB
1831 @@ -42,20 +41,6 @@
1832  #include "../locale/localeinfo.h"
1833  #include WEIGHT_H
1834  
1835 -#define MASK_UTF8_7BIT  (1 << 7)
1836 -#define MASK_UTF8_START (3 << 6)
1837 -
1838 -size_t
1839 -STRDIFF (const STRING_TYPE *s, const STRING_TYPE *t)
1840 -{
1841 -  size_t n;
1842 -
1843 -  for (n = 0; *s != '\0' && *s++ == *t++; ++n)
1844 -    continue;
1845 -
1846 -  return n;
1847 -}
1848 -
1849  /* Track status while looking for sequences in a string.  */
1850  typedef struct
1851  {
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;
1855  
1856 -  /* In case there is no locale specific sort order (C / POSIX).  */
1857    if (nrules == 0)
1858      return STRCMP (s1, s2);
1859  
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)
1866 -    {
1867 -      size_t diff = STRDIFF (s1, s2);
1868 -      if (diff > 0)
1869 -       {
1870 -         if (encoding == __cet_utf8 && (*(s1 + diff) & MASK_UTF8_7BIT) != 0)
1871 -           do
1872 -             diff--;
1873 -           while (diff > 0 && (*(s1 + diff) & MASK_UTF8_START) != MASK_UTF8_START);
1874 -         s1 += diff;
1875 -         s2 += diff;
1876 -       }
1877 -    }
1878 -
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)
1889                     return result;
1890                   else
1891                     break;
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
1896 @@ -5,6 +5,8 @@
1897  static int
1898  do_test (void)
1899  {
1900 +  static const char test_locale[] = "de_DE.UTF-8";
1901 +
1902    int res = 0;
1903  
1904    char buf[20];
1905 @@ -38,9 +40,9 @@ do_test (void)
1906        res = 1;
1907      }
1908  
1909 -  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
1910 +  if (setlocale (LC_ALL, test_locale) == NULL)
1911      {
1912 -      puts ("setlocale failed");
1913 +      printf ("cannot set locale \"%s\"\n", test_locale);
1914        res = 1;
1915      }
1916    else
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;
1925 -
1926 -  /* 0 if internal pointer values should not be guarded, 1 if they should.  */
1927 -  EXTERN int _dl_pointer_guard;
1928  };
1929  # define __rtld_global_attribute__
1930  # if IS_IN (rtld)
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)
1936    else
1937      return (void *) value;
1938  }
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
1944 @@ -42,7 +42,11 @@
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.  */
1948 -       .section        .rodata
1949 +#ifdef SHARED
1950 +       .section        .data.rel.ro,"aw",@progbits
1951 +#else
1952 +       .section        .rodata,"a",@progbits
1953 +#endif
1954         .align 4
1955  .Lpmain:
1956         .word P%main
1957 @@ -52,6 +56,10 @@
1958         .word P%__libc_csu_fini
1959  .Lp__libc_csu_init:
1960         .word P%__libc_csu_init
1961 +#ifdef SHARED
1962 +.Lp__global:
1963 +       .word $global$
1964 +#endif
1965  
1966         .text
1967         .align 4
1968 @@ -122,10 +130,14 @@ _start:
1969         /* void *stack_end (7th argument) */
1970         stw     %sp, -60(%sp)
1971  
1972 +#ifdef SHARED
1973 +       addil   LT'.Lp__global, %r19
1974 +       ldw     RT'.Lp__global(%r1), %dp
1975 +#else
1976         /* load global */
1977         ldil    L%$global$, %dp
1978         ldo     R%$global$(%dp), %dp
1979 -
1980 +#endif
1981         bl      __libc_start_main,%r2
1982         nop
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
1990  # install it.
1991  sysdep_headers += bits/mman-linux.h
1992 +
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)
2001  endif
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)
2009  {
2010 -  if (__builtin_expect (type, ET_DYN) == ET_DYN)
2011 +  if (__glibc_likely (type == ET_DYN))
2012      {
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,
2016                     errno = error;
2017                     return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
2018                   }
2019 +                if (__glibc_unlikely (type != ET_DYN))
2020 +                  {
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
2027 +                       bookkeeping.  */
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))
2032 +                      {
2033 +                        errno = error;
2034 +                        return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
2035 +                      }
2036 +                    if (__glibc_unlikely
2037 +                        (allocated_address != l->l_addr + c->mapstart))
2038 +                      {
2039 +                        /* This is not a very helpful error for this case,
2040 +                           but there isn't really anything better to use.  */
2041 +                        errno = ENOMEM;
2042 +                        return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
2043 +                      }
2044 +                  }
2045               }
2046             else
2047               {
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
2051 --- /dev/null
2052 +++ b/sysdeps/nacl/dl-sysdep-open.h
2053 @@ -0,0 +1,40 @@
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.
2057 +
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.
2062 +
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.
2067 +
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/>.  */
2071 +
2072 +#ifndef _DL_SYSDEP_OPEN_H
2073 +#define _DL_SYSDEP_OPEN_H      1
2074 +
2075 +#include <stddef.h>
2076 +
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).
2079 +
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).  */
2089 +
2090 +extern char *_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
2091 +  internal_function attribute_hidden;
2092 +
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[])
2099  #endif  /* SHARED */
2100  
2101  #include <elf/dl-sysdep.c>
2102 +
2103 +#include <dl-sysdep-open.h>
2104 +#include <nacl-interfaces.h>
2105 +#include <assert.h>
2106 +#include <string.h>
2107 +#include <unistd.h>
2108 +
2109 +char *
2110 +internal_function
2111 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
2112 +{
2113 +  int error = __nacl_irt_resource_open.open_resource (name, fd);
2114 +  if (error)
2115 +    return NULL;
2116 +  assert (*fd != -1);
2117 +  char *realname = __strdup (name);
2118 +  if (__glibc_unlikely (realname == NULL))
2119 +    {
2120 +      __close (*fd);
2121 +      *fd = -1;
2122 +    }
2123 +  return realname;
2124 +}
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
2142 @@ -44,6 +44,10 @@
2143  /* The application defines this, of course.  */
2144  extern int main (int argc, char **argv, char **envp);
2145  
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));
2149 +
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[])
2154  {
2155    /* The generic code actually assumes that envp follows argv.  */
2156  
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 ();
2168  
2169    /* We can skip the expensive `stat' call if O_DIRECTORY works.  */
2170 -  return o_directory_works > 0;
2171 +  return o_directory_works < 0;
2172  #endif
2173    return true;
2174  }
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
2179 @@ -23,67 +23,78 @@
2180  # include <htm.h>
2181  # include <elision-conf.h>
2182  
2183 -/* Returns true if the lock defined by is_lock_free as elided.
2184 -   ADAPT_COUNT is a pointer to per-lock state variable. */
2185 -
2186 +/* Get the new value of adapt_count according to the elision
2187 +   configurations.  Returns true if the system should retry again or false
2188 +   otherwise.  */
2189  static inline bool
2190 -__elide_lock (uint8_t *adapt_count, int is_lock_free)
2191 +__get_new_count (uint8_t *adapt_count, int attempt)
2192  {
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 ()))
2198      {
2199 -      (*adapt_count)--;
2200 +      if (__elision_aconf.skip_lock_internal_abort > 0)
2201 +       *adapt_count = __elision_aconf.skip_lock_internal_abort;
2202        return false;
2203      }
2204 -
2205 -  for (int i = __elision_aconf.try_tbegin; i > 0; i--)
2206 -    {
2207 -      if (__builtin_tbegin (0))
2208 -       {
2209 -         if (is_lock_free)
2210 -           return true;
2211 -         /* Lock was busy.  */
2212 -         __builtin_tabort (_ABORT_LOCK_BUSY);
2213 -       }
2214 -      else
2215 -       {
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 ()))
2220 -           {
2221 -             if (__elision_aconf.skip_lock_internal_abort > 0)
2222 -               *adapt_count = __elision_aconf.skip_lock_internal_abort;
2223 -             break;
2224 -           }
2225 -         /* Same logic as above, but for a number of temporary failures in a
2226 -            a row.  */
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;
2230 -       }
2231 -     }
2232 -
2233 -  return false;
2234 +  /* Same logic as above, but for a number of temporary failures in a
2235 +     a row.  */
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;
2239 +  return true;
2240  }
2241  
2242 -# define ELIDE_LOCK(adapt_count, is_lock_free) \
2243 -  __elide_lock (&(adapt_count), is_lock_free)
2244 -
2245 -
2246 -static inline bool
2247 -__elide_trylock (uint8_t *adapt_count, int is_lock_free, int write)
2248 -{
2249 -  if (__elision_aconf.try_tbegin > 0)
2250 -    {
2251 -      if (write)
2252 -       __builtin_tabort (_ABORT_NESTED_TRYLOCK);
2253 -      return __elide_lock (adapt_count, is_lock_free);
2254 -    }
2255 -  return false;
2256 -}
2257 +/* CONCURRENCY NOTES:
2258 +
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.  */
2268 +
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)                         \
2272 +  ({                                                                   \
2273 +    int ret = 0;                                                       \
2274 +    if (adapt_count > 0)                                               \
2275 +      (adapt_count)--;                                                 \
2276 +    else                                                               \
2277 +      for (int i = __elision_aconf.try_tbegin; i > 0; i--)             \
2278 +       {                                                               \
2279 +         if (__builtin_tbegin (0))                                     \
2280 +           {                                                           \
2281 +             if (is_lock_free)                                         \
2282 +               {                                                       \
2283 +                 ret = 1;                                              \
2284 +                 break;                                                \
2285 +               }                                                       \
2286 +             __builtin_tabort (_ABORT_LOCK_BUSY);                      \
2287 +           }                                                           \
2288 +         else                                                          \
2289 +           if (!__get_new_count (&adapt_count,i))                      \
2290 +             break;                                                    \
2291 +       }                                                               \
2292 +    ret;                                                               \
2293 +  })
2294  
2295  # define ELIDE_TRYLOCK(adapt_count, is_lock_free, write)       \
2296 -  __elide_trylock (&(adapt_count), is_lock_free, write)
2297 +  ({                                                           \
2298 +    int ret = 0;                                               \
2299 +    if (__elision_aconf.try_tbegin > 0)                                \
2300 +      {                                                                \
2301 +       if (write)                                              \
2302 +         __builtin_tabort (_ABORT_NESTED_TRYLOCK);             \
2303 +       ret = ELIDE_LOCK (adapt_count, is_lock_free);           \
2304 +      }                                                                \
2305 +    ret;                                                       \
2306 +  })
2307  
2308  
2309  static inline bool
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
2314 @@ -29,6 +29,7 @@
2315  #include <sys/mman.h>
2316  #include <sys/stat.h>
2317  #include "semaphoreP.h"
2318 +#include <futex-internal.h>
2319  #include <shm-directory.h>
2320  
2321  
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
2327  GLIBC_2.18
2328   GLIBC_2.18 A
2329   __cxa_thread_atexit_impl F
2330 -GLIBC_2.22
2331 - GLIBC_2.22 A
2332 - fmemopen F
2333  GLIBC_2.2
2334   GLIBC_2.2 A
2335   _IO_adjust_wcolumn F
2336 @@ -2015,6 +2012,9 @@ GLIBC_2.2.4
2337  GLIBC_2.2.6
2338   GLIBC_2.2.6 A
2339   __nanosleep F
2340 +GLIBC_2.22
2341 + GLIBC_2.22 A
2342 + fmemopen F
2343  GLIBC_2.3
2344   GLIBC_2.3 A
2345   __ctype_b_loc F
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;
2351  #define _LWS "0xb0"
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"
2360  
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)      \
2366    ({                                                                   \
2367 -     volatile int lws_errno;                                           \
2368 -     __typeof__ (*mem) lws_ret;                                                \
2369 -     asm volatile(                                                     \
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__(                                             \
2376         "0:                                     \n\t"                   \
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"                   \
2386         "nop                                    \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"                   \
2391         "nop                                    \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)                   \
2398         : _LWS_CLOBBER                                                  \
2399       );                                                                        \
2400                                                                         \
2401 -     if(lws_errno == -EFAULT || lws_errno == -ENOSYS)                  \
2402 +     if (lws_errno == -EFAULT || lws_errno == -ENOSYS)                 \
2403         ABORT_INSTRUCTION;                                              \
2404                                                                         \
2405 -     lws_ret;                                                          \
2406 +     (__typeof (oldval)) lws_ret;                                      \
2407     })
2408  
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
2415  GLIBC_2.19
2416   GLIBC_2.19 A
2417   fanotify_mark F
2418 -GLIBC_2.22
2419 - GLIBC_2.22 A
2420 - fmemopen F
2421  GLIBC_2.2
2422   GLIBC_2.2 A
2423   _Exit F
2424 @@ -1863,6 +1860,9 @@ GLIBC_2.2.4
2425  GLIBC_2.2.6
2426   GLIBC_2.2.6 A
2427   __nanosleep F
2428 +GLIBC_2.22
2429 + GLIBC_2.22 A
2430 + fmemopen F
2431  GLIBC_2.3
2432   GLIBC_2.3 A
2433   __ctype_b_loc F
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, ...)
2439    va_end (args);
2440  
2441    {
2442 +    LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
2443      register unsigned long int __res asm("r28");
2444      PIC_REG_DEF
2445 -    LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
2446 +    LOAD_REGS_6
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    \
2455  ({                                                                     \
2456         long __sys_res;                                                 \
2457         {                                                               \
2458 +               LOAD_ARGS_##nr(args)                                    \
2459                 register unsigned long __res asm("r28");                \
2460                 PIC_REG_DEF                                             \
2461 -               LOAD_ARGS_##nr(args)                                    \
2462 +               LOAD_REGS_##nr                                          \
2463                 /* FIXME: HACK save/load r19 around syscall */          \
2464                 asm volatile(                                           \
2465                         SAVE_ASM_PIC                                    \
2466 @@ -425,9 +426,10 @@ L(pre_end):                                        ASM_LINE_SEP    \
2467  ({                                                                     \
2468         long __sys_res;                                                 \
2469         {                                                               \
2470 +               LOAD_ARGS_##nr(args)                                    \
2471                 register unsigned long __res asm("r28");                \
2472                 PIC_REG_DEF                                             \
2473 -               LOAD_ARGS_##nr(args)                                    \
2474 +               LOAD_REGS_##nr                                          \
2475                 /* FIXME: HACK save/load r19 around syscall */          \
2476                 asm volatile(                                           \
2477                         SAVE_ASM_PIC                                    \
2478 @@ -443,27 +445,44 @@ L(pre_end):                                       ASM_LINE_SEP    \
2479         __sys_res;                                                      \
2480   })
2481  
2482 -
2483 -
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);                  \
2490    LOAD_ARGS_0()
2491 -#define LOAD_ARGS_2(r26,r25)                                           \
2492 -  register unsigned long __r25 __asm__("r25") = (unsigned long)(r25);  \
2493 -  LOAD_ARGS_1(r26)
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;                 \
2508 +  LOAD_REGS_0
2509 +#define LOAD_ARGS_2(a1,a2)                                             \
2510 +  register unsigned long __x25 = (unsigned long)(a2);                  \
2511 +  LOAD_ARGS_1(a1)
2512 +#define LOAD_REGS_2                                                    \
2513 +  register unsigned long __r25 __asm__("r25") = __x25;                 \
2514 +  LOAD_REGS_1
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;                 \
2520 +  LOAD_REGS_2
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;                 \
2526 +  LOAD_REGS_3
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;                 \
2532 +  LOAD_REGS_4
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;                 \
2538 +  LOAD_REGS_5
2539  
2540  /* Even with zero args we use r20 for the syscall number */
2541  #define ASM_ARGS_0
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
2546 @@ -16,8 +16,11 @@
2547     License along with the GNU C Library; if not, see
2548     <http://www.gnu.org/licenses/>.  */
2549  
2550 +#ifndef _LINUX_MICROBLAZE_SYSDEP_H
2551 +#define _LINUX_MICROBLAZE_SYSDEP_H 1
2552 +
2553 +#include <sysdeps/unix/sysdep.h>
2554  #include <sysdeps/microblaze/sysdep.h>
2555 -#include <sys/syscall.h>
2556  
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)
2561  
2562  #endif /* not __ASSEMBLER__ */
2563 +
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, ...)
2570        va_end (arg);
2571      }
2572  
2573 +  /* We have to add the O_LARGEFILE flag for openat64.  */
2574 +#ifdef MORE_OFLAGS
2575 +  oflag |= MORE_OFLAGS;
2576 +#endif
2577 +
2578    return SYSCALL_CANCEL (openat, fd, file, oflag, mode);
2579  }
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)
2586        goto use_lock;
2587      }
2588  
2589 -  int try_begin = aconf.try_tbegin;
2590 -  while (1)
2591 +  for (int i = aconf.try_tbegin; i > 0; i--)
2592      {
2593        if (__builtin_tbegin (0))
2594         {
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 ()))
2602             {
2603               if (aconf.skip_lock_internal_abort > 0)
2604                 *adapt_count = aconf.skip_lock_internal_abort;
2605               goto use_lock;
2606             }
2607 -         /* Same logic as above, but for for a number of temporary failures
2608 -            in a row.  */
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;
2612         }
2613       }
2614  
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;
2618 +
2619  use_lock:
2620    return LLL_LOCK ((*lock), pshared);
2621  }
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
2626 @@ -53,34 +53,5 @@
2627  #  undef __DECL_SIMD_powf
2628  #  define __DECL_SIMD_powf __DECL_SIMD_x86_64
2629  
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");
2658 -
2659  # endif
2660  #endif
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 \
2671 +                  svml_finite_alias
2672 +
2673 +libmvec-static-only-routines = svml_finite_alias
2674  endif
2675  
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
2680 --- /dev/null
2681 +++ b/sysdeps/x86_64/fpu/svml_finite_alias.S
2682 @@ -0,0 +1,59 @@
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.
2689 +
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.
2694 +
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.
2699 +
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/>.  */
2703 +
2704 +#include <sysdep.h>
2705 +
2706 +#define ALIAS_IMPL(alias, target) \
2707 +ENTRY (alias); \
2708 +       call target; \
2709 +       ret; \
2710 +END (alias)
2711 +
2712 +       .text
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)
2717 +
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)
2722 +
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)
2727 +
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)
2732 +
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)
2737 +
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.  */
2749  # define a_wkday \
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)))
2753  # define f_wkday \
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)))
2757  # define a_month \
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)))
2761  # define f_month \
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)))
2765  # define ampm \
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)
2770  #else
2771  # if !HAVE_STRFTIME
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;
2783                 }
2784  # endif
2785 -             zone = tzname[tp->tm_isdst];
2786 +             zone = tp->tm_isdst <= 1 ? tzname[tp->tm_isdst] : "?";
2787             }
2788  #endif
2789           if (! zone)
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
2794 @@ -4,6 +4,56 @@
2795  #include <time.h>
2796  
2797  
2798 +static int
2799 +do_bz18985 (void)
2800 +{
2801 +  char buf[1000];
2802 +  struct tm ttm;
2803 +  int rc, ret = 0;
2804 +
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);
2808 +
2809 +  if (rc == 66)
2810 +    {
2811 +      const char expected[]
2812 +       = "? ? ? ? ? ? 16843009 16843009:16843009:16843009 16844909 +467836 ?";
2813 +      if (0 != strcmp (buf, expected))
2814 +       {
2815 +         printf ("expected:\n  %s\ngot:\n  %s\n", expected, buf);
2816 +         ret += 1;
2817 +       }
2818 +    }
2819 +  else
2820 +    {
2821 +      printf ("expected 66, got %d\n", rc);
2822 +      ret += 1;
2823 +    }
2824 +
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);
2829 +
2830 +  if (rc == 30)
2831 +    {
2832 +      const char expected[] = "? ? ? ? ? ? -1 -1:-1:-1 1899  ";
2833 +      if (0 != strcmp (buf, expected))
2834 +       {
2835 +         printf ("expected:\n  %s\ngot:\n  %s\n", expected, buf);
2836 +         ret += 1;
2837 +       }
2838 +    }
2839 +  else
2840 +    {
2841 +      printf ("expected 30, got %d\n", rc);
2842 +      ret += 1;
2843 +    }
2844 +
2845 +  return ret;
2846 +}
2847 +
2848  static struct
2849  {
2850    const char *fmt;
2851 @@ -104,7 +154,7 @@ do_test (void)
2852         }
2853      }
2854  
2855 -  return result;
2856 +  return result + do_bz18985 ();
2857  }
2858  
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
2864 @@ -23,7 +23,6 @@
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"
2871  #define SUFFIX WC
This page took 1.107224 seconds and 4 git commands to generate.