]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-git.patch
- branch diff update; glibc-graceful-locale.patch now part of upstream
[packages/glibc.git] / glibc-git.patch
1 diff --git a/ChangeLog b/ChangeLog
2 index cb9124e..9740c89 100644
3 --- a/ChangeLog
4 +++ b/ChangeLog
5 @@ -1,3 +1,296 @@
6 +2015-10-27  Ludovic Courtès  <ludo@gnu.org>
7 +
8 +       * locale/loadlocale.c (_nl_intern_locale_data): Change assertion
9 +       on CNT to a conditional jump to 'puntdata'.
10 +
11 +2015-08-18  Alan Modra  <amodra@gmail.com>
12 +
13 +       [BZ #18421]
14 +       * sysdeps/hppa/start.S [SHARED]: Use .section .data.rel.ro and define
15 +       .Lp__global.
16 +       (_start): Load %dp via .Lp__global.
17 +       [!SHARED]: Use .section .rodata.
18 +
19 +2015-08-09  John David Anglin  <danglin@gcc.gnu.org>
20 +
21 +       [BZ #18480]
22 +       * sysdeps/unix/sysv/linux/hppa/sysdep.h (LOAD_ARGS_0, LOAD_ARGS_1,
23 +       LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4, LOAD_ARGS_5, LOAD_ARGS_6):
24 +       Define.
25 +       (LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4,
26 +       LOAD_REGS_5, LOAD_REGS_6): Update.
27 +       (INTERNAL_SYSCALL): Update using new LOAD defines.
28 +       (INTERNAL_SYSCALL_NCS): Likewise.
29 +       * sysdeps/unix/sysv/linux/hppa/syscall.c (syscall): Likewise.
30 +
31 +2015-09-26  Paul Pluzhnikov  <ppluzhnikov@google.com>
32 +
33 +       [BZ #18985]
34 +       * time/strftime_l.c (a_wkday, f_wkday, a_month, f_month): Range check.
35 +       (__strftime_internal): Likewise.
36 +       * time/tst-strftime.c (do_bz18985): New test.
37 +       (do_test): Call it.
38 +
39 +2015-08-08  Paul Pluzhnikov  <ppluzhnikov@google.com>
40 +
41 +       [BZ #17905]
42 +       * catgets/Makefile (tst-catgets-mem): New test.
43 +       * catgets/catgets.c (catopen): Don't use unbounded alloca.
44 +       * catgets/open_catalog.c (__open_catalog): Likewise.
45 +       * catgets/tst-catgets.c (do_bz17905): Test unbounded alloca.
46 +
47 +2015-12-31  Aurelien Jarno  <aurelien@aurel32.net>
48 +
49 +       * sysdeps/unix/sysv/linux/alpha/libc.abilist [GLIBC_2.22]: Move
50 +       to keep the file sorted.
51 +       * sysdeps/unix/sysv/linux/hppa/libc.abilist [GLIBC_2.22]: Likewise.
52 +
53 +2015-12-17  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
54 +
55 +       [BZ #19174]
56 +       * sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of
57 +       .skip_lock_out_of_tbegin_retries.
58 +       * sysdeps/unix/sysv/linux/powerpc/elision-lock.c
59 +       (__lll_lock_elision): Likewise, and respect a value of
60 +       try_tbegin <= 0.
61 +
62 +2015-12-03  Andrew Senkevich  <andrew.senkevich@intel.com>
63 +
64 +       * math/Makefile ($(inst_libdir)/libm.so): Corrected path to
65 +       libmvec_nonshared.a
66 +
67 +2015-11-27  Andrew Senkevich  <andrew.senkevich@intel.com>
68 +
69 +       [BZ #19058]
70 +       * math/Makefile ($(inst_libdir)/libm.so): Added libmvec_nonshared.a to
71 +       AS_NEEDED.
72 +       * sysdeps/x86/fpu/bits/math-vector.h: Removed code with asm aliases
73 +       workaround.
74 +       * sysdeps/x86_64/fpu/Makefile (libmvec-support,
75 +       libmvec-static-only-routines): Added new file.
76 +       * sysdeps/x86_64/fpu/svml_finite_alias.S: New file.
77 +       * NEWS: Mention this fix.
78 +
79 +2015-11-20  Roland McGrath  <roland@hack.frob.com>
80 +
81 +       * sysdeps/nacl/dl-map-segments.h (_dl_map_segments): Use
82 +       __glibc_likely instead of __builtin_expect.  After falling back to
83 +       dyncode_create in a non-ET_DYN case, use the allocate_code_data
84 +       system interface to register the code pages as occupied.
85 +
86 +2015-11-14  H.J. Lu  <hongjiu.lu@intel.com>
87 +
88 +       * config.make.in (have-glob-dat-reloc): New.
89 +       * configure.ac (libc_cv_has_glob_dat): New.  Set to yes if
90 +       target supports GLOB_DAT relocaton. AC_SUBST.
91 +       * configure: Regenerated.
92 +       * elf/Makefile (tests): Add tst-prelink.
93 +       (tests-special): Add $(objpfx)tst-prelink-cmp.out.
94 +       (tst-prelink-ENV): New.
95 +       ($(objpfx)tst-prelink-conflict.out): Likewise.
96 +       ($(objpfx)tst-prelink-cmp.out): Likewise.
97 +       * sysdeps/x86/tst-prelink.c: Moved to ...
98 +       * elf/tst-prelink.c: Here.
99 +       * sysdeps/x86/tst-prelink.exp: Moved to ...
100 +       * elf/tst-prelink.exp: Here.
101 +       * sysdeps/x86/Makefile (tests): Don't add tst-prelink.
102 +       (tst-prelink-ENV): Removed.
103 +       ($(objpfx)tst-prelink-conflict.out): Likewise.
104 +       ($(objpfx)tst-prelink-cmp.out): Likewise.
105 +       (tests-special): Don't add $(objpfx)tst-prelink-cmp.out.
106 +
107 +2015-11-10  Roland McGrath  <roland@hack.frob.com>
108 +
109 +       * elf/dl-load.c (open_verify): Take new argument FD.
110 +       Skip __open call if passed FD is not -1.
111 +       (_dl_map_object, open_path): Update callers.
112 +       * elf/dl-sysdep-open.h: New file.
113 +       * elf/dl-load.c: Include it.
114 +       (_dl_map_object): Try _dl_sysdep_open_object before ldconfig cache.
115 +       * sysdeps/nacl/dl-sysdep.c (_dl_sysdep_open_object): New function.
116 +       * sysdeps/nacl/dl-sysdep-open.h: New file.
117 +       * sysdeps/nacl/nacl-interface-list.h: Move nacl_irt_resource_open
118 +       from libc to rtld.
119 +
120 +2015-11-10  H.J. Lu  <hongjiu.lu@intel.com>
121 +
122 +       [BZ #19178]
123 +       * sysdeps/x86/Makefile (tests): Add tst-prelink.
124 +       (tst-prelink-ENV): New.
125 +       ($(objpfx)tst-prelink-conflict.out): Likewise.
126 +       ($(objpfx)tst-prelink-cmp.out): Likewise.
127 +       (tests-special): Add $(objpfx)tst-prelink-cmp.out.
128 +       * sysdeps/x86/tst-prelink.c: New file.
129 +       * sysdeps/x86/tst-prelink.exp: Likewise.
130 +
131 +2015-11-07  H.J. Lu  <hongjiu.lu@intel.com>
132 +
133 +       [BZ #19178]
134 +       * elf/dl-lookup.c (RTYPE_CLASS_VALID): New.
135 +       (RTYPE_CLASS_PLT): Likewise.
136 +       (RTYPE_CLASS_COPY): Likewise.
137 +       (RTYPE_CLASS_TLS): Likewise.
138 +       (_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID
139 +       to set relocation type class for DL_DEBUG_PRELINK.  Keep only
140 +       ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY bits for
141 +       DL_DEBUG_PRELINK.
142 +
143 +2015-10-20  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
144 +
145 +       [BZ #18743]
146 +       * sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
147 +       code to...
148 +       (ELIDE_LOCK): ...here.
149 +       (__get_new_count): New function with part of the code from
150 +       __elide_lock that updates the value of adapt_count after a
151 +       transaction abort.
152 +       (__elided_trylock): Moved this code to...
153 +       (ELIDE_TRYLOCK): ...here.
154 +
155 +2015-10-06  Florian Weimer  <fweimer@redhat.com>
156 +
157 +       [BZ #19018]
158 +       * stdlib/cxa_thread_atexit_impl.c (__cxa_thread_atexit_impl):
159 +       Mangle function pointer before storing it.
160 +       (__call_tls_dtors): Demangle function pointer before calling it.
161 +
162 +2015-10-15  Florian Weimer  <fweimer@redhat.com>
163 +
164 +       [BZ #18928]
165 +       * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
166 +       _dl_pointer_guard member.
167 +       * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
168 +       initializer.
169 +       (security_init): Always set up pointer guard.
170 +       (process_envvars): Do not process LD_POINTER_GUARD.
171 +
172 +2015-10-09  Carlos O'Donell  <carlos@redhat.com>
173 +
174 +       [BZ #18589]
175 +       * string/bug-strcoll2.c: Adjust copyright, and remove contributed by.
176 +       * string/Makefile ($(objpfx)bug-strcoll2.out): Depend on
177 +       $(gen-locales).
178 +
179 +2015-10-08  Carlos O'Donell  <carlos@redhat.com>
180 +
181 +       [BZ #18589]
182 +       * string/Makefile (tests): Add bug-strcoll2.
183 +       (LOCALES): Add cs_CZ.UTF-8.
184 +
185 +2015-09-28  Martin Sebor  <msebor@redhat.com>
186 +
187 +       [BZ #18969]
188 +       * string/Makefile (LOCALES): Define.
189 +       (gen-locales.mk): Include.
190 +       (test-strcasecmp.out, test-strncasecmp.out, tst-strxfrm.out)
191 +       (tst-strxfrm2.out): Add deppendency on $(gen-locales).
192 +       * string/tst-strxfrm2.c (do_test): Print the name of the locale
193 +       on setlocale failure.
194 +
195 +2015-10-08  Carlos O'Donell  <carlos@redhat.com>
196 +
197 +       [BZ #18589]
198 +       * string/bug-strcoll2.c: New file.
199 +       * locale/categories.def: Revert commit
200 +       f13c2a8dff2329c6692a80176262ceaaf8a6f74e.
201 +       * locale/langinfo.h: Likewise.
202 +       * locale/localeinfo.h: Likewise.
203 +       * locale/C-collate.c: Likewise.
204 +       * programs/ld-collate.c (collate_output): Likewise.
205 +       * string/strcoll_l.c (STRDIFF): Likewise.
206 +       (STRCOLL): Likewise.
207 +       * wcsmbs/wcscoll_l.c: Likewise.
208 +
209 +2015-09-15  Roland McGrath  <roland@hack.frob.com>
210 +
211 +       * misc/sys/param.h [!MAXHOSTNAMELEN && HOST_NAME_MAX]
212 +       (MAXHOSTNAMELEN): Define it to HOST_NAME_MAX.
213 +
214 +2015-09-11  Roland McGrath  <roland@hack.frob.com>
215 +
216 +       * sysdeps/nacl/Makefile [$(subdir) = misc] (sysdep_headers):
217 +       Use 'override' keyword to freeze the value here, preventing
218 +       the addition of sys/mtio.h by sysdeps/gnu/Makefile.
219 +
220 +2015-09-04  Roland McGrath  <roland@hack.frob.com>
221 +
222 +       [BZ #18921]
223 +       * sysdeps/posix/opendir.c (need_isdir_precheck) [O_DIRECTORY]:
224 +       Fix inverted sense of test of 'o_directory_works' value.
225 +       Reported by Pádraig Brady <P@draigBrady.com>, diagnosed by
226 +       Bernhard Voelker <mail@bernhard-voelker.de>.
227 +
228 +2015-08-31  Brett Neumeier <brett@neumeier.us>
229 +
230 +       [BZ #18870]
231 +       * sysdeps/sparc/sparc32/sem_open.c: Add missing #include
232 +
233 +2015-08-28  Mike Frysinger  <vapier@gentoo.org>
234 +
235 +       [BZ #18887]
236 +       * misc/Makefile (tests): Add tst-mntent-blank-corrupt and
237 +       tst-mntent-blank-passno.
238 +       * misc/mntent_r.c (__getmntent_r): Do not read past buffer[0].
239 +       * misc/tst-mntent-blank-corrupt.c: New test.
240 +       * misc/tst-mntent-blank-passno.c: New test ripped from ...
241 +       * misc/tst-mntent.c (do_test): ... here.
242 +
243 +2015-08-25  Roland McGrath  <roland@hack.frob.com>
244 +
245 +       * sysdeps/nacl/start.c (_start): Call __nacl_main instead of main
246 +       if the weak reference is not null.
247 +
248 +2015-08-19  Andrew Senkevich  <andrew.senkevich@intel.com>
249 +
250 +       [BZ #18796]
251 +       * scripts/test-installation.pl: Don't add -lmvec to build options
252 +       if libmvec wasn't built.
253 +       * NEWS: Mention this fix.
254 +
255 +2015-08-10  Maxim Ostapenko  <m.ostapenko@partner.samsung.com>
256 +
257 +       [BZ #18778]
258 +       * elf/Makefile (tests): Add Add tst-nodelete2.
259 +       (modules-names): Add tst-nodelete2mod.
260 +       (tst-nodelete2mod.so-no-z-defs): New.
261 +       ($(objpfx)tst-nodelete2): Likewise.
262 +       ($(objpfx)tst-nodelete2.out): Likewise.
263 +       (LDFLAGS-tst-nodelete2): Likewise.
264 +       * elf/dl-close.c (_dl_close_worker): Move DF_1_NODELETE clearing
265 +       out of loop through all loaded libraries.
266 +       * elf/tst-nodelete2.c: New file.
267 +       * elf/tst-nodelete2mod.c: Likewise.
268 +
269 +2015-08-10  Andreas Schwab  <schwab@suse.de>
270 +
271 +       [BZ #18781]
272 +       * sysdeps/unix/sysv/linux/openat.c (__OPENAT) [MORE_OFLAGS]: Add
273 +       MORE_OFLAGS to oflag.
274 +       * io/test-lfs.c (do_test): Test openat64.
275 +
276 +2015-08-08  John David Anglin  <danglin@gcc.gnu.org>
277 +
278 +       [BZ #18787]
279 +       * sysdeps/unix/sysv/linux/hppa/bits/atomic.h (_LWS_CLOBBER): Revise
280 +       clobber registers.
281 +       (atomic_compare_and_exchange_val_acq): Use register asms to assign
282 +       operand registers.  Use register %r20 for EAGAIN and EDEADLOCK checks.
283 +       Cast return to __typeof (oldval).
284 +
285 +2015-08-08  Mike Frysinger  <vapier@gentoo.org>
286 +
287 +       * sysdeps/unix/sysv/linux/microblaze/sysdep.h: Wrap the whole file
288 +       in _LINUX_MICROBLAZE_SYSDEP_H defines.  Include sysdeps/unix/sysdep.h
289 +       and delete sys/syscall.h include.
290 +
291 +2015-08-07  Mike Frysinger  <vapier@gentoo.org>
292 +
293 +       * sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Add rtld_hidden_def.
294 +
295 +2015-08-05  Zack Weinberg  <zackw@panix.com>
296 +
297 +       * misc/regexp.h: Update comments.
298 +
299  2015-08-05  Carlos O'Donell  <carlos@systemhalted.org>
300  
301         * version.h (RELEASE): Set to "stable".
302 diff --git a/NEWS b/NEWS
303 index 4c31de7..99e68d2 100644
304 --- a/NEWS
305 +++ b/NEWS
306 @@ -5,6 +5,16 @@ See the end for copying conditions.
307  Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
308  using `glibc' in the "product" field.
309  \f
310 +Version 2.22.1
311 +
312 +* The following bugs are resolved with this release:
313 +
314 +  17905, 18421, 18480, 18589, 18743, 18778, 18781, 18787, 18796, 18870,
315 +  18887, 18921, 18928, 18969, 18985, 19018, 19058, 19174, 19178.
316 +
317 +* The LD_POINTER_GUARD environment variable can no longer be used to
318 +  disable the pointer guard feature.  It is always enabled.
319 +\f
320  Version 2.22
321  
322  * The following bugs are resolved with this release:
323 @@ -84,7 +94,7 @@ Version 2.22
324    release.  Use of this header will trigger a deprecation warning.
325    Application developers should update their code to use <regex.h> instead.
326  
327 -  This header was formerly part of SUSv2, but was deprecated in 1997 and
328 +  This header was formerly part of SUS, but was deprecated in 1994 and
329    removed from the standard in 2001.  Also, the glibc implementation
330    leaks memory.  See BZ#18681 for more details.
331  \f
332 diff --git a/catgets/Makefile b/catgets/Makefile
333 index 4624a88..56de38b 100644
334 --- a/catgets/Makefile
335 +++ b/catgets/Makefile
336 @@ -34,6 +34,7 @@ test-srcs = test-gencat
337  ifeq ($(run-built-tests),yes)
338  tests-special += $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
339                  $(objpfx)sample.SJIS.cat $(objpfx)test-gencat.out
340 +tests-special += $(objpfx)tst-catgets-mem.out
341  endif
342  
343  gencat-modules = xmalloc
344 @@ -50,9 +51,11 @@ catgets-CPPFLAGS := -DNLSPATH='"$(msgcatdir)/%L/%N:$(msgcatdir)/%L/LC_MESSAGES/%
345  
346  generated += de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
347              test-gencat.h
348 +generated += tst-catgets.mtrace tst-catgets-mem.out
349 +
350  generated-dirs += de
351  
352 -tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
353 +tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de MALLOC_TRACE=$(objpfx)tst-catgets.mtrace
354  
355  ifeq ($(run-built-tests),yes)
356  # This test just checks whether the program produces any error or not.
357 @@ -86,4 +89,8 @@ $(objpfx)test-gencat.out: test-gencat.sh $(objpfx)test-gencat \
358  $(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
359         $(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@; \
360         $(evaluate-test)
361 +
362 +$(objpfx)tst-catgets-mem.out: $(objpfx)tst-catgets.out
363 +       $(common-objpfx)malloc/mtrace $(objpfx)tst-catgets.mtrace > $@; \
364 +       $(evaluate-test)
365  endif
366 diff --git a/catgets/catgets.c b/catgets/catgets.c
367 index cf93d56..4be452d 100644
368 --- a/catgets/catgets.c
369 +++ b/catgets/catgets.c
370 @@ -16,7 +16,6 @@
371     License along with the GNU C Library; if not, see
372     <http://www.gnu.org/licenses/>.  */
373  
374 -#include <alloca.h>
375  #include <errno.h>
376  #include <locale.h>
377  #include <nl_types.h>
378 @@ -35,6 +34,7 @@ catopen (const char *cat_name, int flag)
379    __nl_catd result;
380    const char *env_var = NULL;
381    const char *nlspath = NULL;
382 +  char *tmp = NULL;
383  
384    if (strchr (cat_name, '/') == NULL)
385      {
386 @@ -54,7 +54,10 @@ catopen (const char *cat_name, int flag)
387         {
388           /* Append the system dependent directory.  */
389           size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
390 -         char *tmp = alloca (len);
391 +         tmp = malloc (len);
392 +
393 +         if (__glibc_unlikely (tmp == NULL))
394 +           return (nl_catd) -1;
395  
396           __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
397           nlspath = tmp;
398 @@ -65,16 +68,18 @@ catopen (const char *cat_name, int flag)
399  
400    result = (__nl_catd) malloc (sizeof (*result));
401    if (result == NULL)
402 -    /* We cannot get enough memory.  */
403 -    return (nl_catd) -1;
404 -
405 -  if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
406 +    {
407 +      /* We cannot get enough memory.  */
408 +      result = (nl_catd) -1;
409 +    }
410 +  else if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
411      {
412        /* Couldn't open the file.  */
413        free ((void *) result);
414 -      return (nl_catd) -1;
415 +      result = (nl_catd) -1;
416      }
417  
418 +  free (tmp);
419    return (nl_catd) result;
420  }
421  
422 diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
423 index e069416..9f4d776 100644
424 --- a/catgets/open_catalog.c
425 +++ b/catgets/open_catalog.c
426 @@ -47,6 +47,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
427    size_t tab_size;
428    const char *lastp;
429    int result = -1;
430 +  char *buf = NULL;
431  
432    if (strchr (cat_name, '/') != NULL || nlspath == NULL)
433      fd = open_not_cancel_2 (cat_name, O_RDONLY);
434 @@ -57,23 +58,23 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
435    if (__glibc_unlikely (bufact + (n) >= bufmax))                             \
436      {                                                                        \
437        char *old_buf = buf;                                                   \
438 -      bufmax += 256 + (n);                                                   \
439 -      buf = (char *) alloca (bufmax);                                        \
440 -      memcpy (buf, old_buf, bufact);                                         \
441 +      bufmax += (bufmax < 256 + (n)) ? 256 + (n) : bufmax;                   \
442 +      buf = realloc (buf, bufmax);                                           \
443 +      if (__glibc_unlikely (buf == NULL))                                    \
444 +       {                                                                     \
445 +         free (old_buf);                                                     \
446 +         return -1;                                                          \
447 +       }                                                                     \
448      }
449  
450        /* The RUN_NLSPATH variable contains a colon separated list of
451          descriptions where we expect to find catalogs.  We have to
452          recognize certain % substitutions and stop when we found the
453          first existing file.  */
454 -      char *buf;
455        size_t bufact;
456 -      size_t bufmax;
457 +      size_t bufmax = 0;
458        size_t len;
459  
460 -      buf = NULL;
461 -      bufmax = 0;
462 -
463        fd = -1;
464        while (*run_nlspath != '\0')
465         {
466 @@ -188,7 +189,10 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
467  
468    /* Avoid dealing with directories and block devices */
469    if (__builtin_expect (fd, 0) < 0)
470 -    return -1;
471 +    {
472 +      free (buf);
473 +      return -1;
474 +    }
475  
476    if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
477      goto close_unlock_return;
478 @@ -325,6 +329,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
479    /* Release the lock again.  */
480   close_unlock_return:
481    close_not_cancel_no_status (fd);
482 +  free (buf);
483  
484    return result;
485  }
486 diff --git a/catgets/tst-catgets.c b/catgets/tst-catgets.c
487 index a0a4089..0886938 100644
488 --- a/catgets/tst-catgets.c
489 +++ b/catgets/tst-catgets.c
490 @@ -1,7 +1,10 @@
491 +#include <assert.h>
492  #include <mcheck.h>
493  #include <nl_types.h>
494  #include <stdio.h>
495 +#include <stdlib.h>
496  #include <string.h>
497 +#include <sys/resource.h>
498  
499  
500  static const char *msgs[] =
501 @@ -12,6 +15,33 @@ static const char *msgs[] =
502  };
503  #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
504  
505 +
506 +/* Test for unbounded alloca.  */
507 +static int
508 +do_bz17905 (void)
509 +{
510 +  char *buf;
511 +  struct rlimit rl;
512 +  nl_catd result;
513 +
514 +  const int sz = 1024 * 1024;
515 +
516 +  getrlimit (RLIMIT_STACK, &rl);
517 +  rl.rlim_cur = sz;
518 +  setrlimit (RLIMIT_STACK, &rl);
519 +
520 +  buf = malloc (sz + 1);
521 +  memset (buf, 'A', sz);
522 +  buf[sz] = '\0';
523 +  setenv ("NLSPATH", buf, 1);
524 +
525 +  result = catopen (buf, NL_CAT_LOCALE);
526 +  assert (result == (nl_catd) -1);
527 +
528 +  free (buf);
529 +  return 0;
530 +}
531 +
532  #define ROUNDS 5
533  
534  static int
535 @@ -62,6 +92,7 @@ do_test (void)
536         }
537      }
538  
539 +  result += do_bz17905 ();
540    return result;
541  }
542  
543 diff --git a/config.make.in b/config.make.in
544 index a9f5696..46cd9bb 100644
545 --- a/config.make.in
546 +++ b/config.make.in
547 @@ -51,6 +51,7 @@ have-z-combreloc = @libc_cv_z_combreloc@
548  have-z-execstack = @libc_cv_z_execstack@
549  have-Bgroup = @libc_cv_Bgroup@
550  have-protected-data = @libc_cv_protected_data@
551 +have-glob-dat-reloc = @libc_cv_has_glob_dat@
552  with-fp = @with_fp@
553  old-glibc-headers = @old_glibc_headers@
554  unwind-find-fde = @libc_cv_gcc_unwind_find_fde@
555 diff --git a/configure b/configure
556 index 45cc7cb..4f87b31 100755
557 --- a/configure
558 +++ b/configure
559 @@ -628,6 +628,7 @@ gnu89_inline
560  libc_cv_ssp
561  fno_unit_at_a_time
562  libc_cv_output_format
563 +libc_cv_has_glob_dat
564  libc_cv_hashstyle
565  libc_cv_fpie
566  libc_cv_z_execstack
567 @@ -6335,6 +6336,39 @@ $as_echo "$libc_cv_use_default_link" >&6; }
568    use_default_link=$libc_cv_use_default_link
569  fi
570  
571 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
572 +$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
573 +if ${libc_cv_has_glob_dat+:} false; then :
574 +  $as_echo_n "(cached) " >&6
575 +else
576 +  cat > conftest.c <<EOF
577 +extern int mumble;
578 +int foo (void) { return mumble; }
579 +EOF
580 +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
581 +                       -fPIC -shared -o conftest.so conftest.c
582 +                       -nostdlib -nostartfiles
583 +                       1>&5'
584 +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
585 +  (eval $ac_try) 2>&5
586 +  ac_status=$?
587 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
588 +  test $ac_status = 0; }; }
589 +then
590 +  if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
591 +    libc_cv_has_glob_dat=yes
592 +  else
593 +    libc_cv_has_glob_dat=no
594 +  fi
595 +else
596 +  libc_cv_has_glob_dat=no
597 +fi
598 +rm -f conftest*
599 +fi
600 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_has_glob_dat" >&5
601 +$as_echo "$libc_cv_has_glob_dat" >&6; }
602 +
603 +
604  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
605  $as_echo_n "checking linker output format... " >&6; }
606  if ${libc_cv_output_format+:} false; then :
607 diff --git a/configure.ac b/configure.ac
608 index 7e9383a..8be612d 100644
609 --- a/configure.ac
610 +++ b/configure.ac
611 @@ -1535,6 +1535,29 @@ $ac_try"
612    use_default_link=$libc_cv_use_default_link
613  fi
614  
615 +AC_CACHE_CHECK(for GLOB_DAT reloc,
616 +              libc_cv_has_glob_dat, [dnl
617 +cat > conftest.c <<EOF
618 +extern int mumble;
619 +int foo (void) { return mumble; }
620 +EOF
621 +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
622 +                       -fPIC -shared -o conftest.so conftest.c
623 +                       -nostdlib -nostartfiles
624 +                       1>&AS_MESSAGE_LOG_FD])
625 +then
626 +dnl look for GLOB_DAT relocation.
627 +  if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
628 +    libc_cv_has_glob_dat=yes
629 +  else
630 +    libc_cv_has_glob_dat=no
631 +  fi
632 +else
633 +  libc_cv_has_glob_dat=no
634 +fi
635 +rm -f conftest*])
636 +AC_SUBST(libc_cv_has_glob_dat)
637 +
638  AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
639  if libc_cv_output_format=`
640  ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
641 diff --git a/elf/Makefile b/elf/Makefile
642 index 4ceeaf8..a2c43bc 100644
643 --- a/elf/Makefile
644 +++ b/elf/Makefile
645 @@ -148,7 +148,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
646          tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
647          tst-nodelete) \
648          tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
649 -        tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened
650 +        tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
651 +        tst-nodelete2
652  #       reldep9
653  ifeq ($(build-hardcoded-path-in-tests),yes)
654  tests += tst-dlopen-aout
655 @@ -218,7 +219,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
656                 tst-initorder2d \
657                 tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
658                 tst-array5dep tst-null-argv-lib \
659 -               tst-tlsalign-lib tst-nodelete-opened-lib
660 +               tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod
661  ifeq (yes,$(have-protected-data))
662  modules-names += tst-protected1moda tst-protected1modb
663  tests += tst-protected1a tst-protected1b
664 @@ -292,6 +293,13 @@ check-abi: $(objpfx)check-abi-ld.out
665  tests-special += $(objpfx)check-abi-ld.out
666  update-abi: update-abi-ld
667  
668 +ifeq ($(have-glob-dat-reloc),yes)
669 +tests += tst-prelink
670 +ifeq ($(run-built-tests),yes)
671 +tests-special += $(objpfx)tst-prelink-cmp.out
672 +endif
673 +endif
674 +
675  include ../Rules
676  
677  ifeq (yes,$(build-shared))
678 @@ -594,6 +602,7 @@ tst-auditmod9b.so-no-z-defs = yes
679  tst-nodelete-uniquemod.so-no-z-defs = yes
680  tst-nodelete-rtldmod.so-no-z-defs = yes
681  tst-nodelete-zmod.so-no-z-defs = yes
682 +tst-nodelete2mod.so-no-z-defs = yes
683  
684  ifeq ($(build-shared),yes)
685  # Build all the modules even when not actually running test programs.
686 @@ -1164,6 +1173,11 @@ $(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
687  LDFLAGS-tst-nodelete = -rdynamic
688  LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
689  
690 +$(objpfx)tst-nodelete2: $(libdl)
691 +$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
692 +
693 +LDFLAGS-tst-nodelete2 = -rdynamic
694 +
695  $(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
696         cmp $^ > $@; \
697         $(evaluate-test)
698 @@ -1205,3 +1219,13 @@ $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
699  $(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
700         cmp $< /dev/null > $@; \
701         $(evaluate-test)
702 +
703 +tst-prelink-ENV = LD_TRACE_PRELINKING=1
704 +
705 +$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
706 +       grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
707 +
708 +$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
709 +                             $(objpfx)tst-prelink-conflict.out
710 +       cmp $^ > $@; \
711 +       $(evaluate-test)
712 diff --git a/elf/dl-close.c b/elf/dl-close.c
713 index 9105277..c897247 100644
714 --- a/elf/dl-close.c
715 +++ b/elf/dl-close.c
716 @@ -144,6 +144,14 @@ _dl_close_worker (struct link_map *map, bool force)
717    char done[nloaded];
718    struct link_map *maps[nloaded];
719  
720 +  /* Clear DF_1_NODELETE to force object deletion.  We don't need to touch
721 +     l_tls_dtor_count because forced object deletion only happens when an
722 +     error occurs during object load.  Destructor registration for TLS
723 +     non-POD objects should not have happened till then for this
724 +     object.  */
725 +  if (force)
726 +    map->l_flags_1 &= ~DF_1_NODELETE;
727 +
728    /* Run over the list and assign indexes to the link maps and enter
729       them into the MAPS array.  */
730    int idx = 0;
731 @@ -153,13 +161,6 @@ _dl_close_worker (struct link_map *map, bool force)
732        maps[idx] = l;
733        ++idx;
734  
735 -      /* Clear DF_1_NODELETE to force object deletion.  We don't need to touch
736 -        l_tls_dtor_count because forced object deletion only happens when an
737 -        error occurs during object load.  Destructor registration for TLS
738 -        non-POD objects should not have happened till then for this
739 -        object.  */
740 -      if (force)
741 -       l->l_flags_1 &= ~DF_1_NODELETE;
742      }
743    assert (idx == nloaded);
744  
745 diff --git a/elf/dl-load.c b/elf/dl-load.c
746 index 0c052e4..7e6f4c5 100644
747 --- a/elf/dl-load.c
748 +++ b/elf/dl-load.c
749 @@ -42,6 +42,7 @@
750  #include <dl-map-segments.h>
751  #include <dl-unmap-segments.h>
752  #include <dl-machine-reject-phdr.h>
753 +#include <dl-sysdep-open.h>
754  
755  
756  #include <endian.h>
757 @@ -1471,9 +1472,13 @@ print_search_path (struct r_search_path_elem **list,
758     ignore only ELF files for other architectures.  Non-ELF files and
759     ELF files with different header information cause fatal errors since
760     this could mean there is something wrong in the installation and the
761 -   user might want to know about this.  */
762 +   user might want to know about this.
763 +
764 +   If FD is not -1, then the file is already open and FD refers to it.
765 +   In that case, FD is consumed for both successful and error returns.  */
766  static int
767 -open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
768 +open_verify (const char *name, int fd,
769 +             struct filebuf *fbp, struct link_map *loader,
770              int whatcode, int mode, bool *found_other_class, bool free_name)
771  {
772    /* This is the expected ELF header.  */
773 @@ -1514,6 +1519,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
774    if (__glibc_unlikely (GLRO(dl_naudit) > 0) && whatcode != 0
775        && loader->l_auditing == 0)
776      {
777 +      const char *original_name = name;
778        struct audit_ifaces *afct = GLRO(dl_audit);
779        for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
780         {
781 @@ -1528,11 +1534,21 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
782  
783           afct = afct->next;
784         }
785 +
786 +      if (fd != -1 && name != original_name && strcmp (name, original_name))
787 +        {
788 +          /* An audit library changed what we're supposed to open,
789 +             so FD no longer matches it.  */
790 +          __close (fd);
791 +          fd = -1;
792 +        }
793      }
794  #endif
795  
796 -  /* Open the file.  We always open files read-only.  */
797 -  int fd = __open (name, O_RDONLY | O_CLOEXEC);
798 +  if (fd == -1)
799 +    /* Open the file.  We always open files read-only.  */
800 +    fd = __open (name, O_RDONLY | O_CLOEXEC);
801 +
802    if (fd != -1)
803      {
804        ElfW(Ehdr) *ehdr;
805 @@ -1801,7 +1817,7 @@ open_path (const char *name, size_t namelen, int mode,
806           if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
807             _dl_debug_printf ("  trying file=%s\n", buf);
808  
809 -         fd = open_verify (buf, fbp, loader, whatcode, mode,
810 +         fd = open_verify (buf, -1, fbp, loader, whatcode, mode,
811                             found_other_class, false);
812           if (this_dir->status[cnt] == unknown)
813             {
814 @@ -2041,6 +2057,20 @@ _dl_map_object (struct link_map *loader, const char *name,
815                         &loader->l_runpath_dirs, &realname, &fb, loader,
816                         LA_SER_RUNPATH, &found_other_class);
817  
818 +      if (fd == -1)
819 +        {
820 +          realname = _dl_sysdep_open_object (name, namelen, &fd);
821 +          if (realname != NULL)
822 +            {
823 +              fd = open_verify (realname, fd,
824 +                                &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
825 +                                LA_SER_CONFIG, mode, &found_other_class,
826 +                                false);
827 +              if (fd == -1)
828 +                free (realname);
829 +            }
830 +        }
831 +
832  #ifdef USE_LDCONFIG
833        if (fd == -1
834           && (__glibc_likely ((mode & __RTLD_SECURE) == 0)
835 @@ -2086,7 +2116,7 @@ _dl_map_object (struct link_map *loader, const char *name,
836  
837               if (cached != NULL)
838                 {
839 -                 fd = open_verify (cached,
840 +                 fd = open_verify (cached, -1,
841                                     &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
842                                     LA_SER_CONFIG, mode, &found_other_class,
843                                     false);
844 @@ -2121,7 +2151,7 @@ _dl_map_object (struct link_map *loader, const char *name,
845         fd = -1;
846        else
847         {
848 -         fd = open_verify (realname, &fb,
849 +         fd = open_verify (realname, -1, &fb,
850                             loader ?: GL(dl_ns)[nsid]._ns_loaded, 0, mode,
851                             &found_other_class, true);
852           if (__glibc_unlikely (fd == -1))
853 diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
854 index 11cb44b..acf5280 100644
855 --- a/elf/dl-lookup.c
856 +++ b/elf/dl-lookup.c
857 @@ -1016,6 +1016,18 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
858  #ifdef SHARED
859    if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
860      {
861 +/* ELF_RTYPE_CLASS_XXX must match RTYPE_CLASS_XXX used by prelink with
862 +   LD_TRACE_PRELINKING.  */
863 +#define RTYPE_CLASS_VALID      8
864 +#define RTYPE_CLASS_PLT                (8|1)
865 +#define RTYPE_CLASS_COPY       (8|2)
866 +#define RTYPE_CLASS_TLS                (8|4)
867 +#if ELF_RTYPE_CLASS_PLT != 0 && ELF_RTYPE_CLASS_PLT != 1
868 +# error ELF_RTYPE_CLASS_PLT must be 0 or 1!
869 +#endif
870 +#if ELF_RTYPE_CLASS_COPY != 0 && ELF_RTYPE_CLASS_COPY != 2
871 +# error ELF_RTYPE_CLASS_COPY must be 0 or 2!
872 +#endif
873        int conflict = 0;
874        struct sym_val val = { NULL, NULL };
875  
876 @@ -1071,12 +1083,17 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
877  
878        if (value->s)
879         {
880 +         /* Keep only ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY
881 +            bits since since prelink only uses them.  */
882 +         type_class &= ELF_RTYPE_CLASS_PLT | ELF_RTYPE_CLASS_COPY;
883           if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
884                                 == STT_TLS))
885 -           type_class = 4;
886 +           /* Clear the RTYPE_CLASS_VALID bit in RTYPE_CLASS_TLS.  */
887 +           type_class = RTYPE_CLASS_TLS & ~RTYPE_CLASS_VALID;
888           else if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
889                                      == STT_GNU_IFUNC))
890 -           type_class |= 8;
891 +           /* Set the RTYPE_CLASS_VALID bit.  */
892 +           type_class |= RTYPE_CLASS_VALID;
893         }
894  
895        if (conflict
896 diff --git a/elf/dl-sysdep-open.h b/elf/dl-sysdep-open.h
897 new file mode 100644
898 index 0000000..a63d9f5
899 --- /dev/null
900 +++ b/elf/dl-sysdep-open.h
901 @@ -0,0 +1,45 @@
902 +/* System-specific call to open a shared object by name.  Stub version.
903 +   Copyright (C) 2015 Free Software Foundation, Inc.
904 +   This file is part of the GNU C Library.
905 +
906 +   The GNU C Library is free software; you can redistribute it and/or
907 +   modify it under the terms of the GNU Lesser General Public
908 +   License as published by the Free Software Foundation; either
909 +   version 2.1 of the License, or (at your option) any later version.
910 +
911 +   The GNU C Library is distributed in the hope that it will be useful,
912 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
913 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
914 +   Lesser General Public License for more details.
915 +
916 +   You should have received a copy of the GNU Lesser General Public
917 +   License along with the GNU C Library; if not, see
918 +   <http://www.gnu.org/licenses/>.  */
919 +
920 +#ifndef _DL_SYSDEP_OPEN_H
921 +#define _DL_SYSDEP_OPEN_H      1
922 +
923 +#include <assert.h>
924 +#include <stddef.h>
925 +
926 +/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
927 +   or a dlopen call's argument or suchlike.  NAMELEN is (strlen (NAME) + 1).
928 +
929 +   Find NAME in an OS-dependent fashion, and return its "real" name.
930 +   Optionally fill in *FD with a file descriptor open on that file (or
931 +   else leave its initial value of -1).  The return value is a new
932 +   malloc'd string, which will be free'd by the caller.  If NAME is
933 +   resolved to an actual file that can be opened, then the return
934 +   value should name that file (and if *FD was not set, then a normal
935 +   __open call on that string will be made).  If *FD was set by some
936 +   other means than a normal open and there is no "real" name to use,
937 +   then __strdup (NAME) is fine (modulo error checking).  */
938 +
939 +static inline char *
940 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
941 +{
942 +  assert (*fd == -1);
943 +  return NULL;
944 +}
945 +
946 +#endif  /* dl-sysdep-open.h */
947 diff --git a/elf/rtld.c b/elf/rtld.c
948 index 69873c2..07e741c 100644
949 --- a/elf/rtld.c
950 +++ b/elf/rtld.c
951 @@ -162,7 +162,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
952      ._dl_hwcap_mask = HWCAP_IMPORTANT,
953      ._dl_lazy = 1,
954      ._dl_fpu_control = _FPU_DEFAULT,
955 -    ._dl_pointer_guard = 1,
956      ._dl_pagesize = EXEC_PAGESIZE,
957      ._dl_inhibit_cache = 0,
958  
959 @@ -709,15 +708,12 @@ security_init (void)
960  #endif
961  
962    /* Set up the pointer guard as well, if necessary.  */
963 -  if (GLRO(dl_pointer_guard))
964 -    {
965 -      uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
966 -                                                            stack_chk_guard);
967 +  uintptr_t pointer_chk_guard
968 +    = _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
969  #ifdef THREAD_SET_POINTER_GUARD
970 -      THREAD_SET_POINTER_GUARD (pointer_chk_guard);
971 +  THREAD_SET_POINTER_GUARD (pointer_chk_guard);
972  #endif
973 -      __pointer_chk_guard_local = pointer_chk_guard;
974 -    }
975 +  __pointer_chk_guard_local = pointer_chk_guard;
976  
977    /* We do not need the _dl_random value anymore.  The less
978       information we leave behind, the better, so clear the
979 @@ -2471,9 +2467,6 @@ process_envvars (enum mode *modep)
980               GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
981               break;
982             }
983 -
984 -         if (memcmp (envline, "POINTER_GUARD", 13) == 0)
985 -           GLRO(dl_pointer_guard) = envline[14] != '0';
986           break;
987  
988         case 14:
989 diff --git a/elf/tst-nodelete2.c b/elf/tst-nodelete2.c
990 new file mode 100644
991 index 0000000..388e8af
992 --- /dev/null
993 +++ b/elf/tst-nodelete2.c
994 @@ -0,0 +1,37 @@
995 +#include "../dlfcn/dlfcn.h"
996 +#include <stdio.h>
997 +#include <stdlib.h>
998 +#include <gnu/lib-names.h>
999 +
1000 +static int
1001 +do_test (void)
1002 +{
1003 +  int result = 0;
1004 +
1005 +  printf ("\nOpening pthread library.\n");
1006 +  void *pthread = dlopen (LIBPTHREAD_SO, RTLD_LAZY);
1007 +
1008 +  /* This is a test for correct DF_1_NODELETE clearing when dlopen failure
1009 +     happens.  We should clear DF_1_NODELETE for failed library only, because
1010 +     doing this for others (e.g. libpthread) might cause them to be unloaded,
1011 +     that may lead to some global references (e.g. __rtld_lock_unlock) to be
1012 +     broken.  The dlopen should fail because of undefined symbols in shared
1013 +     library, that cause DF_1_NODELETE to be cleared.  For libpthread, this
1014 +     flag should be set, because if not, SIGSEGV will happen in dlclose.  */
1015 +  if (dlopen ("tst-nodelete2mod.so", RTLD_NOW) != NULL)
1016 +    {
1017 +      printf ("Unique symbols test failed\n");
1018 +      result = 1;
1019 +    }
1020 +
1021 +  if (pthread)
1022 +    dlclose (pthread);
1023 +
1024 +  if (result == 0)
1025 +    printf ("SUCCESS\n");
1026 +
1027 +  return result;
1028 +}
1029 +
1030 +#define TEST_FUNCTION do_test ()
1031 +#include "../test-skeleton.c"
1032 diff --git a/elf/tst-nodelete2mod.c b/elf/tst-nodelete2mod.c
1033 new file mode 100644
1034 index 0000000..e88c756
1035 --- /dev/null
1036 +++ b/elf/tst-nodelete2mod.c
1037 @@ -0,0 +1,7 @@
1038 +/* Undefined symbol.  */
1039 +extern int not_exist (void);
1040 +
1041 +int foo (void)
1042 +{
1043 +  return not_exist ();
1044 +}
1045 diff --git a/elf/tst-prelink.c b/elf/tst-prelink.c
1046 new file mode 100644
1047 index 0000000..ab61c4e
1048 --- /dev/null
1049 +++ b/elf/tst-prelink.c
1050 @@ -0,0 +1,30 @@
1051 +/* Test the output from the environment variable, LD_TRACE_PRELINKING,
1052 +   for prelink.
1053 +   Copyright (C) 2015 Free Software Foundation, Inc.
1054 +   This file is part of the GNU C Library.
1055 +
1056 +   The GNU C Library is free software; you can redistribute it and/or
1057 +   modify it under the terms of the GNU Lesser General Public
1058 +   License as published by the Free Software Foundation; either
1059 +   version 2.1 of the License, or (at your option) any later version.
1060 +
1061 +   The GNU C Library is distributed in the hope that it will be useful,
1062 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1063 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1064 +   Lesser General Public License for more details.
1065 +
1066 +   You should have received a copy of the GNU Lesser General Public
1067 +   License along with the GNU C Library; if not, see
1068 +   <http://www.gnu.org/licenses/>.  */
1069 +
1070 +#include <stdio.h>
1071 +
1072 +static int
1073 +do_test (void)
1074 +{
1075 +  fprintf (stdout, "hello\n");
1076 +  return 0;
1077 +}
1078 +
1079 +#define TEST_FUNCTION do_test ()
1080 +#include "../test-skeleton.c"
1081 diff --git a/elf/tst-prelink.exp b/elf/tst-prelink.exp
1082 new file mode 100644
1083 index 0000000..b35b4c9
1084 --- /dev/null
1085 +++ b/elf/tst-prelink.exp
1086 @@ -0,0 +1 @@
1087 +/0 stdout
1088 diff --git a/elf/tst-znodelete-zlib.cc b/elf/tst-znodelete-zlib.cc
1089 deleted file mode 100644
1090 index 1e8f368..0000000
1091 --- a/elf/tst-znodelete-zlib.cc
1092 +++ /dev/null
1093 @@ -1,6 +0,0 @@
1094 -extern int not_exist (void);
1095 -
1096 -int foo (void)
1097 -{
1098 -  return  not_exist ();
1099 -}
1100 diff --git a/io/test-lfs.c b/io/test-lfs.c
1101 index 539c2a2..b6ebae4 100644
1102 --- a/io/test-lfs.c
1103 +++ b/io/test-lfs.c
1104 @@ -144,7 +144,7 @@ test_ftello (void)
1105  int
1106  do_test (int argc, char *argv[])
1107  {
1108 -  int ret;
1109 +  int ret, fd2;
1110    struct stat64 statbuf;
1111  
1112    ret = lseek64 (fd, TWO_GB+100, SEEK_SET);
1113 @@ -195,6 +195,25 @@ do_test (int argc, char *argv[])
1114      error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
1115            (long long int) statbuf.st_size, (TWO_GB + 100 + 5));
1116  
1117 +  fd2 = openat64 (AT_FDCWD, name, O_RDWR);
1118 +  if (fd2 == -1)
1119 +    {
1120 +      if (errno == ENOSYS)
1121 +       {
1122 +         /* Silently ignore this test.  */
1123 +         error (0, 0, "openat64 is not supported");
1124 +       }
1125 +      else
1126 +       error (EXIT_FAILURE, errno, "openat64 failed to open big file");
1127 +    }
1128 +  else
1129 +    {
1130 +      ret = close (fd2);
1131 +
1132 +      if (ret == -1)
1133 +       error (EXIT_FAILURE, errno, "error closing file");
1134 +    }
1135 +
1136    test_ftello ();
1137  
1138    return 0;
1139 diff --git a/locale/C-collate.c b/locale/C-collate.c
1140 index d7f3c55..06dfdfa 100644
1141 --- a/locale/C-collate.c
1142 +++ b/locale/C-collate.c
1143 @@ -144,8 +144,6 @@ const struct __locale_data _nl_C_LC_COLLATE attribute_hidden =
1144      /* _NL_COLLATE_COLLSEQWC */
1145      { .string = (const char *) collseqwc },
1146      /* _NL_COLLATE_CODESET */
1147 -    { .string = _nl_C_codeset },
1148 -    /* _NL_COLLATE_ENCODING_TYPE */
1149 -    { .word = __cet_8bit }
1150 +    { .string = _nl_C_codeset }
1151    }
1152  };
1153 diff --git a/locale/categories.def b/locale/categories.def
1154 index 045489d..a8dda53 100644
1155 --- a/locale/categories.def
1156 +++ b/locale/categories.def
1157 @@ -58,7 +58,6 @@ DEFINE_CATEGORY
1158    DEFINE_ELEMENT (_NL_COLLATE_COLLSEQMB,        "collate-collseqmb",        std, wstring)
1159    DEFINE_ELEMENT (_NL_COLLATE_COLLSEQWC,        "collate-collseqwc",        std, wstring)
1160    DEFINE_ELEMENT (_NL_COLLATE_CODESET,         "collate-codeset",          std, string)
1161 -  DEFINE_ELEMENT (_NL_COLLATE_ENCODING_TYPE,   "collate-encoding-type",    std, word)
1162    ), NO_POSTLOAD)
1163  
1164  
1165 diff --git a/locale/langinfo.h b/locale/langinfo.h
1166 index ffc5c7f..a565d9d 100644
1167 --- a/locale/langinfo.h
1168 +++ b/locale/langinfo.h
1169 @@ -255,7 +255,6 @@ enum
1170    _NL_COLLATE_COLLSEQMB,
1171    _NL_COLLATE_COLLSEQWC,
1172    _NL_COLLATE_CODESET,
1173 -  _NL_COLLATE_ENCODING_TYPE,
1174    _NL_NUM_LC_COLLATE,
1175  
1176    /* LC_CTYPE category: character classification.
1177 diff --git a/locale/loadlocale.c b/locale/loadlocale.c
1178 index fdba6e9..dcbb833 100644
1179 --- a/locale/loadlocale.c
1180 +++ b/locale/loadlocale.c
1181 @@ -121,9 +121,10 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize)
1182        switch (category)
1183         {
1184  #define CATTEST(cat) \
1185 -       case LC_##cat:                                                        \
1186 -         assert (cnt < (sizeof (_nl_value_type_LC_##cat)                     \
1187 -                        / sizeof (_nl_value_type_LC_##cat[0])));             \
1188 +       case LC_##cat:                                          \
1189 +         if (cnt >= (sizeof (_nl_value_type_LC_##cat)          \
1190 +                     / sizeof (_nl_value_type_LC_##cat[0])))   \
1191 +           goto puntdata;                                      \
1192           break
1193           CATTEST (NUMERIC);
1194           CATTEST (TIME);
1195 diff --git a/locale/localeinfo.h b/locale/localeinfo.h
1196 index bdab9fe..1d2ee00 100644
1197 --- a/locale/localeinfo.h
1198 +++ b/locale/localeinfo.h
1199 @@ -110,14 +110,6 @@ enum coll_sort_rule
1200    sort_mask
1201  };
1202  
1203 -/* Collation encoding type.  */
1204 -enum collation_encoding_type
1205 -{
1206 -  __cet_other,
1207 -  __cet_8bit,
1208 -  __cet_utf8
1209 -};
1210 -
1211  /* We can map the types of the entries into a few categories.  */
1212  enum value_type
1213  {
1214 diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
1215 index a39a94f..dc0fe30 100644
1216 --- a/locale/programs/ld-collate.c
1217 +++ b/locale/programs/ld-collate.c
1218 @@ -32,7 +32,6 @@
1219  #include "linereader.h"
1220  #include "locfile.h"
1221  #include "elem-hash.h"
1222 -#include "../localeinfo.h"
1223  
1224  /* Uncomment the following line in the production version.  */
1225  /* #define NDEBUG 1 */
1226 @@ -2131,8 +2130,6 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
1227           /* The words have to be handled specially.  */
1228           if (idx == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
1229             add_locale_uint32 (&file, 0);
1230 -         else if (idx == _NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE))
1231 -           add_locale_uint32 (&file, __cet_other);
1232           else
1233             add_locale_empty (&file);
1234         }
1235 @@ -2496,12 +2493,6 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
1236    add_locale_raw_data (&file, collate->mbseqorder, 256);
1237    add_locale_collseq_table (&file, &collate->wcseqorder);
1238    add_locale_string (&file, charmap->code_set_name);
1239 -  if (strcmp (charmap->code_set_name, "UTF-8") == 0)
1240 -    add_locale_uint32 (&file, __cet_utf8);
1241 -  else if (charmap->mb_cur_max == 1)
1242 -    add_locale_uint32 (&file, __cet_8bit);
1243 -  else
1244 -    add_locale_uint32 (&file, __cet_other);
1245    write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", &file);
1246  
1247    obstack_free (&weightpool, NULL);
1248 diff --git a/math/Makefile b/math/Makefile
1249 index 6388bae..2c9d72d 100644
1250 --- a/math/Makefile
1251 +++ b/math/Makefile
1252 @@ -98,7 +98,7 @@ $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
1253         (echo '/* GNU ld script'; echo '*/';\
1254          cat $<; \
1255          echo 'GROUP ( $(slibdir)/libm.so$(libm.so-version) ' \
1256 -             'AS_NEEDED ( $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
1257 +             'AS_NEEDED ( $(libdir)/libmvec_nonshared.a $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
1258         ) > $@
1259  endif
1260  
1261 diff --git a/misc/Makefile b/misc/Makefile
1262 index aecb0da..2f5edf6 100644
1263 --- a/misc/Makefile
1264 +++ b/misc/Makefile
1265 @@ -76,7 +76,8 @@ install-lib := libg.a
1266  gpl2lgpl := error.c error.h
1267  
1268  tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
1269 -        tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1
1270 +        tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
1271 +        tst-mntent-blank-corrupt tst-mntent-blank-passno
1272  ifeq ($(run-built-tests),yes)
1273  tests-special += $(objpfx)tst-error1-mem.out
1274  endif
1275 diff --git a/misc/mntent_r.c b/misc/mntent_r.c
1276 index 6159873..4f26998 100644
1277 --- a/misc/mntent_r.c
1278 +++ b/misc/mntent_r.c
1279 @@ -136,7 +136,9 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
1280        end_ptr = strchr (buffer, '\n');
1281        if (end_ptr != NULL)     /* chop newline */
1282         {
1283 -         while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
1284 +         /* Do not walk past the start of buffer if it's all whitespace.  */
1285 +         while (end_ptr != buffer
1286 +                && (end_ptr[-1] == ' ' || end_ptr[-1] == '\t'))
1287              end_ptr--;
1288           *end_ptr = '\0';
1289         }
1290 diff --git a/misc/regexp.h b/misc/regexp.h
1291 index 3460989..42394f7 100644
1292 --- a/misc/regexp.h
1293 +++ b/misc/regexp.h
1294 @@ -19,10 +19,11 @@
1295  #ifndef _REGEXP_H
1296  #define _REGEXP_H      1
1297  
1298 -/* The contents of this header file were standardized in the
1299 -   Single Unix Specification, Version 2 (1997) but marked as
1300 -   LEGACY; new applications were already being encouraged to
1301 -   use <regex.h> instead.  POSIX.1-2001 removed this header.
1302 +/* The contents of this header file were originally standardized in
1303 +   the Single Unix Specification, Issue 3 (1992).  In Issue 4 (1994)
1304 +   the header was marked as TO BE WITHDRAWN, and new applications
1305 +   were encouraged to use <regex.h> instead.  It was officially
1306 +   withdrawn from the standard in Issue 6 (aka POSIX.1-2001).
1307  
1308     This header is provided only for backward compatibility.
1309     It will be removed in the next release of the GNU C Library.
1310 diff --git a/misc/sys/param.h b/misc/sys/param.h
1311 index 62b7ed2..1908b93 100644
1312 --- a/misc/sys/param.h
1313 +++ b/misc/sys/param.h
1314 @@ -50,6 +50,9 @@
1315  #if !defined NOFILE && defined OPEN_MAX
1316  # define NOFILE                OPEN_MAX
1317  #endif
1318 +#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
1319 +# define MAXHOSTNAMELEN        HOST_NAME_MAX
1320 +#endif
1321  #ifndef NCARGS
1322  # ifdef ARG_MAX
1323  #  define NCARGS       ARG_MAX
1324 diff --git a/misc/tst-mntent-blank-corrupt.c b/misc/tst-mntent-blank-corrupt.c
1325 new file mode 100644
1326 index 0000000..92266a3
1327 --- /dev/null
1328 +++ b/misc/tst-mntent-blank-corrupt.c
1329 @@ -0,0 +1,45 @@
1330 +/* Make sure blank lines does not cause memory corruption BZ #18887.
1331 +
1332 +   Copyright (C) 2009-2015 Free Software Foundation, Inc.
1333 +   This file is part of the GNU C Library.
1334 +
1335 +   The GNU C Library is free software; you can redistribute it and/or
1336 +   modify it under the terms of the GNU Lesser General Public
1337 +   License as published by the Free Software Foundation; either
1338 +   version 2.1 of the License, or (at your option) any later version.
1339 +
1340 +   The GNU C Library is distributed in the hope that it will be useful,
1341 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1342 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1343 +   Lesser General Public License for more details.
1344 +
1345 +   You should have received a copy of the GNU Lesser General Public
1346 +   License along with the GNU C Library; if not, see
1347 +   <http://www.gnu.org/licenses/>.  */
1348 +
1349 +#include <mntent.h>
1350 +#include <stdio.h>
1351 +#include <string.h>
1352 +
1353 +/* Make sure blank lines don't trigger memory corruption.  This doesn't happen
1354 +   for all targets though, so it's a best effort test BZ #18887.  */
1355 +static int
1356 +do_test (void)
1357 +{
1358 +  FILE *fp;
1359 +
1360 +  fp = tmpfile ();
1361 +  fputs ("\n \n/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1362 +  rewind (fp);
1363 +
1364 +  /* The corruption happens here ...  */
1365 +  getmntent (fp);
1366 +  /* ... but trigers here.  */
1367 +  endmntent (fp);
1368 +
1369 +  /* If the test failed, we would crash, and not hit this point.  */
1370 +  return 0;
1371 +}
1372 +
1373 +#define TEST_FUNCTION do_test ()
1374 +#include "../test-skeleton.c"
1375 diff --git a/misc/tst-mntent-blank-passno.c b/misc/tst-mntent-blank-passno.c
1376 new file mode 100644
1377 index 0000000..fc04291
1378 --- /dev/null
1379 +++ b/misc/tst-mntent-blank-passno.c
1380 @@ -0,0 +1,53 @@
1381 +/* Make sure trailing whitespace is handled properly BZ #17273.
1382 +
1383 +   Copyright (C) 2009-2015 Free Software Foundation, Inc.
1384 +   This file is part of the GNU C Library.
1385 +
1386 +   The GNU C Library is free software; you can redistribute it and/or
1387 +   modify it under the terms of the GNU Lesser General Public
1388 +   License as published by the Free Software Foundation; either
1389 +   version 2.1 of the License, or (at your option) any later version.
1390 +
1391 +   The GNU C Library is distributed in the hope that it will be useful,
1392 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1393 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1394 +   Lesser General Public License for more details.
1395 +
1396 +   You should have received a copy of the GNU Lesser General Public
1397 +   License along with the GNU C Library; if not, see
1398 +   <http://www.gnu.org/licenses/>.  */
1399 +
1400 +#include <mntent.h>
1401 +#include <stdio.h>
1402 +#include <string.h>
1403 +
1404 +/* Check entries to make sure trailing whitespace is ignored and we return the
1405 +   correct passno value BZ #17273.  */
1406 +static int
1407 +do_test (void)
1408 +{
1409 +  int result = 0;
1410 +  FILE *fp;
1411 +  struct mntent *mnt;
1412 +
1413 +  fp = tmpfile ();
1414 +  fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1415 +  rewind (fp);
1416 +
1417 +  mnt = getmntent (fp);
1418 +  if (strcmp (mnt->mnt_fsname, "/foo dir") != 0
1419 +      || strcmp (mnt->mnt_dir, "/bar dir") != 0
1420 +      || strcmp (mnt->mnt_type, "auto") != 0
1421 +      || strcmp (mnt->mnt_opts, "bind") != 0
1422 +      || mnt->mnt_freq != 0
1423 +      || mnt->mnt_passno != 0)
1424 +    {
1425 +      puts ("Error while reading entry with trailing whitespaces");
1426 +      result = 1;
1427 +    }
1428 +
1429 +  return result;
1430 +}
1431 +
1432 +#define TEST_FUNCTION do_test ()
1433 +#include "../test-skeleton.c"
1434 diff --git a/misc/tst-mntent.c b/misc/tst-mntent.c
1435 index 876c89f..820b354 100644
1436 --- a/misc/tst-mntent.c
1437 +++ b/misc/tst-mntent.c
1438 @@ -73,26 +73,6 @@ main (int argc, char *argv[])
1439           puts ("Error while reading written entry back in");
1440           result = 1;
1441         }
1442 -
1443 -      /* Part III: Entry with whitespaces at the end of a line. */
1444 -      rewind (fp);
1445 -
1446 -      fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1447 -
1448 -      rewind (fp);
1449 -
1450 -      mnt = getmntent (fp);
1451 -
1452 -      if (strcmp (mnt->mnt_fsname, "/foo dir") != 0
1453 -         || strcmp (mnt->mnt_dir, "/bar dir") != 0
1454 -         || strcmp (mnt->mnt_type, "auto") != 0
1455 -         || strcmp (mnt->mnt_opts, "bind") != 0
1456 -         || mnt->mnt_freq != 0
1457 -         || mnt->mnt_passno != 0)
1458 -       {
1459 -         puts ("Error while reading entry with trailing whitespaces");
1460 -         result = 1;
1461 -       }
1462     }
1463  
1464    return result;
1465 diff --git a/scripts/test-installation.pl b/scripts/test-installation.pl
1466 index cac1562..79b2b3e 100755
1467 --- a/scripts/test-installation.pl
1468 +++ b/scripts/test-installation.pl
1469 @@ -80,16 +80,25 @@ arglist: while (@ARGV) {
1470  # We expect none or one argument.
1471  if ($#ARGV == -1) {
1472      $soversions="soversions.mk";
1473 +    $config="config.make";
1474  } elsif ($#ARGV == 0) {
1475      if (-d $ARGV[0]) {
1476        $soversions = "$ARGV[0]/soversions.mk";
1477 +      $config = "$ARGV[0]/config.make";
1478      } else {
1479 -      $soversions = $ARGV[0];
1480 +      $soversions = $dir = $ARGV[0];
1481 +      $dir =~ s!/?[^/]*/*$!!;
1482 +      $config = $dir . "/config.make";
1483      }
1484  } else {
1485      die "Wrong number of arguments.";
1486  }
1487  
1488 +if (system ("grep -q \"build-mathvec = yes\" $config") == 0) {
1489 +    $build_mathvec = 1;
1490 +} else {
1491 +    $build_mathvec = 0;
1492 +}
1493  
1494  # Read names and versions of all shared libraries that are part of
1495  # glibc
1496 @@ -111,6 +120,8 @@ while (<SOVERSIONS>) {
1497      # - libthread_db since it contains unresolved references
1498      # - it's just a test NSS module
1499      # - We don't provide the libgcc so we don't test it
1500 +    # - libmvec if it wasn't built
1501 +    next if ($build_mathvec == 0 && $name eq "mvec");
1502      if ($name ne "nss_ldap" && $name ne "db1"
1503         && !($name =~/^nss1_/) && $name ne "thread_db"
1504         && $name ne "nss_test1" && $name ne "libgcc_s") {
1505 diff --git a/stdlib/cxa_thread_atexit_impl.c b/stdlib/cxa_thread_atexit_impl.c
1506 index 2d5d56a..5717f09 100644
1507 --- a/stdlib/cxa_thread_atexit_impl.c
1508 +++ b/stdlib/cxa_thread_atexit_impl.c
1509 @@ -98,6 +98,10 @@ static __thread struct link_map *lm_cache;
1510  int
1511  __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
1512  {
1513 +#ifdef PTR_MANGLE
1514 +  PTR_MANGLE (func);
1515 +#endif
1516 +
1517    /* Prepend.  */
1518    struct dtor_list *new = calloc (1, sizeof (struct dtor_list));
1519    new->func = func;
1520 @@ -142,9 +146,13 @@ __call_tls_dtors (void)
1521    while (tls_dtor_list)
1522      {
1523        struct dtor_list *cur = tls_dtor_list;
1524 +      dtor_func func = cur->func;
1525 +#ifdef PTR_DEMANGLE
1526 +      PTR_DEMANGLE (func);
1527 +#endif
1528  
1529        tls_dtor_list = tls_dtor_list->next;
1530 -      cur->func (cur->obj);
1531 +      func (cur->obj);
1532  
1533        /* Ensure that the MAP dereference happens before
1534          l_tls_dtor_count decrement.  That way, we protect this access from a
1535 diff --git a/string/Makefile b/string/Makefile
1536 index 8424a61..ebe9354 100644
1537 --- a/string/Makefile
1538 +++ b/string/Makefile
1539 @@ -54,7 +54,7 @@ tests         := tester inl-tester noinl-tester testcopy test-ffs     \
1540                    tst-strtok tst-strxfrm bug-strcoll1 tst-strfry       \
1541                    bug-strtok1 $(addprefix test-,$(strop-tests))        \
1542                    bug-envz1 tst-strxfrm2 tst-endian tst-svc2           \
1543 -                  tst-strtok_r
1544 +                  tst-strtok_r bug-strcoll2
1545  
1546  xtests = tst-strcoll-overflow
1547  
1548 @@ -75,4 +75,17 @@ ifeq ($(run-built-tests),yes)
1549  $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
1550         cmp $^ > $@; \
1551         $(evaluate-test)
1552 +
1553 +LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
1554 +           tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
1555 +          da_DK.ISO-8859-1
1556 +include ../gen-locales.mk
1557 +
1558 +$(objpfx)test-strcasecmp.out: $(gen-locales)
1559 +$(objpfx)test-strncasecmp.out: $(gen-locales)
1560 +$(objpfx)tst-strxfrm.out: $(gen-locales)
1561 +$(objpfx)tst-strxfrm2.out: $(gen-locales)
1562 +# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
1563 +$(objpfx)bug-strcoll2.out: $(gen-locales)
1564 +
1565  endif
1566 diff --git a/string/bug-strcoll2.c b/string/bug-strcoll2.c
1567 new file mode 100644
1568 index 0000000..72a9ff2
1569 --- /dev/null
1570 +++ b/string/bug-strcoll2.c
1571 @@ -0,0 +1,92 @@
1572 +/* Bug 18589: sort-test.sh fails at random.
1573 +   Copyright (C) 2015 Free Software Foundation, Inc.
1574 +   This file is part of the GNU C Library.
1575 +
1576 +   The GNU C Library is free software; you can redistribute it and/or
1577 +   modify it under the terms of the GNU Lesser General Public
1578 +   License as published by the Free Software Foundation; either
1579 +   version 2.1 of the License, or (at your option) any later version.
1580 +
1581 +   The GNU C Library is distributed in the hope that it will be useful,
1582 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1583 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1584 +   Lesser General Public License for more details.
1585 +
1586 +   You should have received a copy of the GNU Lesser General Public
1587 +   License along with the GNU C Library; if not, see
1588 +   <http://www.gnu.org/licenses/>.  */
1589 +
1590 +#include <stdio.h>
1591 +#include <string.h>
1592 +#include <locale.h>
1593 +
1594 +/* An incorrect strcoll optimization resulted in incorrect
1595 +   results from strcoll for cs_CZ and da_DK.  */
1596 +
1597 +int
1598 +test_cs_CZ (void)
1599 +{
1600 +  const char t1[] = "config";
1601 +  const char t2[] = "choose";
1602 +  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
1603 +    {
1604 +      perror ("setlocale");
1605 +      return 1;
1606 +    }
1607 +  /* In Czech the digraph ch sorts after c, therefore we expect
1608 +     config to sort before choose.  */
1609 +  int a = strcoll (t1, t2);
1610 +  int b = strcoll (t2, t1);
1611 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a);
1612 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b);
1613 +  if (a < 0 && b > 0)
1614 +    {
1615 +      puts ("PASS: config < choose");
1616 +      return 0;
1617 +    }
1618 +  else
1619 +    {
1620 +      puts ("FAIL: Wrong sorting in cs_CZ.UTF-8.");
1621 +      return 1;
1622 +    }
1623 +}
1624 +
1625 +int
1626 +test_da_DK (void)
1627 +{
1628 +  const char t1[] = "AS";
1629 +  const char t2[] = "AA";
1630 +  if (setlocale (LC_ALL, "da_DK.ISO-8859-1") == NULL)
1631 +    {
1632 +      perror ("setlocale");
1633 +      return 1;
1634 +    }
1635 +  /* AA should be treated as the last letter of the Danish alphabet,
1636 +     hence sorting after AS.  */
1637 +  int a = strcoll (t1, t2);
1638 +  int b = strcoll (t2, t1);
1639 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a);
1640 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b);
1641 +  if (a < 0 && b > 0)
1642 +    {
1643 +      puts ("PASS: AS < AA");
1644 +      return 0;
1645 +    }
1646 +  else
1647 +    {
1648 +      puts ("FAIL: Wrong sorting in da_DK.ISO-8859-1");
1649 +      return 1;
1650 +    }
1651 +}
1652 +
1653 +static int
1654 +do_test (void)
1655 +{
1656 +  int err = 0;
1657 +  err |= test_cs_CZ ();
1658 +  err |= test_da_DK ();
1659 +  return err;
1660 +}
1661 +
1662 +#define TEST_FUNCTION do_test ()
1663 +#include "../test-skeleton.c"
1664 diff --git a/string/strcoll_l.c b/string/strcoll_l.c
1665 index 8f1225f..35bc0e4 100644
1666 --- a/string/strcoll_l.c
1667 +++ b/string/strcoll_l.c
1668 @@ -29,7 +29,6 @@
1669  # define STRING_TYPE char
1670  # define USTRING_TYPE unsigned char
1671  # define STRCOLL __strcoll_l
1672 -# define STRDIFF __strdiff
1673  # define STRCMP strcmp
1674  # define WEIGHT_H "../locale/weight.h"
1675  # define SUFFIX        MB
1676 @@ -42,20 +41,6 @@
1677  #include "../locale/localeinfo.h"
1678  #include WEIGHT_H
1679  
1680 -#define MASK_UTF8_7BIT  (1 << 7)
1681 -#define MASK_UTF8_START (3 << 6)
1682 -
1683 -size_t
1684 -STRDIFF (const STRING_TYPE *s, const STRING_TYPE *t)
1685 -{
1686 -  size_t n;
1687 -
1688 -  for (n = 0; *s != '\0' && *s++ == *t++; ++n)
1689 -    continue;
1690 -
1691 -  return n;
1692 -}
1693 -
1694  /* Track status while looking for sequences in a string.  */
1695  typedef struct
1696  {
1697 @@ -269,29 +254,9 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
1698    const USTRING_TYPE *extra;
1699    const int32_t *indirect;
1700  
1701 -  /* In case there is no locale specific sort order (C / POSIX).  */
1702    if (nrules == 0)
1703      return STRCMP (s1, s2);
1704  
1705 -  /* Fast forward to the position of the first difference.  Needs to be
1706 -     encoding aware as the byte-by-byte comparison can stop in the middle
1707 -     of a char sequence for multibyte encodings like UTF-8.  */
1708 -  uint_fast32_t encoding =
1709 -    current->values[_NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE)].word;
1710 -  if (encoding != __cet_other)
1711 -    {
1712 -      size_t diff = STRDIFF (s1, s2);
1713 -      if (diff > 0)
1714 -       {
1715 -         if (encoding == __cet_utf8 && (*(s1 + diff) & MASK_UTF8_7BIT) != 0)
1716 -           do
1717 -             diff--;
1718 -           while (diff > 0 && (*(s1 + diff) & MASK_UTF8_START) != MASK_UTF8_START);
1719 -         s1 += diff;
1720 -         s2 += diff;
1721 -       }
1722 -    }
1723 -
1724    /* Catch empty strings.  */
1725    if (__glibc_unlikely (*s1 == '\0') || __glibc_unlikely (*s2 == '\0'))
1726      return (*s1 != '\0') - (*s2 != '\0');
1727 @@ -358,8 +323,7 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
1728                      byte-level comparison to ensure that we don't waste time
1729                      going through multiple passes for totally equal strings
1730                      before proceeding to subsequent passes.  */
1731 -                 if (pass == 0 && encoding == __cet_other &&
1732 -                     STRCMP (s1, s2) == 0)
1733 +                 if (pass == 0 && STRCMP (s1, s2) == 0)
1734                     return result;
1735                   else
1736                     break;
1737 diff --git a/string/tst-strxfrm2.c b/string/tst-strxfrm2.c
1738 index d5a1115..bea5aa2 100644
1739 --- a/string/tst-strxfrm2.c
1740 +++ b/string/tst-strxfrm2.c
1741 @@ -5,6 +5,8 @@
1742  static int
1743  do_test (void)
1744  {
1745 +  static const char test_locale[] = "de_DE.UTF-8";
1746 +
1747    int res = 0;
1748  
1749    char buf[20];
1750 @@ -38,9 +40,9 @@ do_test (void)
1751        res = 1;
1752      }
1753  
1754 -  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
1755 +  if (setlocale (LC_ALL, test_locale) == NULL)
1756      {
1757 -      puts ("setlocale failed");
1758 +      printf ("cannot set locale \"%s\"\n", test_locale);
1759        res = 1;
1760      }
1761    else
1762 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
1763 index 7a0fe8d..78e3a97 100644
1764 --- a/sysdeps/generic/ldsodefs.h
1765 +++ b/sysdeps/generic/ldsodefs.h
1766 @@ -592,9 +592,6 @@ struct rtld_global_ro
1767    /* List of auditing interfaces.  */
1768    struct audit_ifaces *_dl_audit;
1769    unsigned int _dl_naudit;
1770 -
1771 -  /* 0 if internal pointer values should not be guarded, 1 if they should.  */
1772 -  EXTERN int _dl_pointer_guard;
1773  };
1774  # define __rtld_global_attribute__
1775  # if IS_IN (rtld)
1776 diff --git a/sysdeps/hppa/dl-symaddr.c b/sysdeps/hppa/dl-symaddr.c
1777 index b707c19..89d8baf 100644
1778 --- a/sysdeps/hppa/dl-symaddr.c
1779 +++ b/sysdeps/hppa/dl-symaddr.c
1780 @@ -33,3 +33,4 @@ _dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref)
1781    else
1782      return (void *) value;
1783  }
1784 +rtld_hidden_def (_dl_symbol_address)
1785 diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S
1786 index 64d8c3e..cc4f243 100644
1787 --- a/sysdeps/hppa/start.S
1788 +++ b/sysdeps/hppa/start.S
1789 @@ -42,7 +42,11 @@
1790         /* Have the linker create plabel words so we get PLABEL32
1791            relocs and not 21/14.  The use of 21/14 relocs is only
1792            supported in the latest dynamic linker.  */
1793 -       .section        .rodata
1794 +#ifdef SHARED
1795 +       .section        .data.rel.ro,"aw",@progbits
1796 +#else
1797 +       .section        .rodata,"a",@progbits
1798 +#endif
1799         .align 4
1800  .Lpmain:
1801         .word P%main
1802 @@ -52,6 +56,10 @@
1803         .word P%__libc_csu_fini
1804  .Lp__libc_csu_init:
1805         .word P%__libc_csu_init
1806 +#ifdef SHARED
1807 +.Lp__global:
1808 +       .word $global$
1809 +#endif
1810  
1811         .text
1812         .align 4
1813 @@ -122,10 +130,14 @@ _start:
1814         /* void *stack_end (7th argument) */
1815         stw     %sp, -60(%sp)
1816  
1817 +#ifdef SHARED
1818 +       addil   LT'.Lp__global, %r19
1819 +       ldw     RT'.Lp__global(%r1), %dp
1820 +#else
1821         /* load global */
1822         ldil    L%$global$, %dp
1823         ldo     R%$global$(%dp), %dp
1824 -
1825 +#endif
1826         bl      __libc_start_main,%r2
1827         nop
1828         /* die horribly if it returned (it shouldn't) */
1829 diff --git a/sysdeps/nacl/Makefile b/sysdeps/nacl/Makefile
1830 index 6749a44..1748886 100644
1831 --- a/sysdeps/nacl/Makefile
1832 +++ b/sysdeps/nacl/Makefile
1833 @@ -132,4 +132,13 @@ ifeq ($(subdir),misc)
1834  # sysdeps/.../linux/ directories, but it's still a sysdeps decision to
1835  # install it.
1836  sysdep_headers += bits/mman-linux.h
1837 +
1838 +# This defeats sysdeps/gnu/Makefile's addition of sys/mtio.h, which
1839 +# we do not want.  This is a total kludge, but it seems no worse for
1840 +# now than making the sysdeps/gnu/Makefile code conditional on a
1841 +# variable we set here.  If some sysdeps/.../Makefile that is later
1842 +# in the list than sysdeps/gnu needed to add to sysdep_headers, this
1843 +# would break it.  But sysdeps/gnu is close to last in the list and
1844 +# this coming up seems unlikely.
1845 +override sysdep_headers := $(sysdep_headers)
1846  endif
1847 diff --git a/sysdeps/nacl/dl-map-segments.h b/sysdeps/nacl/dl-map-segments.h
1848 index f305da3..f2d5d84 100644
1849 --- a/sysdeps/nacl/dl-map-segments.h
1850 +++ b/sysdeps/nacl/dl-map-segments.h
1851 @@ -53,7 +53,7 @@ _dl_map_segments (struct link_map *l, int fd,
1852                   const size_t maplength, bool has_holes,
1853                   struct link_map *loader)
1854  {
1855 -  if (__builtin_expect (type, ET_DYN) == ET_DYN)
1856 +  if (__glibc_likely (type == ET_DYN))
1857      {
1858        /* This is a position-independent shared object.  Let the system
1859          choose where to place it.
1860 @@ -165,6 +165,32 @@ _dl_map_segments (struct link_map *l, int fd,
1861                     errno = error;
1862                     return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
1863                   }
1864 +                if (__glibc_unlikely (type != ET_DYN))
1865 +                  {
1866 +                    /* A successful PROT_EXEC mmap would have implicitly
1867 +                       updated the bookkeeping so that a future
1868 +                       allocate_code_data call would know that this range
1869 +                       of the address space is already occupied.  That
1870 +                       doesn't happen implicitly with dyncode_create, so
1871 +                       it's necessary to do an explicit call to update the
1872 +                       bookkeeping.  */
1873 +                    uintptr_t allocated_address;
1874 +                    error = __nacl_irt_code_data_alloc.allocate_code_data
1875 +                      (l->l_addr + c->mapstart, len, 0, 0, &allocated_address);
1876 +                    if (__glibc_unlikely (error))
1877 +                      {
1878 +                        errno = error;
1879 +                        return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
1880 +                      }
1881 +                    if (__glibc_unlikely
1882 +                        (allocated_address != l->l_addr + c->mapstart))
1883 +                      {
1884 +                        /* This is not a very helpful error for this case,
1885 +                           but there isn't really anything better to use.  */
1886 +                        errno = ENOMEM;
1887 +                        return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
1888 +                      }
1889 +                  }
1890               }
1891             else
1892               {
1893 diff --git a/sysdeps/nacl/dl-sysdep-open.h b/sysdeps/nacl/dl-sysdep-open.h
1894 new file mode 100644
1895 index 0000000..38b0f9e
1896 --- /dev/null
1897 +++ b/sysdeps/nacl/dl-sysdep-open.h
1898 @@ -0,0 +1,40 @@
1899 +/* System-specific call to open a shared object by name.  NaCl version.
1900 +   Copyright (C) 2015 Free Software Foundation, Inc.
1901 +   This file is part of the GNU C Library.
1902 +
1903 +   The GNU C Library is free software; you can redistribute it and/or
1904 +   modify it under the terms of the GNU Lesser General Public
1905 +   License as published by the Free Software Foundation; either
1906 +   version 2.1 of the License, or (at your option) any later version.
1907 +
1908 +   The GNU C Library is distributed in the hope that it will be useful,
1909 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1910 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1911 +   Lesser General Public License for more details.
1912 +
1913 +   You should have received a copy of the GNU Lesser General Public
1914 +   License along with the GNU C Library; if not, see
1915 +   <http://www.gnu.org/licenses/>.  */
1916 +
1917 +#ifndef _DL_SYSDEP_OPEN_H
1918 +#define _DL_SYSDEP_OPEN_H      1
1919 +
1920 +#include <stddef.h>
1921 +
1922 +/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
1923 +   or a dlopen call's argument or suchlike.  NAMELEN is (strlen (NAME) + 1).
1924 +
1925 +   Find NAME in an OS-dependent fashion, and return its "real" name.
1926 +   Optionally fill in *FD with a file descriptor open on that file (or
1927 +   else leave its initial value of -1).  The return value is a new
1928 +   malloc'd string, which will be free'd by the caller.  If NAME is
1929 +   resolved to an actual file that can be opened, then the return
1930 +   value should name that file (and if *FD was not set, then a normal
1931 +   __open call on that string will be made).  If *FD was set by some
1932 +   other means than a normal open and there is no "real" name to use,
1933 +   then __strdup (NAME) is fine (modulo error checking).  */
1934 +
1935 +extern char *_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
1936 +  internal_function attribute_hidden;
1937 +
1938 +#endif  /* dl-sysdep-open.h */
1939 diff --git a/sysdeps/nacl/dl-sysdep.c b/sysdeps/nacl/dl-sysdep.c
1940 index 3e902c2..3a04aa1 100644
1941 --- a/sysdeps/nacl/dl-sysdep.c
1942 +++ b/sysdeps/nacl/dl-sysdep.c
1943 @@ -87,3 +87,26 @@ _dl_start_user (void (*user_entry) (uint32_t info[]), uint32_t info[])
1944  #endif  /* SHARED */
1945  
1946  #include <elf/dl-sysdep.c>
1947 +
1948 +#include <dl-sysdep-open.h>
1949 +#include <nacl-interfaces.h>
1950 +#include <assert.h>
1951 +#include <string.h>
1952 +#include <unistd.h>
1953 +
1954 +char *
1955 +internal_function
1956 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
1957 +{
1958 +  int error = __nacl_irt_resource_open.open_resource (name, fd);
1959 +  if (error)
1960 +    return NULL;
1961 +  assert (*fd != -1);
1962 +  char *realname = __strdup (name);
1963 +  if (__glibc_unlikely (realname == NULL))
1964 +    {
1965 +      __close (*fd);
1966 +      *fd = -1;
1967 +    }
1968 +  return realname;
1969 +}
1970 diff --git a/sysdeps/nacl/nacl-interface-list.h b/sysdeps/nacl/nacl-interface-list.h
1971 index cb33751..c68faed 100644
1972 --- a/sysdeps/nacl/nacl-interface-list.h
1973 +++ b/sysdeps/nacl/nacl-interface-list.h
1974 @@ -28,7 +28,7 @@ NACL_MANDATORY_INTERFACE (rtld,
1975                           NACL_IRT_FUTEX_v0_1, nacl_irt_futex)
1976  NACL_MANDATORY_INTERFACE (rtld,
1977                           NACL_IRT_TLS_v0_1, nacl_irt_tls)
1978 -NACL_MANDATORY_INTERFACE (libc,
1979 +NACL_MANDATORY_INTERFACE (rtld,
1980                           NACL_IRT_RESOURCE_OPEN_v0_1, nacl_irt_resource_open)
1981  NACL_MANDATORY_INTERFACE (rtld,
1982                           NACL_IRT_CODE_DATA_ALLOC_v0_1,
1983 diff --git a/sysdeps/nacl/start.c b/sysdeps/nacl/start.c
1984 index a4b6dd3..8e8bc1a 100644
1985 --- a/sysdeps/nacl/start.c
1986 +++ b/sysdeps/nacl/start.c
1987 @@ -44,6 +44,10 @@
1988  /* The application defines this, of course.  */
1989  extern int main (int argc, char **argv, char **envp);
1990  
1991 +/* But maybe it defines this too, in which case it takes precedence.  */
1992 +extern int __nacl_main (int argc, char **argv, char **envp)
1993 +  __attribute__ ((weak));
1994 +
1995  /* These are defined in libc.  */
1996  extern int __libc_csu_init (int argc, char **argv, char **envp);
1997  extern void __libc_csu_fini (void);
1998 @@ -59,7 +63,7 @@ _start (uint32_t info[])
1999  {
2000    /* The generic code actually assumes that envp follows argv.  */
2001  
2002 -  __libc_start_main (&main,
2003 +  __libc_start_main (&__nacl_main ?: &main,
2004                      nacl_startup_argc (info),
2005                      nacl_startup_argv (info),
2006                      nacl_startup_auxv (info),
2007 diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
2008 index 6509f5c..9edf056 100644
2009 --- a/sysdeps/posix/opendir.c
2010 +++ b/sysdeps/posix/opendir.c
2011 @@ -105,7 +105,7 @@ need_isdir_precheck (void)
2012      tryopen_o_directory ();
2013  
2014    /* We can skip the expensive `stat' call if O_DIRECTORY works.  */
2015 -  return o_directory_works > 0;
2016 +  return o_directory_works < 0;
2017  #endif
2018    return true;
2019  }
2020 diff --git a/sysdeps/powerpc/nptl/elide.h b/sysdeps/powerpc/nptl/elide.h
2021 index 389f5a5..2e1e443 100644
2022 --- a/sysdeps/powerpc/nptl/elide.h
2023 +++ b/sysdeps/powerpc/nptl/elide.h
2024 @@ -23,67 +23,78 @@
2025  # include <htm.h>
2026  # include <elision-conf.h>
2027  
2028 -/* Returns true if the lock defined by is_lock_free as elided.
2029 -   ADAPT_COUNT is a pointer to per-lock state variable. */
2030 -
2031 +/* Get the new value of adapt_count according to the elision
2032 +   configurations.  Returns true if the system should retry again or false
2033 +   otherwise.  */
2034  static inline bool
2035 -__elide_lock (uint8_t *adapt_count, int is_lock_free)
2036 +__get_new_count (uint8_t *adapt_count, int attempt)
2037  {
2038 -  if (*adapt_count > 0)
2039 +  /* A persistent failure indicates that a retry will probably
2040 +     result in another failure.  Use normal locking now and
2041 +     for the next couple of calls.  */
2042 +  if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2043      {
2044 -      (*adapt_count)--;
2045 +      if (__elision_aconf.skip_lock_internal_abort > 0)
2046 +       *adapt_count = __elision_aconf.skip_lock_internal_abort;
2047        return false;
2048      }
2049 -
2050 -  for (int i = __elision_aconf.try_tbegin; i > 0; i--)
2051 -    {
2052 -      if (__builtin_tbegin (0))
2053 -       {
2054 -         if (is_lock_free)
2055 -           return true;
2056 -         /* Lock was busy.  */
2057 -         __builtin_tabort (_ABORT_LOCK_BUSY);
2058 -       }
2059 -      else
2060 -       {
2061 -         /* A persistent failure indicates that a retry will probably
2062 -            result in another failure.  Use normal locking now and
2063 -            for the next couple of calls.  */
2064 -         if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2065 -           {
2066 -             if (__elision_aconf.skip_lock_internal_abort > 0)
2067 -               *adapt_count = __elision_aconf.skip_lock_internal_abort;
2068 -             break;
2069 -           }
2070 -         /* Same logic as above, but for a number of temporary failures in a
2071 -            a row.  */
2072 -         else if (__elision_aconf.skip_lock_out_of_tbegin_retries > 0
2073 -                  && __elision_aconf.try_tbegin > 0)
2074 -           *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries;
2075 -       }
2076 -     }
2077 -
2078 -  return false;
2079 +  /* Same logic as above, but for a number of temporary failures in a
2080 +     a row.  */
2081 +  else if (attempt <= 1 && __elision_aconf.skip_lock_out_of_tbegin_retries > 0
2082 +          && __elision_aconf.try_tbegin > 0)
2083 +    *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries;
2084 +  return true;
2085  }
2086  
2087 -# define ELIDE_LOCK(adapt_count, is_lock_free) \
2088 -  __elide_lock (&(adapt_count), is_lock_free)
2089 -
2090 -
2091 -static inline bool
2092 -__elide_trylock (uint8_t *adapt_count, int is_lock_free, int write)
2093 -{
2094 -  if (__elision_aconf.try_tbegin > 0)
2095 -    {
2096 -      if (write)
2097 -       __builtin_tabort (_ABORT_NESTED_TRYLOCK);
2098 -      return __elide_lock (adapt_count, is_lock_free);
2099 -    }
2100 -  return false;
2101 -}
2102 +/* CONCURRENCY NOTES:
2103 +
2104 +   The evaluation of the macro expression is_lock_free encompasses one or
2105 +   more loads from memory locations that are concurrently modified by other
2106 +   threads.  For lock elision to work, this evaluation and the rest of the
2107 +   critical section protected by the lock must be atomic because an
2108 +   execution with lock elision must be equivalent to an execution in which
2109 +   the lock would have been actually acquired and released.  Therefore, we
2110 +   evaluate is_lock_free inside of the transaction that represents the
2111 +   critical section for which we want to use lock elision, which ensures
2112 +   the atomicity that we require.  */
2113 +
2114 +/* Returns 0 if the lock defined by is_lock_free was elided.
2115 +   ADAPT_COUNT is a per-lock state variable.  */
2116 +# define ELIDE_LOCK(adapt_count, is_lock_free)                         \
2117 +  ({                                                                   \
2118 +    int ret = 0;                                                       \
2119 +    if (adapt_count > 0)                                               \
2120 +      (adapt_count)--;                                                 \
2121 +    else                                                               \
2122 +      for (int i = __elision_aconf.try_tbegin; i > 0; i--)             \
2123 +       {                                                               \
2124 +         if (__builtin_tbegin (0))                                     \
2125 +           {                                                           \
2126 +             if (is_lock_free)                                         \
2127 +               {                                                       \
2128 +                 ret = 1;                                              \
2129 +                 break;                                                \
2130 +               }                                                       \
2131 +             __builtin_tabort (_ABORT_LOCK_BUSY);                      \
2132 +           }                                                           \
2133 +         else                                                          \
2134 +           if (!__get_new_count (&adapt_count,i))                      \
2135 +             break;                                                    \
2136 +       }                                                               \
2137 +    ret;                                                               \
2138 +  })
2139  
2140  # define ELIDE_TRYLOCK(adapt_count, is_lock_free, write)       \
2141 -  __elide_trylock (&(adapt_count), is_lock_free, write)
2142 +  ({                                                           \
2143 +    int ret = 0;                                               \
2144 +    if (__elision_aconf.try_tbegin > 0)                                \
2145 +      {                                                                \
2146 +       if (write)                                              \
2147 +         __builtin_tabort (_ABORT_NESTED_TRYLOCK);             \
2148 +       ret = ELIDE_LOCK (adapt_count, is_lock_free);           \
2149 +      }                                                                \
2150 +    ret;                                                       \
2151 +  })
2152  
2153  
2154  static inline bool
2155 diff --git a/sysdeps/sparc/sparc32/sem_open.c b/sysdeps/sparc/sparc32/sem_open.c
2156 index 16cb9ad..59df2d7 100644
2157 --- a/sysdeps/sparc/sparc32/sem_open.c
2158 +++ b/sysdeps/sparc/sparc32/sem_open.c
2159 @@ -29,6 +29,7 @@
2160  #include <sys/mman.h>
2161  #include <sys/stat.h>
2162  #include "semaphoreP.h"
2163 +#include <futex-internal.h>
2164  #include <shm-directory.h>
2165  
2166  
2167 diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
2168 index 58c8b32..aa20e22 100644
2169 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
2170 +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
2171 @@ -1822,9 +1822,6 @@ GLIBC_2.17
2172  GLIBC_2.18
2173   GLIBC_2.18 A
2174   __cxa_thread_atexit_impl F
2175 -GLIBC_2.22
2176 - GLIBC_2.22 A
2177 - fmemopen F
2178  GLIBC_2.2
2179   GLIBC_2.2 A
2180   _IO_adjust_wcolumn F
2181 @@ -2015,6 +2012,9 @@ GLIBC_2.2.4
2182  GLIBC_2.2.6
2183   GLIBC_2.2.6 A
2184   __nanosleep F
2185 +GLIBC_2.22
2186 + GLIBC_2.22 A
2187 + fmemopen F
2188  GLIBC_2.3
2189   GLIBC_2.3 A
2190   __ctype_b_loc F
2191 diff --git a/sysdeps/unix/sysv/linux/hppa/bits/atomic.h b/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
2192 index abde83e..6e73504 100644
2193 --- a/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
2194 +++ b/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
2195 @@ -56,42 +56,41 @@ typedef uintmax_t uatomic_max_t;
2196  #define _LWS "0xb0"
2197  #define _LWS_CAS "0"
2198  /* Note r31 is the link register.  */
2199 -#define _LWS_CLOBBER "r1", "r26", "r25", "r24", "r23", "r22", "r21", "r20", "r28", "r31", "memory"
2200 +#define _LWS_CLOBBER "r1", "r23", "r22", "r20", "r31", "memory"
2201  /* String constant for -EAGAIN.  */
2202  #define _ASM_EAGAIN "-11"
2203  /* String constant for -EDEADLOCK.  */
2204  #define _ASM_EDEADLOCK "-45"
2205  
2206  #if __ASSUME_LWS_CAS
2207 -/* The only basic operation needed is compare and exchange.  */
2208 +/* The only basic operation needed is compare and exchange.  The mem
2209 +   pointer must be word aligned.  */
2210  # define atomic_compare_and_exchange_val_acq(mem, newval, oldval)      \
2211    ({                                                                   \
2212 -     volatile int lws_errno;                                           \
2213 -     __typeof__ (*mem) lws_ret;                                                \
2214 -     asm volatile(                                                     \
2215 +     register long lws_errno asm("r21");                               \
2216 +     register unsigned long lws_ret asm("r28");                                \
2217 +     register unsigned long lws_mem asm("r26") = (unsigned long)(mem); \
2218 +     register unsigned long lws_old asm("r25") = (unsigned long)(oldval);\
2219 +     register unsigned long lws_new asm("r24") = (unsigned long)(newval);\
2220 +     __asm__ __volatile__(                                             \
2221         "0:                                     \n\t"                   \
2222 -       "copy   %2, %%r26                       \n\t"                   \
2223 -       "copy   %3, %%r25                       \n\t"                   \
2224 -       "copy   %4, %%r24                       \n\t"                   \
2225         "ble    " _LWS "(%%sr2, %%r0)           \n\t"                   \
2226         "ldi    " _LWS_CAS ", %%r20             \n\t"                   \
2227 -       "ldi    " _ASM_EAGAIN ", %%r24          \n\t"                   \
2228 -       "cmpb,=,n %%r24, %%r21, 0b              \n\t"                   \
2229 +       "ldi    " _ASM_EAGAIN ", %%r20          \n\t"                   \
2230 +       "cmpb,=,n %%r20, %%r21, 0b              \n\t"                   \
2231         "nop                                    \n\t"                   \
2232 -       "ldi    " _ASM_EDEADLOCK ", %%r25       \n\t"                   \
2233 -       "cmpb,=,n %%r25, %%r21, 0b              \n\t"                   \
2234 +       "ldi    " _ASM_EDEADLOCK ", %%r20       \n\t"                   \
2235 +       "cmpb,=,n %%r20, %%r21, 0b              \n\t"                   \
2236         "nop                                    \n\t"                   \
2237 -       "stw    %%r28, %0                       \n\t"                   \
2238 -       "stw    %%r21, %1                       \n\t"                   \
2239 -       : "=m" (lws_ret), "=m" (lws_errno)                              \
2240 -        : "r" (mem), "r" (oldval), "r" (newval)                                \
2241 +       : "=r" (lws_ret), "=r" (lws_errno)                              \
2242 +       : "r" (lws_mem), "r" (lws_old), "r" (lws_new)                   \
2243         : _LWS_CLOBBER                                                  \
2244       );                                                                        \
2245                                                                         \
2246 -     if(lws_errno == -EFAULT || lws_errno == -ENOSYS)                  \
2247 +     if (lws_errno == -EFAULT || lws_errno == -ENOSYS)                 \
2248         ABORT_INSTRUCTION;                                              \
2249                                                                         \
2250 -     lws_ret;                                                          \
2251 +     (__typeof (oldval)) lws_ret;                                      \
2252     })
2253  
2254  # define atomic_compare_and_exchange_bool_acq(mem, newval, oldval)     \
2255 diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
2256 index cf0ad90..224e1f3 100644
2257 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
2258 +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
2259 @@ -95,9 +95,6 @@ GLIBC_2.18
2260  GLIBC_2.19
2261   GLIBC_2.19 A
2262   fanotify_mark F
2263 -GLIBC_2.22
2264 - GLIBC_2.22 A
2265 - fmemopen F
2266  GLIBC_2.2
2267   GLIBC_2.2 A
2268   _Exit F
2269 @@ -1863,6 +1860,9 @@ GLIBC_2.2.4
2270  GLIBC_2.2.6
2271   GLIBC_2.2.6 A
2272   __nanosleep F
2273 +GLIBC_2.22
2274 + GLIBC_2.22 A
2275 + fmemopen F
2276  GLIBC_2.3
2277   GLIBC_2.3 A
2278   __ctype_b_loc F
2279 diff --git a/sysdeps/unix/sysv/linux/hppa/syscall.c b/sysdeps/unix/sysv/linux/hppa/syscall.c
2280 index aff67a8..958fa47 100644
2281 --- a/sysdeps/unix/sysv/linux/hppa/syscall.c
2282 +++ b/sysdeps/unix/sysv/linux/hppa/syscall.c
2283 @@ -43,9 +43,10 @@ syscall (long int __sysno, ...)
2284    va_end (args);
2285  
2286    {
2287 +    LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
2288      register unsigned long int __res asm("r28");
2289      PIC_REG_DEF
2290 -    LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
2291 +    LOAD_REGS_6
2292      asm volatile (SAVE_ASM_PIC
2293                   "     ble  0x100(%%sr2, %%r0) \n"
2294                   "     copy %1, %%r20          \n"
2295 diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
2296 index d20a04b..cb1f163 100644
2297 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
2298 +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
2299 @@ -400,9 +400,10 @@ L(pre_end):                                        ASM_LINE_SEP    \
2300  ({                                                                     \
2301         long __sys_res;                                                 \
2302         {                                                               \
2303 +               LOAD_ARGS_##nr(args)                                    \
2304                 register unsigned long __res asm("r28");                \
2305                 PIC_REG_DEF                                             \
2306 -               LOAD_ARGS_##nr(args)                                    \
2307 +               LOAD_REGS_##nr                                          \
2308                 /* FIXME: HACK save/load r19 around syscall */          \
2309                 asm volatile(                                           \
2310                         SAVE_ASM_PIC                                    \
2311 @@ -425,9 +426,10 @@ L(pre_end):                                        ASM_LINE_SEP    \
2312  ({                                                                     \
2313         long __sys_res;                                                 \
2314         {                                                               \
2315 +               LOAD_ARGS_##nr(args)                                    \
2316                 register unsigned long __res asm("r28");                \
2317                 PIC_REG_DEF                                             \
2318 -               LOAD_ARGS_##nr(args)                                    \
2319 +               LOAD_REGS_##nr                                          \
2320                 /* FIXME: HACK save/load r19 around syscall */          \
2321                 asm volatile(                                           \
2322                         SAVE_ASM_PIC                                    \
2323 @@ -443,27 +445,44 @@ L(pre_end):                                       ASM_LINE_SEP    \
2324         __sys_res;                                                      \
2325   })
2326  
2327 -
2328 -
2329  #define LOAD_ARGS_0()
2330 -#define LOAD_ARGS_1(r26)                                               \
2331 -  register unsigned long __r26 __asm__("r26") = (unsigned long)(r26);  \
2332 +#define LOAD_REGS_0
2333 +#define LOAD_ARGS_1(a1)                                                        \
2334 +  register unsigned long __x26 = (unsigned long)(a1);                  \
2335    LOAD_ARGS_0()
2336 -#define LOAD_ARGS_2(r26,r25)                                           \
2337 -  register unsigned long __r25 __asm__("r25") = (unsigned long)(r25);  \
2338 -  LOAD_ARGS_1(r26)
2339 -#define LOAD_ARGS_3(r26,r25,r24)                                       \
2340 -  register unsigned long __r24 __asm__("r24") = (unsigned long)(r24);  \
2341 -  LOAD_ARGS_2(r26,r25)
2342 -#define LOAD_ARGS_4(r26,r25,r24,r23)                                   \
2343 -  register unsigned long __r23 __asm__("r23") = (unsigned long)(r23);  \
2344 -  LOAD_ARGS_3(r26,r25,r24)
2345 -#define LOAD_ARGS_5(r26,r25,r24,r23,r22)                               \
2346 -  register unsigned long __r22 __asm__("r22") = (unsigned long)(r22);  \
2347 -  LOAD_ARGS_4(r26,r25,r24,r23)
2348 -#define LOAD_ARGS_6(r26,r25,r24,r23,r22,r21)                           \
2349 -  register unsigned long __r21 __asm__("r21") = (unsigned long)(r21);  \
2350 -  LOAD_ARGS_5(r26,r25,r24,r23,r22)
2351 +#define LOAD_REGS_1                                                    \
2352 +  register unsigned long __r26 __asm__("r26") = __x26;                 \
2353 +  LOAD_REGS_0
2354 +#define LOAD_ARGS_2(a1,a2)                                             \
2355 +  register unsigned long __x25 = (unsigned long)(a2);                  \
2356 +  LOAD_ARGS_1(a1)
2357 +#define LOAD_REGS_2                                                    \
2358 +  register unsigned long __r25 __asm__("r25") = __x25;                 \
2359 +  LOAD_REGS_1
2360 +#define LOAD_ARGS_3(a1,a2,a3)                                          \
2361 +  register unsigned long __x24 = (unsigned long)(a3);                  \
2362 +  LOAD_ARGS_2(a1,a2)
2363 +#define LOAD_REGS_3                                                    \
2364 +  register unsigned long __r24 __asm__("r24") = __x24;                 \
2365 +  LOAD_REGS_2
2366 +#define LOAD_ARGS_4(a1,a2,a3,a4)                                       \
2367 +  register unsigned long __x23 = (unsigned long)(a4);                  \
2368 +  LOAD_ARGS_3(a1,a2,a3)
2369 +#define LOAD_REGS_4                                                    \
2370 +  register unsigned long __r23 __asm__("r23") = __x23;                 \
2371 +  LOAD_REGS_3
2372 +#define LOAD_ARGS_5(a1,a2,a3,a4,a5)                                    \
2373 +  register unsigned long __x22 = (unsigned long)(a5);                  \
2374 +  LOAD_ARGS_4(a1,a2,a3,a4)
2375 +#define LOAD_REGS_5                                                    \
2376 +  register unsigned long __r22 __asm__("r22") = __x22;                 \
2377 +  LOAD_REGS_4
2378 +#define LOAD_ARGS_6(a1,a2,a3,a4,a5,a6)                                 \
2379 +  register unsigned long __x21 = (unsigned long)(a6);                  \
2380 +  LOAD_ARGS_5(a1,a2,a3,a4,a5)
2381 +#define LOAD_REGS_6                                                    \
2382 +  register unsigned long __r21 __asm__("r21") = __x21;                 \
2383 +  LOAD_REGS_5
2384  
2385  /* Even with zero args we use r20 for the syscall number */
2386  #define ASM_ARGS_0
2387 diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
2388 index 83c0340..9d5c542 100644
2389 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
2390 +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
2391 @@ -16,8 +16,11 @@
2392     License along with the GNU C Library; if not, see
2393     <http://www.gnu.org/licenses/>.  */
2394  
2395 +#ifndef _LINUX_MICROBLAZE_SYSDEP_H
2396 +#define _LINUX_MICROBLAZE_SYSDEP_H 1
2397 +
2398 +#include <sysdeps/unix/sysdep.h>
2399  #include <sysdeps/microblaze/sysdep.h>
2400 -#include <sys/syscall.h>
2401  
2402  /* Defines RTLD_PRIVATE_ERRNO.  */
2403  #include <dl-sysdep.h>
2404 @@ -305,3 +308,5 @@ SYSCALL_ERROR_LABEL_DCL:                            \
2405  # define PTR_DEMANGLE(var) (void) (var)
2406  
2407  #endif /* not __ASSEMBLER__ */
2408 +
2409 +#endif /* _LINUX_MICROBLAZE_SYSDEP_H */
2410 diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c
2411 index 6777123..ad8e31d 100644
2412 --- a/sysdeps/unix/sysv/linux/openat.c
2413 +++ b/sysdeps/unix/sysv/linux/openat.c
2414 @@ -68,6 +68,11 @@ __OPENAT (int fd, const char *file, int oflag, ...)
2415        va_end (arg);
2416      }
2417  
2418 +  /* We have to add the O_LARGEFILE flag for openat64.  */
2419 +#ifdef MORE_OFLAGS
2420 +  oflag |= MORE_OFLAGS;
2421 +#endif
2422 +
2423    return SYSCALL_CANCEL (openat, fd, file, oflag, mode);
2424  }
2425  libc_hidden_def (__OPENAT)
2426 diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
2427 index 7f9bcc2..c6731ca 100644
2428 --- a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
2429 +++ b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
2430 @@ -72,8 +72,7 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
2431        goto use_lock;
2432      }
2433  
2434 -  int try_begin = aconf.try_tbegin;
2435 -  while (1)
2436 +  for (int i = aconf.try_tbegin; i > 0; i--)
2437      {
2438        if (__builtin_tbegin (0))
2439         {
2440 @@ -87,21 +86,19 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
2441           /* A persistent failure indicates that a retry will probably
2442              result in another failure.  Use normal locking now and
2443              for the next couple of calls.  */
2444 -         if (try_begin-- <= 0
2445 -             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2446 +         if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
2447             {
2448               if (aconf.skip_lock_internal_abort > 0)
2449                 *adapt_count = aconf.skip_lock_internal_abort;
2450               goto use_lock;
2451             }
2452 -         /* Same logic as above, but for for a number of temporary failures
2453 -            in a row.  */
2454 -         else if (aconf.skip_lock_out_of_tbegin_retries > 0
2455 -                   && aconf.try_tbegin > 0)
2456 -           *adapt_count = aconf.skip_lock_out_of_tbegin_retries;
2457         }
2458       }
2459  
2460 +  /* Fall back to locks for a bit if retries have been exhausted */
2461 +  if (aconf.try_tbegin > 0 && aconf.skip_lock_out_of_tbegin_retries > 0)
2462 +    *adapt_count = aconf.skip_lock_out_of_tbegin_retries;
2463 +
2464  use_lock:
2465    return LLL_LOCK ((*lock), pshared);
2466  }
2467 diff --git a/sysdeps/x86/fpu/bits/math-vector.h b/sysdeps/x86/fpu/bits/math-vector.h
2468 index f9e798b..f3bfb86 100644
2469 --- a/sysdeps/x86/fpu/bits/math-vector.h
2470 +++ b/sysdeps/x86/fpu/bits/math-vector.h
2471 @@ -53,34 +53,5 @@
2472  #  undef __DECL_SIMD_powf
2473  #  define __DECL_SIMD_powf __DECL_SIMD_x86_64
2474  
2475 -/* Workaround to exclude unnecessary symbol aliases in libmvec
2476 -   while GCC creates the vector names based on scalar asm name.
2477 -   Corresponding discussion started at
2478 -   <https://gcc.gnu.org/ml/gcc/2015-06/msg00173.html>.  */
2479 -__asm__ ("_ZGVbN2v___log_finite = _ZGVbN2v_log");
2480 -__asm__ ("_ZGVcN4v___log_finite = _ZGVcN4v_log");
2481 -__asm__ ("_ZGVdN4v___log_finite = _ZGVdN4v_log");
2482 -__asm__ ("_ZGVeN8v___log_finite = _ZGVeN8v_log");
2483 -__asm__ ("_ZGVbN4v___logf_finite = _ZGVbN4v_logf");
2484 -__asm__ ("_ZGVcN8v___logf_finite = _ZGVcN8v_logf");
2485 -__asm__ ("_ZGVdN8v___logf_finite = _ZGVdN8v_logf");
2486 -__asm__ ("_ZGVeN16v___logf_finite = _ZGVeN16v_logf");
2487 -__asm__ ("_ZGVbN2v___exp_finite = _ZGVbN2v_exp");
2488 -__asm__ ("_ZGVcN4v___exp_finite = _ZGVcN4v_exp");
2489 -__asm__ ("_ZGVdN4v___exp_finite = _ZGVdN4v_exp");
2490 -__asm__ ("_ZGVeN8v___exp_finite = _ZGVeN8v_exp");
2491 -__asm__ ("_ZGVbN4v___expf_finite = _ZGVbN4v_expf");
2492 -__asm__ ("_ZGVcN8v___expf_finite = _ZGVcN8v_expf");
2493 -__asm__ ("_ZGVdN8v___expf_finite = _ZGVdN8v_expf");
2494 -__asm__ ("_ZGVeN16v___expf_finite = _ZGVeN16v_expf");
2495 -__asm__ ("_ZGVbN2vv___pow_finite = _ZGVbN2vv_pow");
2496 -__asm__ ("_ZGVcN4vv___pow_finite = _ZGVcN4vv_pow");
2497 -__asm__ ("_ZGVdN4vv___pow_finite = _ZGVdN4vv_pow");
2498 -__asm__ ("_ZGVeN8vv___pow_finite = _ZGVeN8vv_pow");
2499 -__asm__ ("_ZGVbN4vv___powf_finite = _ZGVbN4vv_powf");
2500 -__asm__ ("_ZGVcN8vv___powf_finite = _ZGVcN8vv_powf");
2501 -__asm__ ("_ZGVdN8vv___powf_finite = _ZGVdN8vv_powf");
2502 -__asm__ ("_ZGVeN16vv___powf_finite = _ZGVeN16vv_powf");
2503 -
2504  # endif
2505  #endif
2506 diff --git a/sysdeps/x86_64/fpu/Makefile b/sysdeps/x86_64/fpu/Makefile
2507 index 1ebe511..b32b852 100644
2508 --- a/sysdeps/x86_64/fpu/Makefile
2509 +++ b/sysdeps/x86_64/fpu/Makefile
2510 @@ -20,7 +20,10 @@ libmvec-support += svml_d_cos2_core svml_d_cos4_core_avx \
2511                    svml_d_pow_data svml_s_powf4_core svml_s_powf8_core_avx \
2512                    svml_s_powf8_core svml_s_powf16_core svml_s_powf_data \
2513                    svml_s_sincosf4_core svml_s_sincosf8_core_avx \
2514 -                  svml_s_sincosf8_core svml_s_sincosf16_core init-arch
2515 +                  svml_s_sincosf8_core svml_s_sincosf16_core init-arch \
2516 +                  svml_finite_alias
2517 +
2518 +libmvec-static-only-routines = svml_finite_alias
2519  endif
2520  
2521  # Variables for libmvec tests.
2522 diff --git a/sysdeps/x86_64/fpu/svml_finite_alias.S b/sysdeps/x86_64/fpu/svml_finite_alias.S
2523 new file mode 100644
2524 index 0000000..f8bcfeb
2525 --- /dev/null
2526 +++ b/sysdeps/x86_64/fpu/svml_finite_alias.S
2527 @@ -0,0 +1,59 @@
2528 +/* These aliases added as workaround to exclude unnecessary symbol
2529 +   aliases in libmvec.so while compiler creates the vector names
2530 +   based on scalar asm name.  Corresponding discussion is at
2531 +   <https://gcc.gnu.org/ml/gcc/2015-06/msg00173.html>.
2532 +   Copyright (C) 2015 Free Software Foundation, Inc.
2533 +   This file is part of the GNU C Library.
2534 +
2535 +   The GNU C Library is free software; you can redistribute it and/or
2536 +   modify it under the terms of the GNU Lesser General Public
2537 +   License as published by the Free Software Foundation; either
2538 +   version 2.1 of the License, or (at your option) any later version.
2539 +
2540 +   The GNU C Library is distributed in the hope that it will be useful,
2541 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
2542 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2543 +   Lesser General Public License for more details.
2544 +
2545 +   You should have received a copy of the GNU Lesser General Public
2546 +   License along with the GNU C Library; if not, see
2547 +   <http://www.gnu.org/licenses/>.  */
2548 +
2549 +#include <sysdep.h>
2550 +
2551 +#define ALIAS_IMPL(alias, target) \
2552 +ENTRY (alias); \
2553 +       call target; \
2554 +       ret; \
2555 +END (alias)
2556 +
2557 +       .text
2558 +ALIAS_IMPL (_ZGVbN2v___log_finite, _ZGVbN2v_log)
2559 +ALIAS_IMPL (_ZGVcN4v___log_finite, _ZGVcN4v_log)
2560 +ALIAS_IMPL (_ZGVdN4v___log_finite, _ZGVdN4v_log)
2561 +ALIAS_IMPL (_ZGVeN8v___log_finite, _ZGVeN8v_log)
2562 +
2563 +ALIAS_IMPL (_ZGVbN4v___logf_finite, _ZGVbN4v_logf)
2564 +ALIAS_IMPL (_ZGVcN8v___logf_finite, _ZGVcN8v_logf)
2565 +ALIAS_IMPL (_ZGVdN8v___logf_finite, _ZGVdN8v_logf)
2566 +ALIAS_IMPL (_ZGVeN16v___logf_finite, _ZGVeN16v_logf)
2567 +
2568 +ALIAS_IMPL (_ZGVbN2v___exp_finite, _ZGVbN2v_exp)
2569 +ALIAS_IMPL (_ZGVcN4v___exp_finite, _ZGVcN4v_exp)
2570 +ALIAS_IMPL (_ZGVdN4v___exp_finite, _ZGVdN4v_exp)
2571 +ALIAS_IMPL (_ZGVeN8v___exp_finite, _ZGVeN8v_exp)
2572 +
2573 +ALIAS_IMPL (_ZGVbN4v___expf_finite, _ZGVbN4v_expf)
2574 +ALIAS_IMPL (_ZGVcN8v___expf_finite, _ZGVcN8v_expf)
2575 +ALIAS_IMPL (_ZGVdN8v___expf_finite, _ZGVdN8v_expf)
2576 +ALIAS_IMPL (_ZGVeN16v___expf_finite, _ZGVeN16v_expf)
2577 +
2578 +ALIAS_IMPL (_ZGVbN2vv___pow_finite, _ZGVbN2vv_pow)
2579 +ALIAS_IMPL (_ZGVcN4vv___pow_finite, _ZGVcN4vv_pow)
2580 +ALIAS_IMPL (_ZGVdN4vv___pow_finite, _ZGVdN4vv_pow)
2581 +ALIAS_IMPL (_ZGVeN8vv___pow_finite, _ZGVeN8vv_pow)
2582 +
2583 +ALIAS_IMPL (_ZGVbN4vv___powf_finite, _ZGVbN4vv_powf)
2584 +ALIAS_IMPL (_ZGVcN8vv___powf_finite, _ZGVcN8vv_powf)
2585 +ALIAS_IMPL (_ZGVdN8vv___powf_finite, _ZGVdN8vv_powf)
2586 +ALIAS_IMPL (_ZGVeN16vv___powf_finite, _ZGVeN16vv_powf)
2587 diff --git a/time/strftime_l.c b/time/strftime_l.c
2588 index b48ef34..4eb647c 100644
2589 --- a/time/strftime_l.c
2590 +++ b/time/strftime_l.c
2591 @@ -510,13 +510,17 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
2592       only a few elements.  Dereference the pointers only if the format
2593       requires this.  Then it is ok to fail if the pointers are invalid.  */
2594  # define a_wkday \
2595 -  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday))
2596 +  ((const CHAR_T *) (tp->tm_wday < 0 || tp->tm_wday > 6                             \
2597 +                    ? "?" : _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)))
2598  # define f_wkday \
2599 -  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday))
2600 +  ((const CHAR_T *) (tp->tm_wday < 0 || tp->tm_wday > 6                             \
2601 +                    ? "?" : _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)))
2602  # define a_month \
2603 -  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon))
2604 +  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11                      \
2605 +                    ? "?" : _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)))
2606  # define f_month \
2607 -  ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))
2608 +  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11                      \
2609 +                    ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
2610  # define ampm \
2611    ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11                   \
2612                                  ? NLW(PM_STR) : NLW(AM_STR)))
2613 @@ -526,8 +530,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
2614  # define ap_len STRLEN (ampm)
2615  #else
2616  # if !HAVE_STRFTIME
2617 -#  define f_wkday (weekday_name[tp->tm_wday])
2618 -#  define f_month (month_name[tp->tm_mon])
2619 +#  define f_wkday (tp->tm_wday < 0 || tp->tm_wday > 6  \
2620 +                  ? "?" : weekday_name[tp->tm_wday])
2621 +#  define f_month (tp->tm_mon < 0 || tp->tm_mon > 11   \
2622 +                  ? "?" : month_name[tp->tm_mon])
2623  #  define a_wkday f_wkday
2624  #  define a_month f_month
2625  #  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
2626 @@ -1321,7 +1327,7 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
2627                   *tzset_called = true;
2628                 }
2629  # endif
2630 -             zone = tzname[tp->tm_isdst];
2631 +             zone = tp->tm_isdst <= 1 ? tzname[tp->tm_isdst] : "?";
2632             }
2633  #endif
2634           if (! zone)
2635 diff --git a/time/tst-strftime.c b/time/tst-strftime.c
2636 index 374fba4..af3ff72 100644
2637 --- a/time/tst-strftime.c
2638 +++ b/time/tst-strftime.c
2639 @@ -4,6 +4,56 @@
2640  #include <time.h>
2641  
2642  
2643 +static int
2644 +do_bz18985 (void)
2645 +{
2646 +  char buf[1000];
2647 +  struct tm ttm;
2648 +  int rc, ret = 0;
2649 +
2650 +  memset (&ttm, 1, sizeof (ttm));
2651 +  ttm.tm_zone = NULL;  /* Dereferenced directly if non-NULL.  */
2652 +  rc = strftime (buf, sizeof (buf), "%a %A %b %B %c %z %Z", &ttm);
2653 +
2654 +  if (rc == 66)
2655 +    {
2656 +      const char expected[]
2657 +       = "? ? ? ? ? ? 16843009 16843009:16843009:16843009 16844909 +467836 ?";
2658 +      if (0 != strcmp (buf, expected))
2659 +       {
2660 +         printf ("expected:\n  %s\ngot:\n  %s\n", expected, buf);
2661 +         ret += 1;
2662 +       }
2663 +    }
2664 +  else
2665 +    {
2666 +      printf ("expected 66, got %d\n", rc);
2667 +      ret += 1;
2668 +    }
2669 +
2670 +  /* Check negative values as well.  */
2671 +  memset (&ttm, 0xFF, sizeof (ttm));
2672 +  ttm.tm_zone = NULL;  /* Dereferenced directly if non-NULL.  */
2673 +  rc = strftime (buf, sizeof (buf), "%a %A %b %B %c %z %Z", &ttm);
2674 +
2675 +  if (rc == 30)
2676 +    {
2677 +      const char expected[] = "? ? ? ? ? ? -1 -1:-1:-1 1899  ";
2678 +      if (0 != strcmp (buf, expected))
2679 +       {
2680 +         printf ("expected:\n  %s\ngot:\n  %s\n", expected, buf);
2681 +         ret += 1;
2682 +       }
2683 +    }
2684 +  else
2685 +    {
2686 +      printf ("expected 30, got %d\n", rc);
2687 +      ret += 1;
2688 +    }
2689 +
2690 +  return ret;
2691 +}
2692 +
2693  static struct
2694  {
2695    const char *fmt;
2696 @@ -104,7 +154,7 @@ do_test (void)
2697         }
2698      }
2699  
2700 -  return result;
2701 +  return result + do_bz18985 ();
2702  }
2703  
2704  #define TEST_FUNCTION do_test ()
2705 diff --git a/wcsmbs/wcscoll_l.c b/wcsmbs/wcscoll_l.c
2706 index 6d9384a..87f240d 100644
2707 --- a/wcsmbs/wcscoll_l.c
2708 +++ b/wcsmbs/wcscoll_l.c
2709 @@ -23,7 +23,6 @@
2710  #define STRING_TYPE wchar_t
2711  #define USTRING_TYPE wint_t
2712  #define STRCOLL __wcscoll_l
2713 -#define STRDIFF __wcsdiff
2714  #define STRCMP __wcscmp
2715  #define WEIGHT_H "../locale/weightwc.h"
2716  #define SUFFIX WC
This page took 0.235044 seconds and 3 git commands to generate.