]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-git.patch
c78b864dc66a188267467db5945ac69ef7f5d1e1
[packages/glibc.git] / glibc-git.patch
1 diff --git a/ChangeLog b/ChangeLog
2 index cb9124e..b1816c2 100644
3 --- a/ChangeLog
4 +++ b/ChangeLog
5 @@ -1,3 +1,223 @@
6 +2015-11-20  Roland McGrath  <roland@hack.frob.com>
7 +
8 +       * sysdeps/nacl/dl-map-segments.h (_dl_map_segments): Use
9 +       __glibc_likely instead of __builtin_expect.  After falling back to
10 +       dyncode_create in a non-ET_DYN case, use the allocate_code_data
11 +       system interface to register the code pages as occupied.
12 +
13 +2015-11-14  H.J. Lu  <hongjiu.lu@intel.com>
14 +
15 +       * config.make.in (have-glob-dat-reloc): New.
16 +       * configure.ac (libc_cv_has_glob_dat): New.  Set to yes if
17 +       target supports GLOB_DAT relocaton. AC_SUBST.
18 +       * configure: Regenerated.
19 +       * elf/Makefile (tests): Add tst-prelink.
20 +       (tests-special): Add $(objpfx)tst-prelink-cmp.out.
21 +       (tst-prelink-ENV): New.
22 +       ($(objpfx)tst-prelink-conflict.out): Likewise.
23 +       ($(objpfx)tst-prelink-cmp.out): Likewise.
24 +       * sysdeps/x86/tst-prelink.c: Moved to ...
25 +       * elf/tst-prelink.c: Here.
26 +       * sysdeps/x86/tst-prelink.exp: Moved to ...
27 +       * elf/tst-prelink.exp: Here.
28 +       * sysdeps/x86/Makefile (tests): Don't add tst-prelink.
29 +       (tst-prelink-ENV): Removed.
30 +       ($(objpfx)tst-prelink-conflict.out): Likewise.
31 +       ($(objpfx)tst-prelink-cmp.out): Likewise.
32 +       (tests-special): Don't add $(objpfx)tst-prelink-cmp.out.
33 +
34 +2015-11-10  Roland McGrath  <roland@hack.frob.com>
35 +
36 +       * elf/dl-load.c (open_verify): Take new argument FD.
37 +       Skip __open call if passed FD is not -1.
38 +       (_dl_map_object, open_path): Update callers.
39 +       * elf/dl-sysdep-open.h: New file.
40 +       * elf/dl-load.c: Include it.
41 +       (_dl_map_object): Try _dl_sysdep_open_object before ldconfig cache.
42 +       * sysdeps/nacl/dl-sysdep.c (_dl_sysdep_open_object): New function.
43 +       * sysdeps/nacl/dl-sysdep-open.h: New file.
44 +       * sysdeps/nacl/nacl-interface-list.h: Move nacl_irt_resource_open
45 +       from libc to rtld.
46 +
47 +2015-11-10  H.J. Lu  <hongjiu.lu@intel.com>
48 +
49 +       [BZ #19178]
50 +       * sysdeps/x86/Makefile (tests): Add tst-prelink.
51 +       (tst-prelink-ENV): New.
52 +       ($(objpfx)tst-prelink-conflict.out): Likewise.
53 +       ($(objpfx)tst-prelink-cmp.out): Likewise.
54 +       (tests-special): Add $(objpfx)tst-prelink-cmp.out.
55 +       * sysdeps/x86/tst-prelink.c: New file.
56 +       * sysdeps/x86/tst-prelink.exp: Likewise.
57 +
58 +2015-11-07  H.J. Lu  <hongjiu.lu@intel.com>
59 +
60 +       [BZ #19178]
61 +       * elf/dl-lookup.c (RTYPE_CLASS_VALID): New.
62 +       (RTYPE_CLASS_PLT): Likewise.
63 +       (RTYPE_CLASS_COPY): Likewise.
64 +       (RTYPE_CLASS_TLS): Likewise.
65 +       (_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID
66 +       to set relocation type class for DL_DEBUG_PRELINK.  Keep only
67 +       ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY bits for
68 +       DL_DEBUG_PRELINK.
69 +
70 +2015-10-20  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
71 +
72 +       [BZ #18743]
73 +       * sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
74 +       code to...
75 +       (ELIDE_LOCK): ...here.
76 +       (__get_new_count): New function with part of the code from
77 +       __elide_lock that updates the value of adapt_count after a
78 +       transaction abort.
79 +       (__elided_trylock): Moved this code to...
80 +       (ELIDE_TRYLOCK): ...here.
81 +
82 +2015-10-06  Florian Weimer  <fweimer@redhat.com>
83 +
84 +       [BZ #19018]
85 +       * stdlib/cxa_thread_atexit_impl.c (__cxa_thread_atexit_impl):
86 +       Mangle function pointer before storing it.
87 +       (__call_tls_dtors): Demangle function pointer before calling it.
88 +
89 +2015-10-15  Florian Weimer  <fweimer@redhat.com>
90 +
91 +       [BZ #18928]
92 +       * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
93 +       _dl_pointer_guard member.
94 +       * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
95 +       initializer.
96 +       (security_init): Always set up pointer guard.
97 +       (process_envvars): Do not process LD_POINTER_GUARD.
98 +
99 +2015-10-09  Carlos O'Donell  <carlos@redhat.com>
100 +
101 +       [BZ #18589]
102 +       * string/bug-strcoll2.c: Adjust copyright, and remove contributed by.
103 +       * string/Makefile ($(objpfx)bug-strcoll2.out): Depend on
104 +       $(gen-locales).
105 +
106 +2015-10-08  Carlos O'Donell  <carlos@redhat.com>
107 +
108 +       [BZ #18589]
109 +       * string/Makefile (tests): Add bug-strcoll2.
110 +       (LOCALES): Add cs_CZ.UTF-8.
111 +
112 +2015-09-28  Martin Sebor  <msebor@redhat.com>
113 +
114 +       [BZ #18969]
115 +       * string/Makefile (LOCALES): Define.
116 +       (gen-locales.mk): Include.
117 +       (test-strcasecmp.out, test-strncasecmp.out, tst-strxfrm.out)
118 +       (tst-strxfrm2.out): Add deppendency on $(gen-locales).
119 +       * string/tst-strxfrm2.c (do_test): Print the name of the locale
120 +       on setlocale failure.
121 +
122 +2015-10-08  Carlos O'Donell  <carlos@redhat.com>
123 +
124 +       [BZ #18589]
125 +       * string/bug-strcoll2.c: New file.
126 +       * locale/categories.def: Revert commit
127 +       f13c2a8dff2329c6692a80176262ceaaf8a6f74e.
128 +       * locale/langinfo.h: Likewise.
129 +       * locale/localeinfo.h: Likewise.
130 +       * locale/C-collate.c: Likewise.
131 +       * programs/ld-collate.c (collate_output): Likewise.
132 +       * string/strcoll_l.c (STRDIFF): Likewise.
133 +       (STRCOLL): Likewise.
134 +       * wcsmbs/wcscoll_l.c: Likewise.
135 +
136 +2015-09-15  Roland McGrath  <roland@hack.frob.com>
137 +
138 +       * misc/sys/param.h [!MAXHOSTNAMELEN && HOST_NAME_MAX]
139 +       (MAXHOSTNAMELEN): Define it to HOST_NAME_MAX.
140 +
141 +2015-09-11  Roland McGrath  <roland@hack.frob.com>
142 +
143 +       * sysdeps/nacl/Makefile [$(subdir) = misc] (sysdep_headers):
144 +       Use 'override' keyword to freeze the value here, preventing
145 +       the addition of sys/mtio.h by sysdeps/gnu/Makefile.
146 +
147 +2015-09-04  Roland McGrath  <roland@hack.frob.com>
148 +
149 +       [BZ #18921]
150 +       * sysdeps/posix/opendir.c (need_isdir_precheck) [O_DIRECTORY]:
151 +       Fix inverted sense of test of 'o_directory_works' value.
152 +       Reported by Pádraig Brady <P@draigBrady.com>, diagnosed by
153 +       Bernhard Voelker <mail@bernhard-voelker.de>.
154 +
155 +2015-08-31  Brett Neumeier <brett@neumeier.us>
156 +
157 +       [BZ #18870]
158 +       * sysdeps/sparc/sparc32/sem_open.c: Add missing #include
159 +
160 +2015-08-28  Mike Frysinger  <vapier@gentoo.org>
161 +
162 +       [BZ #18887]
163 +       * misc/Makefile (tests): Add tst-mntent-blank-corrupt and
164 +       tst-mntent-blank-passno.
165 +       * misc/mntent_r.c (__getmntent_r): Do not read past buffer[0].
166 +       * misc/tst-mntent-blank-corrupt.c: New test.
167 +       * misc/tst-mntent-blank-passno.c: New test ripped from ...
168 +       * misc/tst-mntent.c (do_test): ... here.
169 +
170 +2015-08-25  Roland McGrath  <roland@hack.frob.com>
171 +
172 +       * sysdeps/nacl/start.c (_start): Call __nacl_main instead of main
173 +       if the weak reference is not null.
174 +
175 +2015-08-19  Andrew Senkevich  <andrew.senkevich@intel.com>
176 +
177 +       [BZ #18796]
178 +       * scripts/test-installation.pl: Don't add -lmvec to build options
179 +       if libmvec wasn't built.
180 +       * NEWS: Mention this fix.
181 +
182 +2015-08-10  Maxim Ostapenko  <m.ostapenko@partner.samsung.com>
183 +
184 +       [BZ #18778]
185 +       * elf/Makefile (tests): Add Add tst-nodelete2.
186 +       (modules-names): Add tst-nodelete2mod.
187 +       (tst-nodelete2mod.so-no-z-defs): New.
188 +       ($(objpfx)tst-nodelete2): Likewise.
189 +       ($(objpfx)tst-nodelete2.out): Likewise.
190 +       (LDFLAGS-tst-nodelete2): Likewise.
191 +       * elf/dl-close.c (_dl_close_worker): Move DF_1_NODELETE clearing
192 +       out of loop through all loaded libraries.
193 +       * elf/tst-nodelete2.c: New file.
194 +       * elf/tst-nodelete2mod.c: Likewise.
195 +
196 +2015-08-10  Andreas Schwab  <schwab@suse.de>
197 +
198 +       [BZ #18781]
199 +       * sysdeps/unix/sysv/linux/openat.c (__OPENAT) [MORE_OFLAGS]: Add
200 +       MORE_OFLAGS to oflag.
201 +       * io/test-lfs.c (do_test): Test openat64.
202 +
203 +2015-08-08  John David Anglin  <danglin@gcc.gnu.org>
204 +
205 +       [BZ #18787]
206 +       * sysdeps/unix/sysv/linux/hppa/bits/atomic.h (_LWS_CLOBBER): Revise
207 +       clobber registers.
208 +       (atomic_compare_and_exchange_val_acq): Use register asms to assign
209 +       operand registers.  Use register %r20 for EAGAIN and EDEADLOCK checks.
210 +       Cast return to __typeof (oldval).
211 +
212 +2015-08-08  Mike Frysinger  <vapier@gentoo.org>
213 +
214 +       * sysdeps/unix/sysv/linux/microblaze/sysdep.h: Wrap the whole file
215 +       in _LINUX_MICROBLAZE_SYSDEP_H defines.  Include sysdeps/unix/sysdep.h
216 +       and delete sys/syscall.h include.
217 +
218 +2015-08-07  Mike Frysinger  <vapier@gentoo.org>
219 +
220 +       * sysdeps/hppa/dl-symaddr.c (_dl_symbol_address): Add rtld_hidden_def.
221 +
222 +2015-08-05  Zack Weinberg  <zackw@panix.com>
223 +
224 +       * misc/regexp.h: Update comments.
225 +
226  2015-08-05  Carlos O'Donell  <carlos@systemhalted.org>
227  
228         * version.h (RELEASE): Set to "stable".
229 diff --git a/NEWS b/NEWS
230 index 4c31de7..30fe67c 100644
231 --- a/NEWS
232 +++ b/NEWS
233 @@ -5,6 +5,16 @@ See the end for copying conditions.
234  Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
235  using `glibc' in the "product" field.
236  \f
237 +Version 2.22.1
238 +
239 +* The following bugs are resolved with this release:
240 +
241 +  18589, 18743, 18778, 18781, 18787, 18796, 18870, 18887, 18921, 18928,
242 +  18969, 19018, 19178.
243 +
244 +* The LD_POINTER_GUARD environment variable can no longer be used to
245 +  disable the pointer guard feature.  It is always enabled.
246 +\f
247  Version 2.22
248  
249  * The following bugs are resolved with this release:
250 @@ -84,7 +94,7 @@ Version 2.22
251    release.  Use of this header will trigger a deprecation warning.
252    Application developers should update their code to use <regex.h> instead.
253  
254 -  This header was formerly part of SUSv2, but was deprecated in 1997 and
255 +  This header was formerly part of SUS, but was deprecated in 1994 and
256    removed from the standard in 2001.  Also, the glibc implementation
257    leaks memory.  See BZ#18681 for more details.
258  \f
259 diff --git a/config.make.in b/config.make.in
260 index a9f5696..46cd9bb 100644
261 --- a/config.make.in
262 +++ b/config.make.in
263 @@ -51,6 +51,7 @@ have-z-combreloc = @libc_cv_z_combreloc@
264  have-z-execstack = @libc_cv_z_execstack@
265  have-Bgroup = @libc_cv_Bgroup@
266  have-protected-data = @libc_cv_protected_data@
267 +have-glob-dat-reloc = @libc_cv_has_glob_dat@
268  with-fp = @with_fp@
269  old-glibc-headers = @old_glibc_headers@
270  unwind-find-fde = @libc_cv_gcc_unwind_find_fde@
271 diff --git a/configure b/configure
272 index 45cc7cb..4f87b31 100755
273 --- a/configure
274 +++ b/configure
275 @@ -628,6 +628,7 @@ gnu89_inline
276  libc_cv_ssp
277  fno_unit_at_a_time
278  libc_cv_output_format
279 +libc_cv_has_glob_dat
280  libc_cv_hashstyle
281  libc_cv_fpie
282  libc_cv_z_execstack
283 @@ -6335,6 +6336,39 @@ $as_echo "$libc_cv_use_default_link" >&6; }
284    use_default_link=$libc_cv_use_default_link
285  fi
286  
287 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
288 +$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
289 +if ${libc_cv_has_glob_dat+:} false; then :
290 +  $as_echo_n "(cached) " >&6
291 +else
292 +  cat > conftest.c <<EOF
293 +extern int mumble;
294 +int foo (void) { return mumble; }
295 +EOF
296 +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
297 +                       -fPIC -shared -o conftest.so conftest.c
298 +                       -nostdlib -nostartfiles
299 +                       1>&5'
300 +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
301 +  (eval $ac_try) 2>&5
302 +  ac_status=$?
303 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
304 +  test $ac_status = 0; }; }
305 +then
306 +  if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
307 +    libc_cv_has_glob_dat=yes
308 +  else
309 +    libc_cv_has_glob_dat=no
310 +  fi
311 +else
312 +  libc_cv_has_glob_dat=no
313 +fi
314 +rm -f conftest*
315 +fi
316 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_has_glob_dat" >&5
317 +$as_echo "$libc_cv_has_glob_dat" >&6; }
318 +
319 +
320  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
321  $as_echo_n "checking linker output format... " >&6; }
322  if ${libc_cv_output_format+:} false; then :
323 diff --git a/configure.ac b/configure.ac
324 index 7e9383a..8be612d 100644
325 --- a/configure.ac
326 +++ b/configure.ac
327 @@ -1535,6 +1535,29 @@ $ac_try"
328    use_default_link=$libc_cv_use_default_link
329  fi
330  
331 +AC_CACHE_CHECK(for GLOB_DAT reloc,
332 +              libc_cv_has_glob_dat, [dnl
333 +cat > conftest.c <<EOF
334 +extern int mumble;
335 +int foo (void) { return mumble; }
336 +EOF
337 +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
338 +                       -fPIC -shared -o conftest.so conftest.c
339 +                       -nostdlib -nostartfiles
340 +                       1>&AS_MESSAGE_LOG_FD])
341 +then
342 +dnl look for GLOB_DAT relocation.
343 +  if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
344 +    libc_cv_has_glob_dat=yes
345 +  else
346 +    libc_cv_has_glob_dat=no
347 +  fi
348 +else
349 +  libc_cv_has_glob_dat=no
350 +fi
351 +rm -f conftest*])
352 +AC_SUBST(libc_cv_has_glob_dat)
353 +
354  AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
355  if libc_cv_output_format=`
356  ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
357 diff --git a/elf/Makefile b/elf/Makefile
358 index 4ceeaf8..a2c43bc 100644
359 --- a/elf/Makefile
360 +++ b/elf/Makefile
361 @@ -148,7 +148,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
362          tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
363          tst-nodelete) \
364          tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
365 -        tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened
366 +        tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
367 +        tst-nodelete2
368  #       reldep9
369  ifeq ($(build-hardcoded-path-in-tests),yes)
370  tests += tst-dlopen-aout
371 @@ -218,7 +219,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
372                 tst-initorder2d \
373                 tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
374                 tst-array5dep tst-null-argv-lib \
375 -               tst-tlsalign-lib tst-nodelete-opened-lib
376 +               tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod
377  ifeq (yes,$(have-protected-data))
378  modules-names += tst-protected1moda tst-protected1modb
379  tests += tst-protected1a tst-protected1b
380 @@ -292,6 +293,13 @@ check-abi: $(objpfx)check-abi-ld.out
381  tests-special += $(objpfx)check-abi-ld.out
382  update-abi: update-abi-ld
383  
384 +ifeq ($(have-glob-dat-reloc),yes)
385 +tests += tst-prelink
386 +ifeq ($(run-built-tests),yes)
387 +tests-special += $(objpfx)tst-prelink-cmp.out
388 +endif
389 +endif
390 +
391  include ../Rules
392  
393  ifeq (yes,$(build-shared))
394 @@ -594,6 +602,7 @@ tst-auditmod9b.so-no-z-defs = yes
395  tst-nodelete-uniquemod.so-no-z-defs = yes
396  tst-nodelete-rtldmod.so-no-z-defs = yes
397  tst-nodelete-zmod.so-no-z-defs = yes
398 +tst-nodelete2mod.so-no-z-defs = yes
399  
400  ifeq ($(build-shared),yes)
401  # Build all the modules even when not actually running test programs.
402 @@ -1164,6 +1173,11 @@ $(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
403  LDFLAGS-tst-nodelete = -rdynamic
404  LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
405  
406 +$(objpfx)tst-nodelete2: $(libdl)
407 +$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
408 +
409 +LDFLAGS-tst-nodelete2 = -rdynamic
410 +
411  $(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
412         cmp $^ > $@; \
413         $(evaluate-test)
414 @@ -1205,3 +1219,13 @@ $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
415  $(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
416         cmp $< /dev/null > $@; \
417         $(evaluate-test)
418 +
419 +tst-prelink-ENV = LD_TRACE_PRELINKING=1
420 +
421 +$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
422 +       grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
423 +
424 +$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
425 +                             $(objpfx)tst-prelink-conflict.out
426 +       cmp $^ > $@; \
427 +       $(evaluate-test)
428 diff --git a/elf/dl-close.c b/elf/dl-close.c
429 index 9105277..c897247 100644
430 --- a/elf/dl-close.c
431 +++ b/elf/dl-close.c
432 @@ -144,6 +144,14 @@ _dl_close_worker (struct link_map *map, bool force)
433    char done[nloaded];
434    struct link_map *maps[nloaded];
435  
436 +  /* Clear DF_1_NODELETE to force object deletion.  We don't need to touch
437 +     l_tls_dtor_count because forced object deletion only happens when an
438 +     error occurs during object load.  Destructor registration for TLS
439 +     non-POD objects should not have happened till then for this
440 +     object.  */
441 +  if (force)
442 +    map->l_flags_1 &= ~DF_1_NODELETE;
443 +
444    /* Run over the list and assign indexes to the link maps and enter
445       them into the MAPS array.  */
446    int idx = 0;
447 @@ -153,13 +161,6 @@ _dl_close_worker (struct link_map *map, bool force)
448        maps[idx] = l;
449        ++idx;
450  
451 -      /* Clear DF_1_NODELETE to force object deletion.  We don't need to touch
452 -        l_tls_dtor_count because forced object deletion only happens when an
453 -        error occurs during object load.  Destructor registration for TLS
454 -        non-POD objects should not have happened till then for this
455 -        object.  */
456 -      if (force)
457 -       l->l_flags_1 &= ~DF_1_NODELETE;
458      }
459    assert (idx == nloaded);
460  
461 diff --git a/elf/dl-load.c b/elf/dl-load.c
462 index 0c052e4..7e6f4c5 100644
463 --- a/elf/dl-load.c
464 +++ b/elf/dl-load.c
465 @@ -42,6 +42,7 @@
466  #include <dl-map-segments.h>
467  #include <dl-unmap-segments.h>
468  #include <dl-machine-reject-phdr.h>
469 +#include <dl-sysdep-open.h>
470  
471  
472  #include <endian.h>
473 @@ -1471,9 +1472,13 @@ print_search_path (struct r_search_path_elem **list,
474     ignore only ELF files for other architectures.  Non-ELF files and
475     ELF files with different header information cause fatal errors since
476     this could mean there is something wrong in the installation and the
477 -   user might want to know about this.  */
478 +   user might want to know about this.
479 +
480 +   If FD is not -1, then the file is already open and FD refers to it.
481 +   In that case, FD is consumed for both successful and error returns.  */
482  static int
483 -open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
484 +open_verify (const char *name, int fd,
485 +             struct filebuf *fbp, struct link_map *loader,
486              int whatcode, int mode, bool *found_other_class, bool free_name)
487  {
488    /* This is the expected ELF header.  */
489 @@ -1514,6 +1519,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
490    if (__glibc_unlikely (GLRO(dl_naudit) > 0) && whatcode != 0
491        && loader->l_auditing == 0)
492      {
493 +      const char *original_name = name;
494        struct audit_ifaces *afct = GLRO(dl_audit);
495        for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
496         {
497 @@ -1528,11 +1534,21 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
498  
499           afct = afct->next;
500         }
501 +
502 +      if (fd != -1 && name != original_name && strcmp (name, original_name))
503 +        {
504 +          /* An audit library changed what we're supposed to open,
505 +             so FD no longer matches it.  */
506 +          __close (fd);
507 +          fd = -1;
508 +        }
509      }
510  #endif
511  
512 -  /* Open the file.  We always open files read-only.  */
513 -  int fd = __open (name, O_RDONLY | O_CLOEXEC);
514 +  if (fd == -1)
515 +    /* Open the file.  We always open files read-only.  */
516 +    fd = __open (name, O_RDONLY | O_CLOEXEC);
517 +
518    if (fd != -1)
519      {
520        ElfW(Ehdr) *ehdr;
521 @@ -1801,7 +1817,7 @@ open_path (const char *name, size_t namelen, int mode,
522           if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
523             _dl_debug_printf ("  trying file=%s\n", buf);
524  
525 -         fd = open_verify (buf, fbp, loader, whatcode, mode,
526 +         fd = open_verify (buf, -1, fbp, loader, whatcode, mode,
527                             found_other_class, false);
528           if (this_dir->status[cnt] == unknown)
529             {
530 @@ -2041,6 +2057,20 @@ _dl_map_object (struct link_map *loader, const char *name,
531                         &loader->l_runpath_dirs, &realname, &fb, loader,
532                         LA_SER_RUNPATH, &found_other_class);
533  
534 +      if (fd == -1)
535 +        {
536 +          realname = _dl_sysdep_open_object (name, namelen, &fd);
537 +          if (realname != NULL)
538 +            {
539 +              fd = open_verify (realname, fd,
540 +                                &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
541 +                                LA_SER_CONFIG, mode, &found_other_class,
542 +                                false);
543 +              if (fd == -1)
544 +                free (realname);
545 +            }
546 +        }
547 +
548  #ifdef USE_LDCONFIG
549        if (fd == -1
550           && (__glibc_likely ((mode & __RTLD_SECURE) == 0)
551 @@ -2086,7 +2116,7 @@ _dl_map_object (struct link_map *loader, const char *name,
552  
553               if (cached != NULL)
554                 {
555 -                 fd = open_verify (cached,
556 +                 fd = open_verify (cached, -1,
557                                     &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded,
558                                     LA_SER_CONFIG, mode, &found_other_class,
559                                     false);
560 @@ -2121,7 +2151,7 @@ _dl_map_object (struct link_map *loader, const char *name,
561         fd = -1;
562        else
563         {
564 -         fd = open_verify (realname, &fb,
565 +         fd = open_verify (realname, -1, &fb,
566                             loader ?: GL(dl_ns)[nsid]._ns_loaded, 0, mode,
567                             &found_other_class, true);
568           if (__glibc_unlikely (fd == -1))
569 diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
570 index 11cb44b..acf5280 100644
571 --- a/elf/dl-lookup.c
572 +++ b/elf/dl-lookup.c
573 @@ -1016,6 +1016,18 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
574  #ifdef SHARED
575    if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
576      {
577 +/* ELF_RTYPE_CLASS_XXX must match RTYPE_CLASS_XXX used by prelink with
578 +   LD_TRACE_PRELINKING.  */
579 +#define RTYPE_CLASS_VALID      8
580 +#define RTYPE_CLASS_PLT                (8|1)
581 +#define RTYPE_CLASS_COPY       (8|2)
582 +#define RTYPE_CLASS_TLS                (8|4)
583 +#if ELF_RTYPE_CLASS_PLT != 0 && ELF_RTYPE_CLASS_PLT != 1
584 +# error ELF_RTYPE_CLASS_PLT must be 0 or 1!
585 +#endif
586 +#if ELF_RTYPE_CLASS_COPY != 0 && ELF_RTYPE_CLASS_COPY != 2
587 +# error ELF_RTYPE_CLASS_COPY must be 0 or 2!
588 +#endif
589        int conflict = 0;
590        struct sym_val val = { NULL, NULL };
591  
592 @@ -1071,12 +1083,17 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
593  
594        if (value->s)
595         {
596 +         /* Keep only ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY
597 +            bits since since prelink only uses them.  */
598 +         type_class &= ELF_RTYPE_CLASS_PLT | ELF_RTYPE_CLASS_COPY;
599           if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
600                                 == STT_TLS))
601 -           type_class = 4;
602 +           /* Clear the RTYPE_CLASS_VALID bit in RTYPE_CLASS_TLS.  */
603 +           type_class = RTYPE_CLASS_TLS & ~RTYPE_CLASS_VALID;
604           else if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info)
605                                      == STT_GNU_IFUNC))
606 -           type_class |= 8;
607 +           /* Set the RTYPE_CLASS_VALID bit.  */
608 +           type_class |= RTYPE_CLASS_VALID;
609         }
610  
611        if (conflict
612 diff --git a/elf/dl-sysdep-open.h b/elf/dl-sysdep-open.h
613 new file mode 100644
614 index 0000000..a63d9f5
615 --- /dev/null
616 +++ b/elf/dl-sysdep-open.h
617 @@ -0,0 +1,45 @@
618 +/* System-specific call to open a shared object by name.  Stub version.
619 +   Copyright (C) 2015 Free Software Foundation, Inc.
620 +   This file is part of the GNU C Library.
621 +
622 +   The GNU C Library is free software; you can redistribute it and/or
623 +   modify it under the terms of the GNU Lesser General Public
624 +   License as published by the Free Software Foundation; either
625 +   version 2.1 of the License, or (at your option) any later version.
626 +
627 +   The GNU C Library is distributed in the hope that it will be useful,
628 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
629 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
630 +   Lesser General Public License for more details.
631 +
632 +   You should have received a copy of the GNU Lesser General Public
633 +   License along with the GNU C Library; if not, see
634 +   <http://www.gnu.org/licenses/>.  */
635 +
636 +#ifndef _DL_SYSDEP_OPEN_H
637 +#define _DL_SYSDEP_OPEN_H      1
638 +
639 +#include <assert.h>
640 +#include <stddef.h>
641 +
642 +/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
643 +   or a dlopen call's argument or suchlike.  NAMELEN is (strlen (NAME) + 1).
644 +
645 +   Find NAME in an OS-dependent fashion, and return its "real" name.
646 +   Optionally fill in *FD with a file descriptor open on that file (or
647 +   else leave its initial value of -1).  The return value is a new
648 +   malloc'd string, which will be free'd by the caller.  If NAME is
649 +   resolved to an actual file that can be opened, then the return
650 +   value should name that file (and if *FD was not set, then a normal
651 +   __open call on that string will be made).  If *FD was set by some
652 +   other means than a normal open and there is no "real" name to use,
653 +   then __strdup (NAME) is fine (modulo error checking).  */
654 +
655 +static inline char *
656 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
657 +{
658 +  assert (*fd == -1);
659 +  return NULL;
660 +}
661 +
662 +#endif  /* dl-sysdep-open.h */
663 diff --git a/elf/rtld.c b/elf/rtld.c
664 index 69873c2..07e741c 100644
665 --- a/elf/rtld.c
666 +++ b/elf/rtld.c
667 @@ -162,7 +162,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
668      ._dl_hwcap_mask = HWCAP_IMPORTANT,
669      ._dl_lazy = 1,
670      ._dl_fpu_control = _FPU_DEFAULT,
671 -    ._dl_pointer_guard = 1,
672      ._dl_pagesize = EXEC_PAGESIZE,
673      ._dl_inhibit_cache = 0,
674  
675 @@ -709,15 +708,12 @@ security_init (void)
676  #endif
677  
678    /* Set up the pointer guard as well, if necessary.  */
679 -  if (GLRO(dl_pointer_guard))
680 -    {
681 -      uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
682 -                                                            stack_chk_guard);
683 +  uintptr_t pointer_chk_guard
684 +    = _dl_setup_pointer_guard (_dl_random, stack_chk_guard);
685  #ifdef THREAD_SET_POINTER_GUARD
686 -      THREAD_SET_POINTER_GUARD (pointer_chk_guard);
687 +  THREAD_SET_POINTER_GUARD (pointer_chk_guard);
688  #endif
689 -      __pointer_chk_guard_local = pointer_chk_guard;
690 -    }
691 +  __pointer_chk_guard_local = pointer_chk_guard;
692  
693    /* We do not need the _dl_random value anymore.  The less
694       information we leave behind, the better, so clear the
695 @@ -2471,9 +2467,6 @@ process_envvars (enum mode *modep)
696               GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0;
697               break;
698             }
699 -
700 -         if (memcmp (envline, "POINTER_GUARD", 13) == 0)
701 -           GLRO(dl_pointer_guard) = envline[14] != '0';
702           break;
703  
704         case 14:
705 diff --git a/elf/tst-nodelete2.c b/elf/tst-nodelete2.c
706 new file mode 100644
707 index 0000000..388e8af
708 --- /dev/null
709 +++ b/elf/tst-nodelete2.c
710 @@ -0,0 +1,37 @@
711 +#include "../dlfcn/dlfcn.h"
712 +#include <stdio.h>
713 +#include <stdlib.h>
714 +#include <gnu/lib-names.h>
715 +
716 +static int
717 +do_test (void)
718 +{
719 +  int result = 0;
720 +
721 +  printf ("\nOpening pthread library.\n");
722 +  void *pthread = dlopen (LIBPTHREAD_SO, RTLD_LAZY);
723 +
724 +  /* This is a test for correct DF_1_NODELETE clearing when dlopen failure
725 +     happens.  We should clear DF_1_NODELETE for failed library only, because
726 +     doing this for others (e.g. libpthread) might cause them to be unloaded,
727 +     that may lead to some global references (e.g. __rtld_lock_unlock) to be
728 +     broken.  The dlopen should fail because of undefined symbols in shared
729 +     library, that cause DF_1_NODELETE to be cleared.  For libpthread, this
730 +     flag should be set, because if not, SIGSEGV will happen in dlclose.  */
731 +  if (dlopen ("tst-nodelete2mod.so", RTLD_NOW) != NULL)
732 +    {
733 +      printf ("Unique symbols test failed\n");
734 +      result = 1;
735 +    }
736 +
737 +  if (pthread)
738 +    dlclose (pthread);
739 +
740 +  if (result == 0)
741 +    printf ("SUCCESS\n");
742 +
743 +  return result;
744 +}
745 +
746 +#define TEST_FUNCTION do_test ()
747 +#include "../test-skeleton.c"
748 diff --git a/elf/tst-nodelete2mod.c b/elf/tst-nodelete2mod.c
749 new file mode 100644
750 index 0000000..e88c756
751 --- /dev/null
752 +++ b/elf/tst-nodelete2mod.c
753 @@ -0,0 +1,7 @@
754 +/* Undefined symbol.  */
755 +extern int not_exist (void);
756 +
757 +int foo (void)
758 +{
759 +  return not_exist ();
760 +}
761 diff --git a/elf/tst-prelink.c b/elf/tst-prelink.c
762 new file mode 100644
763 index 0000000..ab61c4e
764 --- /dev/null
765 +++ b/elf/tst-prelink.c
766 @@ -0,0 +1,30 @@
767 +/* Test the output from the environment variable, LD_TRACE_PRELINKING,
768 +   for prelink.
769 +   Copyright (C) 2015 Free Software Foundation, Inc.
770 +   This file is part of the GNU C Library.
771 +
772 +   The GNU C Library is free software; you can redistribute it and/or
773 +   modify it under the terms of the GNU Lesser General Public
774 +   License as published by the Free Software Foundation; either
775 +   version 2.1 of the License, or (at your option) any later version.
776 +
777 +   The GNU C Library is distributed in the hope that it will be useful,
778 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
779 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
780 +   Lesser General Public License for more details.
781 +
782 +   You should have received a copy of the GNU Lesser General Public
783 +   License along with the GNU C Library; if not, see
784 +   <http://www.gnu.org/licenses/>.  */
785 +
786 +#include <stdio.h>
787 +
788 +static int
789 +do_test (void)
790 +{
791 +  fprintf (stdout, "hello\n");
792 +  return 0;
793 +}
794 +
795 +#define TEST_FUNCTION do_test ()
796 +#include "../test-skeleton.c"
797 diff --git a/elf/tst-prelink.exp b/elf/tst-prelink.exp
798 new file mode 100644
799 index 0000000..b35b4c9
800 --- /dev/null
801 +++ b/elf/tst-prelink.exp
802 @@ -0,0 +1 @@
803 +/0 stdout
804 diff --git a/elf/tst-znodelete-zlib.cc b/elf/tst-znodelete-zlib.cc
805 deleted file mode 100644
806 index 1e8f368..0000000
807 --- a/elf/tst-znodelete-zlib.cc
808 +++ /dev/null
809 @@ -1,6 +0,0 @@
810 -extern int not_exist (void);
811 -
812 -int foo (void)
813 -{
814 -  return  not_exist ();
815 -}
816 diff --git a/io/test-lfs.c b/io/test-lfs.c
817 index 539c2a2..b6ebae4 100644
818 --- a/io/test-lfs.c
819 +++ b/io/test-lfs.c
820 @@ -144,7 +144,7 @@ test_ftello (void)
821  int
822  do_test (int argc, char *argv[])
823  {
824 -  int ret;
825 +  int ret, fd2;
826    struct stat64 statbuf;
827  
828    ret = lseek64 (fd, TWO_GB+100, SEEK_SET);
829 @@ -195,6 +195,25 @@ do_test (int argc, char *argv[])
830      error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
831            (long long int) statbuf.st_size, (TWO_GB + 100 + 5));
832  
833 +  fd2 = openat64 (AT_FDCWD, name, O_RDWR);
834 +  if (fd2 == -1)
835 +    {
836 +      if (errno == ENOSYS)
837 +       {
838 +         /* Silently ignore this test.  */
839 +         error (0, 0, "openat64 is not supported");
840 +       }
841 +      else
842 +       error (EXIT_FAILURE, errno, "openat64 failed to open big file");
843 +    }
844 +  else
845 +    {
846 +      ret = close (fd2);
847 +
848 +      if (ret == -1)
849 +       error (EXIT_FAILURE, errno, "error closing file");
850 +    }
851 +
852    test_ftello ();
853  
854    return 0;
855 diff --git a/locale/C-collate.c b/locale/C-collate.c
856 index d7f3c55..06dfdfa 100644
857 --- a/locale/C-collate.c
858 +++ b/locale/C-collate.c
859 @@ -144,8 +144,6 @@ const struct __locale_data _nl_C_LC_COLLATE attribute_hidden =
860      /* _NL_COLLATE_COLLSEQWC */
861      { .string = (const char *) collseqwc },
862      /* _NL_COLLATE_CODESET */
863 -    { .string = _nl_C_codeset },
864 -    /* _NL_COLLATE_ENCODING_TYPE */
865 -    { .word = __cet_8bit }
866 +    { .string = _nl_C_codeset }
867    }
868  };
869 diff --git a/locale/categories.def b/locale/categories.def
870 index 045489d..a8dda53 100644
871 --- a/locale/categories.def
872 +++ b/locale/categories.def
873 @@ -58,7 +58,6 @@ DEFINE_CATEGORY
874    DEFINE_ELEMENT (_NL_COLLATE_COLLSEQMB,        "collate-collseqmb",        std, wstring)
875    DEFINE_ELEMENT (_NL_COLLATE_COLLSEQWC,        "collate-collseqwc",        std, wstring)
876    DEFINE_ELEMENT (_NL_COLLATE_CODESET,         "collate-codeset",          std, string)
877 -  DEFINE_ELEMENT (_NL_COLLATE_ENCODING_TYPE,   "collate-encoding-type",    std, word)
878    ), NO_POSTLOAD)
879  
880  
881 diff --git a/locale/langinfo.h b/locale/langinfo.h
882 index ffc5c7f..a565d9d 100644
883 --- a/locale/langinfo.h
884 +++ b/locale/langinfo.h
885 @@ -255,7 +255,6 @@ enum
886    _NL_COLLATE_COLLSEQMB,
887    _NL_COLLATE_COLLSEQWC,
888    _NL_COLLATE_CODESET,
889 -  _NL_COLLATE_ENCODING_TYPE,
890    _NL_NUM_LC_COLLATE,
891  
892    /* LC_CTYPE category: character classification.
893 diff --git a/locale/localeinfo.h b/locale/localeinfo.h
894 index bdab9fe..1d2ee00 100644
895 --- a/locale/localeinfo.h
896 +++ b/locale/localeinfo.h
897 @@ -110,14 +110,6 @@ enum coll_sort_rule
898    sort_mask
899  };
900  
901 -/* Collation encoding type.  */
902 -enum collation_encoding_type
903 -{
904 -  __cet_other,
905 -  __cet_8bit,
906 -  __cet_utf8
907 -};
908 -
909  /* We can map the types of the entries into a few categories.  */
910  enum value_type
911  {
912 diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
913 index a39a94f..dc0fe30 100644
914 --- a/locale/programs/ld-collate.c
915 +++ b/locale/programs/ld-collate.c
916 @@ -32,7 +32,6 @@
917  #include "linereader.h"
918  #include "locfile.h"
919  #include "elem-hash.h"
920 -#include "../localeinfo.h"
921  
922  /* Uncomment the following line in the production version.  */
923  /* #define NDEBUG 1 */
924 @@ -2131,8 +2130,6 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
925           /* The words have to be handled specially.  */
926           if (idx == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
927             add_locale_uint32 (&file, 0);
928 -         else if (idx == _NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE))
929 -           add_locale_uint32 (&file, __cet_other);
930           else
931             add_locale_empty (&file);
932         }
933 @@ -2496,12 +2493,6 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
934    add_locale_raw_data (&file, collate->mbseqorder, 256);
935    add_locale_collseq_table (&file, &collate->wcseqorder);
936    add_locale_string (&file, charmap->code_set_name);
937 -  if (strcmp (charmap->code_set_name, "UTF-8") == 0)
938 -    add_locale_uint32 (&file, __cet_utf8);
939 -  else if (charmap->mb_cur_max == 1)
940 -    add_locale_uint32 (&file, __cet_8bit);
941 -  else
942 -    add_locale_uint32 (&file, __cet_other);
943    write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", &file);
944  
945    obstack_free (&weightpool, NULL);
946 diff --git a/misc/Makefile b/misc/Makefile
947 index aecb0da..2f5edf6 100644
948 --- a/misc/Makefile
949 +++ b/misc/Makefile
950 @@ -76,7 +76,8 @@ install-lib := libg.a
951  gpl2lgpl := error.c error.h
952  
953  tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
954 -        tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1
955 +        tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
956 +        tst-mntent-blank-corrupt tst-mntent-blank-passno
957  ifeq ($(run-built-tests),yes)
958  tests-special += $(objpfx)tst-error1-mem.out
959  endif
960 diff --git a/misc/mntent_r.c b/misc/mntent_r.c
961 index 6159873..4f26998 100644
962 --- a/misc/mntent_r.c
963 +++ b/misc/mntent_r.c
964 @@ -136,7 +136,9 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
965        end_ptr = strchr (buffer, '\n');
966        if (end_ptr != NULL)     /* chop newline */
967         {
968 -         while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
969 +         /* Do not walk past the start of buffer if it's all whitespace.  */
970 +         while (end_ptr != buffer
971 +                && (end_ptr[-1] == ' ' || end_ptr[-1] == '\t'))
972              end_ptr--;
973           *end_ptr = '\0';
974         }
975 diff --git a/misc/regexp.h b/misc/regexp.h
976 index 3460989..42394f7 100644
977 --- a/misc/regexp.h
978 +++ b/misc/regexp.h
979 @@ -19,10 +19,11 @@
980  #ifndef _REGEXP_H
981  #define _REGEXP_H      1
982  
983 -/* The contents of this header file were standardized in the
984 -   Single Unix Specification, Version 2 (1997) but marked as
985 -   LEGACY; new applications were already being encouraged to
986 -   use <regex.h> instead.  POSIX.1-2001 removed this header.
987 +/* The contents of this header file were originally standardized in
988 +   the Single Unix Specification, Issue 3 (1992).  In Issue 4 (1994)
989 +   the header was marked as TO BE WITHDRAWN, and new applications
990 +   were encouraged to use <regex.h> instead.  It was officially
991 +   withdrawn from the standard in Issue 6 (aka POSIX.1-2001).
992  
993     This header is provided only for backward compatibility.
994     It will be removed in the next release of the GNU C Library.
995 diff --git a/misc/sys/param.h b/misc/sys/param.h
996 index 62b7ed2..1908b93 100644
997 --- a/misc/sys/param.h
998 +++ b/misc/sys/param.h
999 @@ -50,6 +50,9 @@
1000  #if !defined NOFILE && defined OPEN_MAX
1001  # define NOFILE                OPEN_MAX
1002  #endif
1003 +#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX
1004 +# define MAXHOSTNAMELEN        HOST_NAME_MAX
1005 +#endif
1006  #ifndef NCARGS
1007  # ifdef ARG_MAX
1008  #  define NCARGS       ARG_MAX
1009 diff --git a/misc/tst-mntent-blank-corrupt.c b/misc/tst-mntent-blank-corrupt.c
1010 new file mode 100644
1011 index 0000000..92266a3
1012 --- /dev/null
1013 +++ b/misc/tst-mntent-blank-corrupt.c
1014 @@ -0,0 +1,45 @@
1015 +/* Make sure blank lines does not cause memory corruption BZ #18887.
1016 +
1017 +   Copyright (C) 2009-2015 Free Software Foundation, Inc.
1018 +   This file is part of the GNU C Library.
1019 +
1020 +   The GNU C Library is free software; you can redistribute it and/or
1021 +   modify it under the terms of the GNU Lesser General Public
1022 +   License as published by the Free Software Foundation; either
1023 +   version 2.1 of the License, or (at your option) any later version.
1024 +
1025 +   The GNU C Library is distributed in the hope that it will be useful,
1026 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1027 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1028 +   Lesser General Public License for more details.
1029 +
1030 +   You should have received a copy of the GNU Lesser General Public
1031 +   License along with the GNU C Library; if not, see
1032 +   <http://www.gnu.org/licenses/>.  */
1033 +
1034 +#include <mntent.h>
1035 +#include <stdio.h>
1036 +#include <string.h>
1037 +
1038 +/* Make sure blank lines don't trigger memory corruption.  This doesn't happen
1039 +   for all targets though, so it's a best effort test BZ #18887.  */
1040 +static int
1041 +do_test (void)
1042 +{
1043 +  FILE *fp;
1044 +
1045 +  fp = tmpfile ();
1046 +  fputs ("\n \n/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1047 +  rewind (fp);
1048 +
1049 +  /* The corruption happens here ...  */
1050 +  getmntent (fp);
1051 +  /* ... but trigers here.  */
1052 +  endmntent (fp);
1053 +
1054 +  /* If the test failed, we would crash, and not hit this point.  */
1055 +  return 0;
1056 +}
1057 +
1058 +#define TEST_FUNCTION do_test ()
1059 +#include "../test-skeleton.c"
1060 diff --git a/misc/tst-mntent-blank-passno.c b/misc/tst-mntent-blank-passno.c
1061 new file mode 100644
1062 index 0000000..fc04291
1063 --- /dev/null
1064 +++ b/misc/tst-mntent-blank-passno.c
1065 @@ -0,0 +1,53 @@
1066 +/* Make sure trailing whitespace is handled properly BZ #17273.
1067 +
1068 +   Copyright (C) 2009-2015 Free Software Foundation, Inc.
1069 +   This file is part of the GNU C Library.
1070 +
1071 +   The GNU C Library is free software; you can redistribute it and/or
1072 +   modify it under the terms of the GNU Lesser General Public
1073 +   License as published by the Free Software Foundation; either
1074 +   version 2.1 of the License, or (at your option) any later version.
1075 +
1076 +   The GNU C Library is distributed in the hope that it will be useful,
1077 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1078 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1079 +   Lesser General Public License for more details.
1080 +
1081 +   You should have received a copy of the GNU Lesser General Public
1082 +   License along with the GNU C Library; if not, see
1083 +   <http://www.gnu.org/licenses/>.  */
1084 +
1085 +#include <mntent.h>
1086 +#include <stdio.h>
1087 +#include <string.h>
1088 +
1089 +/* Check entries to make sure trailing whitespace is ignored and we return the
1090 +   correct passno value BZ #17273.  */
1091 +static int
1092 +do_test (void)
1093 +{
1094 +  int result = 0;
1095 +  FILE *fp;
1096 +  struct mntent *mnt;
1097 +
1098 +  fp = tmpfile ();
1099 +  fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1100 +  rewind (fp);
1101 +
1102 +  mnt = getmntent (fp);
1103 +  if (strcmp (mnt->mnt_fsname, "/foo dir") != 0
1104 +      || strcmp (mnt->mnt_dir, "/bar dir") != 0
1105 +      || strcmp (mnt->mnt_type, "auto") != 0
1106 +      || strcmp (mnt->mnt_opts, "bind") != 0
1107 +      || mnt->mnt_freq != 0
1108 +      || mnt->mnt_passno != 0)
1109 +    {
1110 +      puts ("Error while reading entry with trailing whitespaces");
1111 +      result = 1;
1112 +    }
1113 +
1114 +  return result;
1115 +}
1116 +
1117 +#define TEST_FUNCTION do_test ()
1118 +#include "../test-skeleton.c"
1119 diff --git a/misc/tst-mntent.c b/misc/tst-mntent.c
1120 index 876c89f..820b354 100644
1121 --- a/misc/tst-mntent.c
1122 +++ b/misc/tst-mntent.c
1123 @@ -73,26 +73,6 @@ main (int argc, char *argv[])
1124           puts ("Error while reading written entry back in");
1125           result = 1;
1126         }
1127 -
1128 -      /* Part III: Entry with whitespaces at the end of a line. */
1129 -      rewind (fp);
1130 -
1131 -      fputs ("/foo\\040dir /bar\\040dir auto bind \t \n", fp);
1132 -
1133 -      rewind (fp);
1134 -
1135 -      mnt = getmntent (fp);
1136 -
1137 -      if (strcmp (mnt->mnt_fsname, "/foo dir") != 0
1138 -         || strcmp (mnt->mnt_dir, "/bar dir") != 0
1139 -         || strcmp (mnt->mnt_type, "auto") != 0
1140 -         || strcmp (mnt->mnt_opts, "bind") != 0
1141 -         || mnt->mnt_freq != 0
1142 -         || mnt->mnt_passno != 0)
1143 -       {
1144 -         puts ("Error while reading entry with trailing whitespaces");
1145 -         result = 1;
1146 -       }
1147     }
1148  
1149    return result;
1150 diff --git a/scripts/test-installation.pl b/scripts/test-installation.pl
1151 index cac1562..79b2b3e 100755
1152 --- a/scripts/test-installation.pl
1153 +++ b/scripts/test-installation.pl
1154 @@ -80,16 +80,25 @@ arglist: while (@ARGV) {
1155  # We expect none or one argument.
1156  if ($#ARGV == -1) {
1157      $soversions="soversions.mk";
1158 +    $config="config.make";
1159  } elsif ($#ARGV == 0) {
1160      if (-d $ARGV[0]) {
1161        $soversions = "$ARGV[0]/soversions.mk";
1162 +      $config = "$ARGV[0]/config.make";
1163      } else {
1164 -      $soversions = $ARGV[0];
1165 +      $soversions = $dir = $ARGV[0];
1166 +      $dir =~ s!/?[^/]*/*$!!;
1167 +      $config = $dir . "/config.make";
1168      }
1169  } else {
1170      die "Wrong number of arguments.";
1171  }
1172  
1173 +if (system ("grep -q \"build-mathvec = yes\" $config") == 0) {
1174 +    $build_mathvec = 1;
1175 +} else {
1176 +    $build_mathvec = 0;
1177 +}
1178  
1179  # Read names and versions of all shared libraries that are part of
1180  # glibc
1181 @@ -111,6 +120,8 @@ while (<SOVERSIONS>) {
1182      # - libthread_db since it contains unresolved references
1183      # - it's just a test NSS module
1184      # - We don't provide the libgcc so we don't test it
1185 +    # - libmvec if it wasn't built
1186 +    next if ($build_mathvec == 0 && $name eq "mvec");
1187      if ($name ne "nss_ldap" && $name ne "db1"
1188         && !($name =~/^nss1_/) && $name ne "thread_db"
1189         && $name ne "nss_test1" && $name ne "libgcc_s") {
1190 diff --git a/stdlib/cxa_thread_atexit_impl.c b/stdlib/cxa_thread_atexit_impl.c
1191 index 2d5d56a..5717f09 100644
1192 --- a/stdlib/cxa_thread_atexit_impl.c
1193 +++ b/stdlib/cxa_thread_atexit_impl.c
1194 @@ -98,6 +98,10 @@ static __thread struct link_map *lm_cache;
1195  int
1196  __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
1197  {
1198 +#ifdef PTR_MANGLE
1199 +  PTR_MANGLE (func);
1200 +#endif
1201 +
1202    /* Prepend.  */
1203    struct dtor_list *new = calloc (1, sizeof (struct dtor_list));
1204    new->func = func;
1205 @@ -142,9 +146,13 @@ __call_tls_dtors (void)
1206    while (tls_dtor_list)
1207      {
1208        struct dtor_list *cur = tls_dtor_list;
1209 +      dtor_func func = cur->func;
1210 +#ifdef PTR_DEMANGLE
1211 +      PTR_DEMANGLE (func);
1212 +#endif
1213  
1214        tls_dtor_list = tls_dtor_list->next;
1215 -      cur->func (cur->obj);
1216 +      func (cur->obj);
1217  
1218        /* Ensure that the MAP dereference happens before
1219          l_tls_dtor_count decrement.  That way, we protect this access from a
1220 diff --git a/string/Makefile b/string/Makefile
1221 index 8424a61..ebe9354 100644
1222 --- a/string/Makefile
1223 +++ b/string/Makefile
1224 @@ -54,7 +54,7 @@ tests         := tester inl-tester noinl-tester testcopy test-ffs     \
1225                    tst-strtok tst-strxfrm bug-strcoll1 tst-strfry       \
1226                    bug-strtok1 $(addprefix test-,$(strop-tests))        \
1227                    bug-envz1 tst-strxfrm2 tst-endian tst-svc2           \
1228 -                  tst-strtok_r
1229 +                  tst-strtok_r bug-strcoll2
1230  
1231  xtests = tst-strcoll-overflow
1232  
1233 @@ -75,4 +75,17 @@ ifeq ($(run-built-tests),yes)
1234  $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
1235         cmp $^ > $@; \
1236         $(evaluate-test)
1237 +
1238 +LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
1239 +           tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
1240 +          da_DK.ISO-8859-1
1241 +include ../gen-locales.mk
1242 +
1243 +$(objpfx)test-strcasecmp.out: $(gen-locales)
1244 +$(objpfx)test-strncasecmp.out: $(gen-locales)
1245 +$(objpfx)tst-strxfrm.out: $(gen-locales)
1246 +$(objpfx)tst-strxfrm2.out: $(gen-locales)
1247 +# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
1248 +$(objpfx)bug-strcoll2.out: $(gen-locales)
1249 +
1250  endif
1251 diff --git a/string/bug-strcoll2.c b/string/bug-strcoll2.c
1252 new file mode 100644
1253 index 0000000..72a9ff2
1254 --- /dev/null
1255 +++ b/string/bug-strcoll2.c
1256 @@ -0,0 +1,92 @@
1257 +/* Bug 18589: sort-test.sh fails at random.
1258 +   Copyright (C) 2015 Free Software Foundation, Inc.
1259 +   This file is part of the GNU C Library.
1260 +
1261 +   The GNU C Library is free software; you can redistribute it and/or
1262 +   modify it under the terms of the GNU Lesser General Public
1263 +   License as published by the Free Software Foundation; either
1264 +   version 2.1 of the License, or (at your option) any later version.
1265 +
1266 +   The GNU C Library is distributed in the hope that it will be useful,
1267 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1268 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1269 +   Lesser General Public License for more details.
1270 +
1271 +   You should have received a copy of the GNU Lesser General Public
1272 +   License along with the GNU C Library; if not, see
1273 +   <http://www.gnu.org/licenses/>.  */
1274 +
1275 +#include <stdio.h>
1276 +#include <string.h>
1277 +#include <locale.h>
1278 +
1279 +/* An incorrect strcoll optimization resulted in incorrect
1280 +   results from strcoll for cs_CZ and da_DK.  */
1281 +
1282 +int
1283 +test_cs_CZ (void)
1284 +{
1285 +  const char t1[] = "config";
1286 +  const char t2[] = "choose";
1287 +  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
1288 +    {
1289 +      perror ("setlocale");
1290 +      return 1;
1291 +    }
1292 +  /* In Czech the digraph ch sorts after c, therefore we expect
1293 +     config to sort before choose.  */
1294 +  int a = strcoll (t1, t2);
1295 +  int b = strcoll (t2, t1);
1296 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a);
1297 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b);
1298 +  if (a < 0 && b > 0)
1299 +    {
1300 +      puts ("PASS: config < choose");
1301 +      return 0;
1302 +    }
1303 +  else
1304 +    {
1305 +      puts ("FAIL: Wrong sorting in cs_CZ.UTF-8.");
1306 +      return 1;
1307 +    }
1308 +}
1309 +
1310 +int
1311 +test_da_DK (void)
1312 +{
1313 +  const char t1[] = "AS";
1314 +  const char t2[] = "AA";
1315 +  if (setlocale (LC_ALL, "da_DK.ISO-8859-1") == NULL)
1316 +    {
1317 +      perror ("setlocale");
1318 +      return 1;
1319 +    }
1320 +  /* AA should be treated as the last letter of the Danish alphabet,
1321 +     hence sorting after AS.  */
1322 +  int a = strcoll (t1, t2);
1323 +  int b = strcoll (t2, t1);
1324 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a);
1325 +  printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b);
1326 +  if (a < 0 && b > 0)
1327 +    {
1328 +      puts ("PASS: AS < AA");
1329 +      return 0;
1330 +    }
1331 +  else
1332 +    {
1333 +      puts ("FAIL: Wrong sorting in da_DK.ISO-8859-1");
1334 +      return 1;
1335 +    }
1336 +}
1337 +
1338 +static int
1339 +do_test (void)
1340 +{
1341 +  int err = 0;
1342 +  err |= test_cs_CZ ();
1343 +  err |= test_da_DK ();
1344 +  return err;
1345 +}
1346 +
1347 +#define TEST_FUNCTION do_test ()
1348 +#include "../test-skeleton.c"
1349 diff --git a/string/strcoll_l.c b/string/strcoll_l.c
1350 index 8f1225f..35bc0e4 100644
1351 --- a/string/strcoll_l.c
1352 +++ b/string/strcoll_l.c
1353 @@ -29,7 +29,6 @@
1354  # define STRING_TYPE char
1355  # define USTRING_TYPE unsigned char
1356  # define STRCOLL __strcoll_l
1357 -# define STRDIFF __strdiff
1358  # define STRCMP strcmp
1359  # define WEIGHT_H "../locale/weight.h"
1360  # define SUFFIX        MB
1361 @@ -42,20 +41,6 @@
1362  #include "../locale/localeinfo.h"
1363  #include WEIGHT_H
1364  
1365 -#define MASK_UTF8_7BIT  (1 << 7)
1366 -#define MASK_UTF8_START (3 << 6)
1367 -
1368 -size_t
1369 -STRDIFF (const STRING_TYPE *s, const STRING_TYPE *t)
1370 -{
1371 -  size_t n;
1372 -
1373 -  for (n = 0; *s != '\0' && *s++ == *t++; ++n)
1374 -    continue;
1375 -
1376 -  return n;
1377 -}
1378 -
1379  /* Track status while looking for sequences in a string.  */
1380  typedef struct
1381  {
1382 @@ -269,29 +254,9 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
1383    const USTRING_TYPE *extra;
1384    const int32_t *indirect;
1385  
1386 -  /* In case there is no locale specific sort order (C / POSIX).  */
1387    if (nrules == 0)
1388      return STRCMP (s1, s2);
1389  
1390 -  /* Fast forward to the position of the first difference.  Needs to be
1391 -     encoding aware as the byte-by-byte comparison can stop in the middle
1392 -     of a char sequence for multibyte encodings like UTF-8.  */
1393 -  uint_fast32_t encoding =
1394 -    current->values[_NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE)].word;
1395 -  if (encoding != __cet_other)
1396 -    {
1397 -      size_t diff = STRDIFF (s1, s2);
1398 -      if (diff > 0)
1399 -       {
1400 -         if (encoding == __cet_utf8 && (*(s1 + diff) & MASK_UTF8_7BIT) != 0)
1401 -           do
1402 -             diff--;
1403 -           while (diff > 0 && (*(s1 + diff) & MASK_UTF8_START) != MASK_UTF8_START);
1404 -         s1 += diff;
1405 -         s2 += diff;
1406 -       }
1407 -    }
1408 -
1409    /* Catch empty strings.  */
1410    if (__glibc_unlikely (*s1 == '\0') || __glibc_unlikely (*s2 == '\0'))
1411      return (*s1 != '\0') - (*s2 != '\0');
1412 @@ -358,8 +323,7 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
1413                      byte-level comparison to ensure that we don't waste time
1414                      going through multiple passes for totally equal strings
1415                      before proceeding to subsequent passes.  */
1416 -                 if (pass == 0 && encoding == __cet_other &&
1417 -                     STRCMP (s1, s2) == 0)
1418 +                 if (pass == 0 && STRCMP (s1, s2) == 0)
1419                     return result;
1420                   else
1421                     break;
1422 diff --git a/string/tst-strxfrm2.c b/string/tst-strxfrm2.c
1423 index d5a1115..bea5aa2 100644
1424 --- a/string/tst-strxfrm2.c
1425 +++ b/string/tst-strxfrm2.c
1426 @@ -5,6 +5,8 @@
1427  static int
1428  do_test (void)
1429  {
1430 +  static const char test_locale[] = "de_DE.UTF-8";
1431 +
1432    int res = 0;
1433  
1434    char buf[20];
1435 @@ -38,9 +40,9 @@ do_test (void)
1436        res = 1;
1437      }
1438  
1439 -  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
1440 +  if (setlocale (LC_ALL, test_locale) == NULL)
1441      {
1442 -      puts ("setlocale failed");
1443 +      printf ("cannot set locale \"%s\"\n", test_locale);
1444        res = 1;
1445      }
1446    else
1447 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
1448 index 7a0fe8d..78e3a97 100644
1449 --- a/sysdeps/generic/ldsodefs.h
1450 +++ b/sysdeps/generic/ldsodefs.h
1451 @@ -592,9 +592,6 @@ struct rtld_global_ro
1452    /* List of auditing interfaces.  */
1453    struct audit_ifaces *_dl_audit;
1454    unsigned int _dl_naudit;
1455 -
1456 -  /* 0 if internal pointer values should not be guarded, 1 if they should.  */
1457 -  EXTERN int _dl_pointer_guard;
1458  };
1459  # define __rtld_global_attribute__
1460  # if IS_IN (rtld)
1461 diff --git a/sysdeps/hppa/dl-symaddr.c b/sysdeps/hppa/dl-symaddr.c
1462 index b707c19..89d8baf 100644
1463 --- a/sysdeps/hppa/dl-symaddr.c
1464 +++ b/sysdeps/hppa/dl-symaddr.c
1465 @@ -33,3 +33,4 @@ _dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref)
1466    else
1467      return (void *) value;
1468  }
1469 +rtld_hidden_def (_dl_symbol_address)
1470 diff --git a/sysdeps/nacl/Makefile b/sysdeps/nacl/Makefile
1471 index 6749a44..1748886 100644
1472 --- a/sysdeps/nacl/Makefile
1473 +++ b/sysdeps/nacl/Makefile
1474 @@ -132,4 +132,13 @@ ifeq ($(subdir),misc)
1475  # sysdeps/.../linux/ directories, but it's still a sysdeps decision to
1476  # install it.
1477  sysdep_headers += bits/mman-linux.h
1478 +
1479 +# This defeats sysdeps/gnu/Makefile's addition of sys/mtio.h, which
1480 +# we do not want.  This is a total kludge, but it seems no worse for
1481 +# now than making the sysdeps/gnu/Makefile code conditional on a
1482 +# variable we set here.  If some sysdeps/.../Makefile that is later
1483 +# in the list than sysdeps/gnu needed to add to sysdep_headers, this
1484 +# would break it.  But sysdeps/gnu is close to last in the list and
1485 +# this coming up seems unlikely.
1486 +override sysdep_headers := $(sysdep_headers)
1487  endif
1488 diff --git a/sysdeps/nacl/dl-map-segments.h b/sysdeps/nacl/dl-map-segments.h
1489 index f305da3..f2d5d84 100644
1490 --- a/sysdeps/nacl/dl-map-segments.h
1491 +++ b/sysdeps/nacl/dl-map-segments.h
1492 @@ -53,7 +53,7 @@ _dl_map_segments (struct link_map *l, int fd,
1493                   const size_t maplength, bool has_holes,
1494                   struct link_map *loader)
1495  {
1496 -  if (__builtin_expect (type, ET_DYN) == ET_DYN)
1497 +  if (__glibc_likely (type == ET_DYN))
1498      {
1499        /* This is a position-independent shared object.  Let the system
1500          choose where to place it.
1501 @@ -165,6 +165,32 @@ _dl_map_segments (struct link_map *l, int fd,
1502                     errno = error;
1503                     return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
1504                   }
1505 +                if (__glibc_unlikely (type != ET_DYN))
1506 +                  {
1507 +                    /* A successful PROT_EXEC mmap would have implicitly
1508 +                       updated the bookkeeping so that a future
1509 +                       allocate_code_data call would know that this range
1510 +                       of the address space is already occupied.  That
1511 +                       doesn't happen implicitly with dyncode_create, so
1512 +                       it's necessary to do an explicit call to update the
1513 +                       bookkeeping.  */
1514 +                    uintptr_t allocated_address;
1515 +                    error = __nacl_irt_code_data_alloc.allocate_code_data
1516 +                      (l->l_addr + c->mapstart, len, 0, 0, &allocated_address);
1517 +                    if (__glibc_unlikely (error))
1518 +                      {
1519 +                        errno = error;
1520 +                        return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
1521 +                      }
1522 +                    if (__glibc_unlikely
1523 +                        (allocated_address != l->l_addr + c->mapstart))
1524 +                      {
1525 +                        /* This is not a very helpful error for this case,
1526 +                           but there isn't really anything better to use.  */
1527 +                        errno = ENOMEM;
1528 +                        return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
1529 +                      }
1530 +                  }
1531               }
1532             else
1533               {
1534 diff --git a/sysdeps/nacl/dl-sysdep-open.h b/sysdeps/nacl/dl-sysdep-open.h
1535 new file mode 100644
1536 index 0000000..38b0f9e
1537 --- /dev/null
1538 +++ b/sysdeps/nacl/dl-sysdep-open.h
1539 @@ -0,0 +1,40 @@
1540 +/* System-specific call to open a shared object by name.  NaCl version.
1541 +   Copyright (C) 2015 Free Software Foundation, Inc.
1542 +   This file is part of the GNU C Library.
1543 +
1544 +   The GNU C Library is free software; you can redistribute it and/or
1545 +   modify it under the terms of the GNU Lesser General Public
1546 +   License as published by the Free Software Foundation; either
1547 +   version 2.1 of the License, or (at your option) any later version.
1548 +
1549 +   The GNU C Library is distributed in the hope that it will be useful,
1550 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1551 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1552 +   Lesser General Public License for more details.
1553 +
1554 +   You should have received a copy of the GNU Lesser General Public
1555 +   License along with the GNU C Library; if not, see
1556 +   <http://www.gnu.org/licenses/>.  */
1557 +
1558 +#ifndef _DL_SYSDEP_OPEN_H
1559 +#define _DL_SYSDEP_OPEN_H      1
1560 +
1561 +#include <stddef.h>
1562 +
1563 +/* NAME is a name without slashes, as it appears in a DT_NEEDED entry
1564 +   or a dlopen call's argument or suchlike.  NAMELEN is (strlen (NAME) + 1).
1565 +
1566 +   Find NAME in an OS-dependent fashion, and return its "real" name.
1567 +   Optionally fill in *FD with a file descriptor open on that file (or
1568 +   else leave its initial value of -1).  The return value is a new
1569 +   malloc'd string, which will be free'd by the caller.  If NAME is
1570 +   resolved to an actual file that can be opened, then the return
1571 +   value should name that file (and if *FD was not set, then a normal
1572 +   __open call on that string will be made).  If *FD was set by some
1573 +   other means than a normal open and there is no "real" name to use,
1574 +   then __strdup (NAME) is fine (modulo error checking).  */
1575 +
1576 +extern char *_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
1577 +  internal_function attribute_hidden;
1578 +
1579 +#endif  /* dl-sysdep-open.h */
1580 diff --git a/sysdeps/nacl/dl-sysdep.c b/sysdeps/nacl/dl-sysdep.c
1581 index 3e902c2..3a04aa1 100644
1582 --- a/sysdeps/nacl/dl-sysdep.c
1583 +++ b/sysdeps/nacl/dl-sysdep.c
1584 @@ -87,3 +87,26 @@ _dl_start_user (void (*user_entry) (uint32_t info[]), uint32_t info[])
1585  #endif  /* SHARED */
1586  
1587  #include <elf/dl-sysdep.c>
1588 +
1589 +#include <dl-sysdep-open.h>
1590 +#include <nacl-interfaces.h>
1591 +#include <assert.h>
1592 +#include <string.h>
1593 +#include <unistd.h>
1594 +
1595 +char *
1596 +internal_function
1597 +_dl_sysdep_open_object (const char *name, size_t namelen, int *fd)
1598 +{
1599 +  int error = __nacl_irt_resource_open.open_resource (name, fd);
1600 +  if (error)
1601 +    return NULL;
1602 +  assert (*fd != -1);
1603 +  char *realname = __strdup (name);
1604 +  if (__glibc_unlikely (realname == NULL))
1605 +    {
1606 +      __close (*fd);
1607 +      *fd = -1;
1608 +    }
1609 +  return realname;
1610 +}
1611 diff --git a/sysdeps/nacl/nacl-interface-list.h b/sysdeps/nacl/nacl-interface-list.h
1612 index cb33751..c68faed 100644
1613 --- a/sysdeps/nacl/nacl-interface-list.h
1614 +++ b/sysdeps/nacl/nacl-interface-list.h
1615 @@ -28,7 +28,7 @@ NACL_MANDATORY_INTERFACE (rtld,
1616                           NACL_IRT_FUTEX_v0_1, nacl_irt_futex)
1617  NACL_MANDATORY_INTERFACE (rtld,
1618                           NACL_IRT_TLS_v0_1, nacl_irt_tls)
1619 -NACL_MANDATORY_INTERFACE (libc,
1620 +NACL_MANDATORY_INTERFACE (rtld,
1621                           NACL_IRT_RESOURCE_OPEN_v0_1, nacl_irt_resource_open)
1622  NACL_MANDATORY_INTERFACE (rtld,
1623                           NACL_IRT_CODE_DATA_ALLOC_v0_1,
1624 diff --git a/sysdeps/nacl/start.c b/sysdeps/nacl/start.c
1625 index a4b6dd3..8e8bc1a 100644
1626 --- a/sysdeps/nacl/start.c
1627 +++ b/sysdeps/nacl/start.c
1628 @@ -44,6 +44,10 @@
1629  /* The application defines this, of course.  */
1630  extern int main (int argc, char **argv, char **envp);
1631  
1632 +/* But maybe it defines this too, in which case it takes precedence.  */
1633 +extern int __nacl_main (int argc, char **argv, char **envp)
1634 +  __attribute__ ((weak));
1635 +
1636  /* These are defined in libc.  */
1637  extern int __libc_csu_init (int argc, char **argv, char **envp);
1638  extern void __libc_csu_fini (void);
1639 @@ -59,7 +63,7 @@ _start (uint32_t info[])
1640  {
1641    /* The generic code actually assumes that envp follows argv.  */
1642  
1643 -  __libc_start_main (&main,
1644 +  __libc_start_main (&__nacl_main ?: &main,
1645                      nacl_startup_argc (info),
1646                      nacl_startup_argv (info),
1647                      nacl_startup_auxv (info),
1648 diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
1649 index 6509f5c..9edf056 100644
1650 --- a/sysdeps/posix/opendir.c
1651 +++ b/sysdeps/posix/opendir.c
1652 @@ -105,7 +105,7 @@ need_isdir_precheck (void)
1653      tryopen_o_directory ();
1654  
1655    /* We can skip the expensive `stat' call if O_DIRECTORY works.  */
1656 -  return o_directory_works > 0;
1657 +  return o_directory_works < 0;
1658  #endif
1659    return true;
1660  }
1661 diff --git a/sysdeps/powerpc/nptl/elide.h b/sysdeps/powerpc/nptl/elide.h
1662 index 389f5a5..12171f4 100644
1663 --- a/sysdeps/powerpc/nptl/elide.h
1664 +++ b/sysdeps/powerpc/nptl/elide.h
1665 @@ -23,67 +23,78 @@
1666  # include <htm.h>
1667  # include <elision-conf.h>
1668  
1669 -/* Returns true if the lock defined by is_lock_free as elided.
1670 -   ADAPT_COUNT is a pointer to per-lock state variable. */
1671 -
1672 +/* Get the new value of adapt_count according to the elision
1673 +   configurations.  Returns true if the system should retry again or false
1674 +   otherwise.  */
1675  static inline bool
1676 -__elide_lock (uint8_t *adapt_count, int is_lock_free)
1677 +__get_new_count (uint8_t *adapt_count)
1678  {
1679 -  if (*adapt_count > 0)
1680 +  /* A persistent failure indicates that a retry will probably
1681 +     result in another failure.  Use normal locking now and
1682 +     for the next couple of calls.  */
1683 +  if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
1684      {
1685 -      (*adapt_count)--;
1686 +      if (__elision_aconf.skip_lock_internal_abort > 0)
1687 +       *adapt_count = __elision_aconf.skip_lock_internal_abort;
1688        return false;
1689      }
1690 -
1691 -  for (int i = __elision_aconf.try_tbegin; i > 0; i--)
1692 -    {
1693 -      if (__builtin_tbegin (0))
1694 -       {
1695 -         if (is_lock_free)
1696 -           return true;
1697 -         /* Lock was busy.  */
1698 -         __builtin_tabort (_ABORT_LOCK_BUSY);
1699 -       }
1700 -      else
1701 -       {
1702 -         /* A persistent failure indicates that a retry will probably
1703 -            result in another failure.  Use normal locking now and
1704 -            for the next couple of calls.  */
1705 -         if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
1706 -           {
1707 -             if (__elision_aconf.skip_lock_internal_abort > 0)
1708 -               *adapt_count = __elision_aconf.skip_lock_internal_abort;
1709 -             break;
1710 -           }
1711 -         /* Same logic as above, but for a number of temporary failures in a
1712 -            a row.  */
1713 -         else if (__elision_aconf.skip_lock_out_of_tbegin_retries > 0
1714 -                  && __elision_aconf.try_tbegin > 0)
1715 -           *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries;
1716 -       }
1717 -     }
1718 -
1719 -  return false;
1720 +  /* Same logic as above, but for a number of temporary failures in a
1721 +     a row.  */
1722 +  else if (__elision_aconf.skip_lock_out_of_tbegin_retries > 0
1723 +          && __elision_aconf.try_tbegin > 0)
1724 +    *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries;
1725 +  return true;
1726  }
1727  
1728 -# define ELIDE_LOCK(adapt_count, is_lock_free) \
1729 -  __elide_lock (&(adapt_count), is_lock_free)
1730 -
1731 -
1732 -static inline bool
1733 -__elide_trylock (uint8_t *adapt_count, int is_lock_free, int write)
1734 -{
1735 -  if (__elision_aconf.try_tbegin > 0)
1736 -    {
1737 -      if (write)
1738 -       __builtin_tabort (_ABORT_NESTED_TRYLOCK);
1739 -      return __elide_lock (adapt_count, is_lock_free);
1740 -    }
1741 -  return false;
1742 -}
1743 +/* CONCURRENCY NOTES:
1744 +
1745 +   The evaluation of the macro expression is_lock_free encompasses one or
1746 +   more loads from memory locations that are concurrently modified by other
1747 +   threads.  For lock elision to work, this evaluation and the rest of the
1748 +   critical section protected by the lock must be atomic because an
1749 +   execution with lock elision must be equivalent to an execution in which
1750 +   the lock would have been actually acquired and released.  Therefore, we
1751 +   evaluate is_lock_free inside of the transaction that represents the
1752 +   critical section for which we want to use lock elision, which ensures
1753 +   the atomicity that we require.  */
1754 +
1755 +/* Returns 0 if the lock defined by is_lock_free was elided.
1756 +   ADAPT_COUNT is a per-lock state variable.  */
1757 +# define ELIDE_LOCK(adapt_count, is_lock_free)                         \
1758 +  ({                                                                   \
1759 +    int ret = 0;                                                       \
1760 +    if (adapt_count > 0)                                               \
1761 +      (adapt_count)--;                                                 \
1762 +    else                                                               \
1763 +      for (int i = __elision_aconf.try_tbegin; i > 0; i--)             \
1764 +       {                                                               \
1765 +         if (__builtin_tbegin (0))                                     \
1766 +           {                                                           \
1767 +             if (is_lock_free)                                         \
1768 +               {                                                       \
1769 +                 ret = 1;                                              \
1770 +                 break;                                                \
1771 +               }                                                       \
1772 +             __builtin_tabort (_ABORT_LOCK_BUSY);                      \
1773 +           }                                                           \
1774 +         else                                                          \
1775 +           if (!__get_new_count(&adapt_count))                         \
1776 +             break;                                                    \
1777 +       }                                                               \
1778 +    ret;                                                               \
1779 +  })
1780  
1781  # define ELIDE_TRYLOCK(adapt_count, is_lock_free, write)       \
1782 -  __elide_trylock (&(adapt_count), is_lock_free, write)
1783 +  ({                                                           \
1784 +    int ret = 0;                                               \
1785 +    if (__elision_aconf.try_tbegin > 0)                                \
1786 +      {                                                                \
1787 +       if (write)                                              \
1788 +         __builtin_tabort (_ABORT_NESTED_TRYLOCK);             \
1789 +       ret = ELIDE_LOCK (adapt_count, is_lock_free);           \
1790 +      }                                                                \
1791 +    ret;                                                       \
1792 +  })
1793  
1794  
1795  static inline bool
1796 diff --git a/sysdeps/sparc/sparc32/sem_open.c b/sysdeps/sparc/sparc32/sem_open.c
1797 index 16cb9ad..59df2d7 100644
1798 --- a/sysdeps/sparc/sparc32/sem_open.c
1799 +++ b/sysdeps/sparc/sparc32/sem_open.c
1800 @@ -29,6 +29,7 @@
1801  #include <sys/mman.h>
1802  #include <sys/stat.h>
1803  #include "semaphoreP.h"
1804 +#include <futex-internal.h>
1805  #include <shm-directory.h>
1806  
1807  
1808 diff --git a/sysdeps/unix/sysv/linux/hppa/bits/atomic.h b/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
1809 index abde83e..6e73504 100644
1810 --- a/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
1811 +++ b/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
1812 @@ -56,42 +56,41 @@ typedef uintmax_t uatomic_max_t;
1813  #define _LWS "0xb0"
1814  #define _LWS_CAS "0"
1815  /* Note r31 is the link register.  */
1816 -#define _LWS_CLOBBER "r1", "r26", "r25", "r24", "r23", "r22", "r21", "r20", "r28", "r31", "memory"
1817 +#define _LWS_CLOBBER "r1", "r23", "r22", "r20", "r31", "memory"
1818  /* String constant for -EAGAIN.  */
1819  #define _ASM_EAGAIN "-11"
1820  /* String constant for -EDEADLOCK.  */
1821  #define _ASM_EDEADLOCK "-45"
1822  
1823  #if __ASSUME_LWS_CAS
1824 -/* The only basic operation needed is compare and exchange.  */
1825 +/* The only basic operation needed is compare and exchange.  The mem
1826 +   pointer must be word aligned.  */
1827  # define atomic_compare_and_exchange_val_acq(mem, newval, oldval)      \
1828    ({                                                                   \
1829 -     volatile int lws_errno;                                           \
1830 -     __typeof__ (*mem) lws_ret;                                                \
1831 -     asm volatile(                                                     \
1832 +     register long lws_errno asm("r21");                               \
1833 +     register unsigned long lws_ret asm("r28");                                \
1834 +     register unsigned long lws_mem asm("r26") = (unsigned long)(mem); \
1835 +     register unsigned long lws_old asm("r25") = (unsigned long)(oldval);\
1836 +     register unsigned long lws_new asm("r24") = (unsigned long)(newval);\
1837 +     __asm__ __volatile__(                                             \
1838         "0:                                     \n\t"                   \
1839 -       "copy   %2, %%r26                       \n\t"                   \
1840 -       "copy   %3, %%r25                       \n\t"                   \
1841 -       "copy   %4, %%r24                       \n\t"                   \
1842         "ble    " _LWS "(%%sr2, %%r0)           \n\t"                   \
1843         "ldi    " _LWS_CAS ", %%r20             \n\t"                   \
1844 -       "ldi    " _ASM_EAGAIN ", %%r24          \n\t"                   \
1845 -       "cmpb,=,n %%r24, %%r21, 0b              \n\t"                   \
1846 +       "ldi    " _ASM_EAGAIN ", %%r20          \n\t"                   \
1847 +       "cmpb,=,n %%r20, %%r21, 0b              \n\t"                   \
1848         "nop                                    \n\t"                   \
1849 -       "ldi    " _ASM_EDEADLOCK ", %%r25       \n\t"                   \
1850 -       "cmpb,=,n %%r25, %%r21, 0b              \n\t"                   \
1851 +       "ldi    " _ASM_EDEADLOCK ", %%r20       \n\t"                   \
1852 +       "cmpb,=,n %%r20, %%r21, 0b              \n\t"                   \
1853         "nop                                    \n\t"                   \
1854 -       "stw    %%r28, %0                       \n\t"                   \
1855 -       "stw    %%r21, %1                       \n\t"                   \
1856 -       : "=m" (lws_ret), "=m" (lws_errno)                              \
1857 -        : "r" (mem), "r" (oldval), "r" (newval)                                \
1858 +       : "=r" (lws_ret), "=r" (lws_errno)                              \
1859 +       : "r" (lws_mem), "r" (lws_old), "r" (lws_new)                   \
1860         : _LWS_CLOBBER                                                  \
1861       );                                                                        \
1862                                                                         \
1863 -     if(lws_errno == -EFAULT || lws_errno == -ENOSYS)                  \
1864 +     if (lws_errno == -EFAULT || lws_errno == -ENOSYS)                 \
1865         ABORT_INSTRUCTION;                                              \
1866                                                                         \
1867 -     lws_ret;                                                          \
1868 +     (__typeof (oldval)) lws_ret;                                      \
1869     })
1870  
1871  # define atomic_compare_and_exchange_bool_acq(mem, newval, oldval)     \
1872 diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
1873 index 83c0340..9d5c542 100644
1874 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
1875 +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
1876 @@ -16,8 +16,11 @@
1877     License along with the GNU C Library; if not, see
1878     <http://www.gnu.org/licenses/>.  */
1879  
1880 +#ifndef _LINUX_MICROBLAZE_SYSDEP_H
1881 +#define _LINUX_MICROBLAZE_SYSDEP_H 1
1882 +
1883 +#include <sysdeps/unix/sysdep.h>
1884  #include <sysdeps/microblaze/sysdep.h>
1885 -#include <sys/syscall.h>
1886  
1887  /* Defines RTLD_PRIVATE_ERRNO.  */
1888  #include <dl-sysdep.h>
1889 @@ -305,3 +308,5 @@ SYSCALL_ERROR_LABEL_DCL:                            \
1890  # define PTR_DEMANGLE(var) (void) (var)
1891  
1892  #endif /* not __ASSEMBLER__ */
1893 +
1894 +#endif /* _LINUX_MICROBLAZE_SYSDEP_H */
1895 diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c
1896 index 6777123..ad8e31d 100644
1897 --- a/sysdeps/unix/sysv/linux/openat.c
1898 +++ b/sysdeps/unix/sysv/linux/openat.c
1899 @@ -68,6 +68,11 @@ __OPENAT (int fd, const char *file, int oflag, ...)
1900        va_end (arg);
1901      }
1902  
1903 +  /* We have to add the O_LARGEFILE flag for openat64.  */
1904 +#ifdef MORE_OFLAGS
1905 +  oflag |= MORE_OFLAGS;
1906 +#endif
1907 +
1908    return SYSCALL_CANCEL (openat, fd, file, oflag, mode);
1909  }
1910  libc_hidden_def (__OPENAT)
1911 diff --git a/wcsmbs/wcscoll_l.c b/wcsmbs/wcscoll_l.c
1912 index 6d9384a..87f240d 100644
1913 --- a/wcsmbs/wcscoll_l.c
1914 +++ b/wcsmbs/wcscoll_l.c
1915 @@ -23,7 +23,6 @@
1916  #define STRING_TYPE wchar_t
1917  #define USTRING_TYPE wint_t
1918  #define STRCOLL __wcscoll_l
1919 -#define STRDIFF __wcsdiff
1920  #define STRCMP __wcscmp
1921  #define WEIGHT_H "../locale/weightwc.h"
1922  #define SUFFIX WC
This page took 0.17042 seconds and 2 git commands to generate.