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