diff options
Diffstat (limited to 'libc')
32 files changed, 634 insertions, 288 deletions
diff --git a/libc/ChangeLog b/libc/ChangeLog index 824ec0e1c..08f1c06fd 100644 --- a/libc/ChangeLog +++ b/libc/ChangeLog @@ -1,3 +1,85 @@ +2011-05-15 Ulrich Drepper <drepper@gmail.com> + + [BZ #11901] + * include/stdlib.h: Move include protection to the right place. + Define abort_msg_s. Declare __abort_msg with it. + * stdlib/abort.c (__abort_msg): Adjust type. + * assert/assert.c (__assert_fail_base): New function. Majority + of code from __assert_fail. Allocate memory for __abort_msg with + mmap. + (__assert_fail): Now call __assert_fail_base. + * assert/assert-perr.c: Remove bulk of implementation. Use + __assert_fail_base. + * include/assert.hL Declare __assert_fail_base. + * sysdeps/posix/libc_fatal.c: Allocate memory for __abort_msg with + mmap. + * sysdeps/unix/sysv/linux/libc_fatal.c: Likewise. + +2011-05-14 Ulrich Drepper <drepper@gmail.com> + + [BZ #11952] + [BZ #12453] + * elf/dl-open.c (dl_open_worker): Delay calls to _dl_update_slotinfo + until all modules are registered in the DTV. + * elf/Makefile: Add rules to build and run tst-tls19. + * elf/tst-tls19.c: New file. + * elf/tst-tls19mod1.c: New file. + * elf/tst-tls19mod2.c: New file. + * elf/tst-tls19mod3.c: New file. + Patch mostly by Martin von Gagern <Martin.vGagern@gmx.net>. + + [BZ #12083] + * sysdeps/pthread/aio_misc.c (__aio_init): Compute optim.aio_num + correctly. + + [BZ #12601] + * iconvdata/cp932.c (BODY to UCS4): Fix incrementing inptr in case of + two-byte sequence errors. + * iconvdata/Makefile (tests): Add bug-iconv8. + * iconvdata/bug-iconv8.c: New file. + + [BZ #12626] + * sysdeps/generic/elf/backtracesymsfd.c (__backtrace_symbols_fd): Move + buf2 definition. + + * libio/fileops.c (_IO_new_file_close_it): Initialize write_status. + + [BZ #12432] + * sysdeps/ia64/backtrace.c (struct trace_reg): Add cfa element. + (dummy_getcfa): New function. + (init): Get _Unwind_GetCFA address, use dummy if not found. + (backtrace_helper): In recursion check, also check whether CFA changes. + (__backtrace): Completely initialize arg. + + * iconv/loop.c (SINGLE) [STORE_REST]: Add input bytes to bytebuf before + storing incomplete byte sequence in state object. Avoid testing for + guaranteed too small input if we know there is enough data available. + +2011-05-11 Andreas Schwab <schwab@redhat.com> + + * Makeconfig (+link-pie): Indent. + * Rules (binaries-pie): Define if $(have-fpie) and + $(build-shared). + (binaries-shared): Also filter out $(binaries-pie). + ($(addprefix $(objpfx),$(binaries-pie))): New rule. + * nscd/Makefile (others-pie): Add nscd. + (LDFLAGS-nscd): Set this instead of relro-LDFLAGS. + ($(objpfx)nscd): Remove command override. + * login/Makefile (others-pie): Add pt_chown. + ($(objpfx)pt_chown): Remove command override. + * elf/Makefile: Add PIE tests to tests and tests-pie variables and + remove command overrides. + +2011-05-13 Ulrich Drepper <drepper@gmail.com> + + * libio/tst_putwc.c: Fix error messages. + + [BZ #12724] + * libio/fileops.c (_IO_new_file_close_it): Always flush when + currently writing and seek to current position when not. + * libio/Makefile (tests): Add bug-fclose1. + * libio/bug-fclose1.c: New file. + 2011-05-12 Ulrich Drepper <drepper@gmail.com> [BZ #12511] diff --git a/libc/Makeconfig b/libc/Makeconfig index 470d742a3..ea7bf3437 100644 --- a/libc/Makeconfig +++ b/libc/Makeconfig @@ -450,9 +450,9 @@ ifndef +link-pie $(addprefix $(csu-objpfx),S$(start-installed-name)) \ $(+preinit) $(+prectorS) \ $(filter-out $(addprefix $(csu-objpfx),start.o \ - S$(start-installed-name))\ - $(+preinit) $(link-extra-libs) \ - $(common-objpfx)libc% $(+postinit),$^) \ + S$(start-installed-name))\ + $(+preinit) $(link-extra-libs) \ + $(common-objpfx)libc% $(+postinit),$^) \ $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit) endif # Command for statically linking programs with the C library. @@ -1,4 +1,4 @@ -GNU C Library NEWS -- history of user-visible changes. 2011-5-11 +GNU C Library NEWS -- history of user-visible changes. 2011-5-14 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc. See the end for copying conditions. @@ -9,11 +9,12 @@ Version 2.14 * The following bugs are resolved with this release: - 386, 11257, 11258, 11487, 11532, 11578, 11653, 11668, 11724, 11945, 11947, - 12052, 12158, 12178, 12200, 12346, 12393, 12420, 12445, 12449, 12454, - 12460, 12469, 12489, 12509, 12510, 12511, 12518, 12527, 12541, 12545, - 12551, 12583, 12587, 12597, 12611, 12625, 12631, 12650, 12653, 12655, - 12660, 12681, 12685, 12711, 12713, 12714, 12717, 12723, 12734, 12738 + 386, 11257, 11258, 11487, 11532, 11578, 11653, 11668, 11724, 11901, 11945, + 11947, 11952, 12052, 12083, 12158, 12178, 12200, 12346, 12393, 12420, + 12432, 12445, 12449, 12453, 12454, 12460, 12469, 12489, 12509, 12510, + 12511, 12518, 12527, 12541, 12545, 12551, 12582, 12583, 12587, 12597, + 12601, 12611, 12625, 12626, 12631, 12650, 12653, 12655, 12660, 12681, + 12685, 12711, 12713, 12714, 12717, 12723, 12724, 12734, 12738 * The RPC implementation in libc is obsoleted. Old programs keep working but new programs cannot be linked with the routines in libc anymore. diff --git a/libc/Rules b/libc/Rules index 434b8a230..a7cbdd3b9 100644 --- a/libc/Rules +++ b/libc/Rules @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2000,2002,2003,2004,2005,2006 +# Copyright (C) 1991-2000,2002,2003,2004,2005,2006,2011 # Free Software Foundation, Inc. # This file is part of the GNU C Library. @@ -106,12 +106,19 @@ xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-bp.out) ifeq ($(build-programs),yes) binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs) binaries-static = $(others-static) $(tests-static) $(xtests-static) +ifeq (yesyes,$(have-fpie)$(build-shared)) +binaries-pie = $(others-pie) $(tests-pie) $(xtests-pie) +else +binaries-pie = +endif else binaries-all = $(tests) $(xtests) $(test-srcs) binaries-static = +binaries-pie = endif -binaries-shared = $(filter-out $(binaries-static), $(binaries-all)) +binaries-shared = $(filter-out $(binaries-pie) $(binaries-static), \ + $(binaries-all)) ifneq "$(strip $(binaries-shared))" "" $(addprefix $(objpfx),$(binaries-shared)): %: %.o \ @@ -120,6 +127,13 @@ $(addprefix $(objpfx),$(binaries-shared)): %: %.o \ $(+link) endif +ifneq "$(strip $(binaries-pie))" "" +$(addprefix $(objpfx),$(binaries-pie)): %: %.o \ + $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \ + $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) + $(+link-pie) +endif + ifneq "$(strip $(binaries-static))" "" $(addprefix $(objpfx),$(binaries-static)): %: %.o \ $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \ diff --git a/libc/assert/assert-perr.c b/libc/assert/assert-perr.c index f239fab86..cad87dab0 100644 --- a/libc/assert/assert-perr.c +++ b/libc/assert/assert-perr.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1994-1998,2001,2002,2005,2009 Free Software Foundation, Inc. +/* Copyright (C) 1994-1998,2001,2002,2005,2009,2011 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,66 +18,23 @@ 02111-1307 USA. */ #include <assert.h> -#include <atomic.h> #include <libintl.h> -#include <stdio.h> -#include <stdlib.h> #include <string.h> -#include <sysdep.h> -#include <unistd.h> -extern const char *__progname; - -#ifdef USE_IN_LIBIO -# include <wchar.h> -# include <libio/iolibio.h> -# define fflush(s) INTUSE(_IO_fflush) (s) -#endif - /* This function, when passed an error number, a filename, and a line number, prints a message on the standard error stream of the form: - a.c:10: foobar: Unexpected error: Computer bought the farm + a.c:10: foobar: Unexpected error: Computer bought the farm It then aborts program execution via a call to `abort'. */ - -#ifdef FATAL_PREPARE_INCLUDE -# include FATAL_PREPARE_INCLUDE -#endif - void __assert_perror_fail (int errnum, const char *file, unsigned int line, const char *function) { char errbuf[1024]; - char *buf; - -#ifdef FATAL_PREPARE - FATAL_PREPARE; -#endif - - if (__asprintf (&buf, _("%s%s%s:%u: %s%sUnexpected error: %s.\n"), - __progname, __progname[0] ? ": " : "", - file, line, - function ? function : "", function ? ": " : "", - __strerror_r (errnum, errbuf, sizeof errbuf)) >= 0) - { - /* Print the message. */ - (void) __fxprintf (NULL, "%s", buf); - (void) fflush (stderr); - - /* We have to free the old buffer since the application might - catch the SIGABRT signal. */ - char *old = atomic_exchange_acq (&__abort_msg, buf); - free (old); - } - else - { - /* At least print a minimal message. */ - static const char errstr[] = "Unexpected error.\n"; - __libc_write (STDERR_FILENO, errstr, sizeof (errstr) - 1); - } - abort (); + char *e = __strerror_r (errnum, errbuf, sizeof errbuf); + __assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n"), + e, file, line, function); } libc_hidden_def (__assert_perror_fail) diff --git a/libc/assert/assert.c b/libc/assert/assert.c index 727fb1446..803015f0f 100644 --- a/libc/assert/assert.c +++ b/libc/assert/assert.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1994-1996,1998,2001,2002,2005,2009 +/* Copyright (C) 1991,1994-1996,1998,2001,2002,2005,2009,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,11 +19,13 @@ #include <assert.h> #include <atomic.h> +#include <ldsodefs.h> #include <libintl.h> #include <stdio.h> #include <stdlib.h> #include <sysdep.h> #include <unistd.h> +#include <sys/mman.h> extern const char *__progname; @@ -37,7 +39,7 @@ extern const char *__progname; /* This function, when passed a string containing an asserted expression, a filename, and a line number, prints a message on the standard error stream of the form: - a.c:10: foobar: Assertion `a == b' failed. + a.c:10: foobar: Assertion `a == b' failed. It then aborts program execution via a call to `abort'. */ #ifdef FATAL_PREPARE_INCLUDE @@ -45,31 +47,44 @@ extern const char *__progname; #endif -#undef __assert_fail void -__assert_fail (const char *assertion, const char *file, unsigned int line, - const char *function) +__assert_fail_base (const char *fmt, const char *assertion, const char *file, + unsigned int line, const char *function) { - char *buf; + char *str; #ifdef FATAL_PREPARE FATAL_PREPARE; #endif - if (__asprintf (&buf, _("%s%s%s:%u: %s%sAssertion `%s' failed.\n"), + int total; + if (__asprintf (&str, fmt, __progname, __progname[0] ? ": " : "", file, line, function ? function : "", function ? ": " : "", - assertion) >= 0) + assertion, &total) >= 0) { /* Print the message. */ - (void) __fxprintf (NULL, "%s", buf); + (void) __fxprintf (NULL, "%s", str); (void) fflush (stderr); - /* We have to free the old buffer since the application might - catch the SIGABRT signal. */ - char *old = atomic_exchange_acq (&__abort_msg, buf); - free (old); + total = (total + 1 + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1); + struct abort_msg_s *buf = __mmap (NULL, total, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + if (__builtin_expect (buf != MAP_FAILED, 1)) + { + buf->size = total; + strcpy (buf->msg, str); + + /* We have to free the old buffer since the application might + catch the SIGABRT signal. */ + struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, buf); + + if (old != NULL) + __munmap (old, old->size); + } + + free (str); } else { @@ -80,4 +95,14 @@ __assert_fail (const char *assertion, const char *file, unsigned int line, abort (); } + + +#undef __assert_fail +void +__assert_fail (const char *assertion, const char *file, unsigned int line, + const char *function) +{ + __assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n%n"), + assertion, file, line, function); +} hidden_def(__assert_fail) diff --git a/libc/elf/Makefile b/libc/elf/Makefile index 5cbcd410a..7e00096cb 100644 --- a/libc/elf/Makefile +++ b/libc/elf/Makefile @@ -76,6 +76,7 @@ distribute := rtld-Rules \ tst-tlsmod12.c tst-tls10.h tst-alignmod.c tst-alignmod2.c \ circlemod1.c circlemod1a.c circlemod2.c circlemod2a.c \ circlemod3.c circlemod3a.c nodlopenmod2.c \ + tst-tls19mod1.c tst-tls19mod2.c tst-tls19mod3.c \ tls-macros.h \ reldep8mod1.c reldep8mod2.c reldep8mod3.c \ nodel2mod1.c nodel2mod2.c nodel2mod3.c \ @@ -195,7 +196,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \ circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \ tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \ - tst-tls16 tst-tls17 tst-tls18 tst-tls-dlinfo \ + tst-tls16 tst-tls17 tst-tls18 tst-tls19 tst-tls-dlinfo \ tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \ tst-dlmodcount tst-dlopenrpath tst-deep1 \ tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \ @@ -214,9 +215,6 @@ ifeq (x86_64,$(config-machine)) tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 endif endif -ifeq (yesyes,$(have-fpie)$(build-shared)) -tests: $(objpfx)tst-pie1.out -endif tests: $(objpfx)tst-leaks1-mem $(objpfx)noload-mem tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 @@ -244,6 +242,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ tst-tlsmod13 tst-tlsmod13a tst-tlsmod14a tst-tlsmod14b \ tst-tlsmod15a tst-tlsmod15b tst-tlsmod16a tst-tlsmod16b \ $(tlsmod17a-modules) tst-tlsmod17b $(tlsmod18a-modules) \ + tst-tls19mod1 tst-tls19mod2 tst-tls19mod3 \ circlemod1 circlemod1a circlemod2 circlemod2a \ circlemod3 circlemod3a \ reldep8mod1 reldep8mod2 reldep8mod3 \ @@ -269,8 +268,8 @@ modules-names += tst-array2dep tst-array5dep endif ifeq (yesyes,$(have-fpie)$(build-shared)) modules-names += tst-piemod1 -extra-test-objs += tst-pie1.o -test-extras += tst-pie1 +tests += tst-pie1 +tests-pie += tst-pie1 endif ifeq (x86_64,$(config-machine)) modules-names += tst-auditmod3a tst-auditmod3b \ @@ -307,9 +306,8 @@ test-extras += $(ifunc-test-modules) ifeq (yes,$(have-fpie)) ifunc-pie-tests = ifuncmain1pie ifuncmain1vispie ifuncmain1staticpie \ ifuncmain5pie ifuncmain6pie ifuncmain7pie -tests: $(patsubst %,$(objpfx)%.out, $(ifunc-pie-tests)) -extra-test-objs += $(ifunc-pie-tests:=.o) -test-extras += $(ifunc-pie-tests) +tests += $(ifunc-pie-tests) +tests-pie += $(ifunc-pie-tests) endif modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6 endif @@ -532,6 +530,8 @@ $(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so # For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED $(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so $(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so +$(objpfx)tst-tls19mod1.so: $(objpfx)tst-tls19mod2.so $(objpfx)tst-tls19mod3.so +$(objpfx)tst-tls19mod3.so: $(objpfx)ld.so $(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so $(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so $(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so @@ -833,6 +833,9 @@ $(patsubst %,$(objpfx)%.os,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.os : t $(compile-command.c) -DN=$* $(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.so: $(objpfx)ld.so +$(objpfx)tst-tls19: $(libdl) +$(objpfx)tst-tls19.out: $(objpfx)tst-tls19mod1.so + CFLAGS-tst-align.c = $(stack-align-test-flags) CFLAGS-tst-align2.c = $(stack-align-test-flags) CFLAGS-tst-alignmod.c = $(stack-align-test-flags) @@ -918,20 +921,9 @@ $(objpfx)tst-array5-static.out: $(objpfx)tst-array5-static $(objpfx)tst-array5-static > $@ cmp $@ tst-array5-static.exp > /dev/null -ifeq (yesyes,$(have-fpie)$(build-shared)) CFLAGS-tst-pie1.c += $(pie-ccflag) -$(objpfx)tst-pie1.out: $(objpfx)tst-pie1 - $(cross-test-wrapper) \ - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)tst-pie1: $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so - $(+link-pie) - -generated += tst-pie1 tst-pie1.out tst-pie1.o -endif +$(objpfx)tst-pie1: $(objpfx)tst-piemod1.so check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE $(objpfx)check-textrel: check-textrel.c @@ -1102,7 +1094,6 @@ CFLAGS-ifuncmain7picstatic.c += $(pic-ccflag) LDFLAGS-ifuncmain3 = -Wl,-export-dynamic -ifeq (yesyes,$(have-fpie)$(build-shared)) CFLAGS-ifuncmain1pie.c += $(pie-ccflag) CFLAGS-ifuncmain1vispie.c += $(pie-ccflag) CFLAGS-ifuncmain1staticpie.c += $(pie-ccflag) @@ -1110,66 +1101,11 @@ CFLAGS-ifuncmain5pie.c += $(pie-ccflag) CFLAGS-ifuncmain6pie.c += $(pie-ccflag) CFLAGS-ifuncmain7pie.c += $(pie-ccflag) -$(objpfx)ifuncmain1pie.out: $(objpfx)ifuncmain1pie - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)ifuncmain1pie: $(objpfx)ifuncmain1pie.o $(objpfx)ifuncmod1.so - $(+link-pie) - -generated += ifuncmain1pie ifuncmain1pie.out - -$(objpfx)ifuncmain1staticpie.out: $(objpfx)ifuncmain1staticpie - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)ifuncmain1staticpie: $(objpfx)ifuncmain1staticpie.o $(objpfx)ifuncdep1pic.o - $(+link-pie) - -generated += ifuncmain1staticpie ifuncmain1staticpie.out - -$(objpfx)ifuncmain1vispie.out: $(objpfx)ifuncmain1vispie - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)ifuncmain1vispie: $(objpfx)ifuncmain1vispie.o $(objpfx)ifuncmod1.so - $(+link-pie) - -generated += ifuncmain1vispie ifuncmain1vispie.out - -$(objpfx)ifuncmain5pie.out: $(objpfx)ifuncmain5pie - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)ifuncmain5pie: $(objpfx)ifuncmain5pie.o $(objpfx)ifuncmod5.so - $(+link-pie) - -generated += ifuncmain5pie ifuncmain5pie.out - -$(objpfx)ifuncmain6pie.out: $(objpfx)ifuncmain6pie - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)ifuncmain6pie: $(objpfx)ifuncmain6pie.o $(objpfx)ifuncmod6.so - $(+link-pie) - -generated += ifuncmain6pie ifuncmain6pie.out - -$(objpfx)ifuncmain7pie.out: $(objpfx)ifuncmain7pie - $(elf-objpfx)$(rtld-installed-name) \ - --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ - $< > $@ - -$(objpfx)ifuncmain7pie: $(objpfx)ifuncmain7pie.o - $(+link-pie) - -generated += ifuncmain7pie ifuncmain7pie.out -endif +$(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so +$(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o +$(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so +$(objpfx)ifuncmain5pie: $(objpfx)ifuncmod5.so +$(objpfx)ifuncmain6pie: $(objpfx)ifuncmod6.so $(objpfx)ifuncmain1: $(addprefix $(objpfx),ifuncmod1.so) $(objpfx)ifuncmain1pic: $(addprefix $(objpfx),ifuncmod1.so) diff --git a/libc/elf/dl-open.c b/libc/elf/dl-open.c index ee09f0ec5..a5b46a433 100644 --- a/libc/elf/dl-open.c +++ b/libc/elf/dl-open.c @@ -1,5 +1,5 @@ /* Load a shared object at runtime, relocate it, and run its initializer. - Copyright (C) 1996-2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1996-2007, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -347,6 +347,7 @@ dl_open_worker (void *a) /* If the file is not loaded now as a dependency, add the search list of the newly loaded object to the scope. */ bool any_tls = false; + unsigned int first_static_tls = new->l_searchlist.r_nlist; for (unsigned int i = 0; i < new->l_searchlist.r_nlist; ++i) { struct link_map *imap = new->l_searchlist.r_list[i]; @@ -425,30 +426,9 @@ dl_open_worker (void *a) might have to increase its size. */ _dl_add_to_slotinfo (imap); - if (imap->l_need_tls_init) - { - /* For static TLS we have to allocate the memory here - and now. This includes allocating memory in the DTV. - But we cannot change any DTV other than our own. So, - if we cannot guarantee that there is room in the DTV - we don't even try it and fail the load. - - XXX We could track the minimum DTV slots allocated in - all threads. */ - if (! RTLD_SINGLE_THREAD_P && imap->l_tls_modid > DTV_SURPLUS) - _dl_signal_error (0, "dlopen", NULL, N_("\ -cannot load any more object with static TLS")); - - imap->l_need_tls_init = 0; -#ifdef SHARED - /* Update the slot information data for at least the - generation of the DSO we are allocating data for. */ - _dl_update_slotinfo (imap->l_tls_modid); -#endif - - GL(dl_init_static_tls) (imap); - assert (imap->l_need_tls_init == 0); - } + if (imap->l_need_tls_init + && first_static_tls == new->l_searchlist.r_nlist) + first_static_tls = i; /* We have to bump the generation counter. */ any_tls = true; @@ -460,6 +440,40 @@ cannot load any more object with static TLS")); _dl_fatal_printf (N_("\ TLS generation counter wrapped! Please report this.")); + /* We need a second pass for static tls data, because _dl_update_slotinfo + must not be run while calls to _dl_add_to_slotinfo are still pending. */ + for (unsigned int i = first_static_tls; i < new->l_searchlist.r_nlist; ++i) + { + struct link_map *imap = new->l_searchlist.r_list[i]; + + if (imap->l_need_tls_init + && ! imap->l_init_called + && imap->l_tls_blocksize > 0) + { + /* For static TLS we have to allocate the memory here and + now. This includes allocating memory in the DTV. But we + cannot change any DTV other than our own. So, if we + cannot guarantee that there is room in the DTV we don't + even try it and fail the load. + + XXX We could track the minimum DTV slots allocated in + all threads. */ + if (! RTLD_SINGLE_THREAD_P && imap->l_tls_modid > DTV_SURPLUS) + _dl_signal_error (0, "dlopen", NULL, N_("\ +cannot load any more object with static TLS")); + + imap->l_need_tls_init = 0; +#ifdef SHARED + /* Update the slot information data for at least the + generation of the DSO we are allocating data for. */ + _dl_update_slotinfo (imap->l_tls_modid); +#endif + + GL(dl_init_static_tls) (imap); + assert (imap->l_need_tls_init == 0); + } + } + /* Run the initializer functions of new objects. */ _dl_init (new, args->argc, args->argv, args->env); diff --git a/libc/elf/tst-tls19.c b/libc/elf/tst-tls19.c new file mode 100644 index 000000000..acbc1d696 --- /dev/null +++ b/libc/elf/tst-tls19.c @@ -0,0 +1,27 @@ +// BZ 12453 +#include <stdio.h> +#include <dlfcn.h> + + +static int +do_test (void) +{ + void* dl = dlopen ("tst-tls19mod1.so", RTLD_LAZY | RTLD_GLOBAL); + if (dl == NULL) + { + printf ("Error loading tst-tls19mod1.so: %s\n", dlerror ()); + return 1; + } + + int (*fn) (void) = dlsym (dl, "foo"); + if (fn == NULL) + { + printf("Error obtaining symbol foo\n"); + return 1; + } + + return fn (); +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/elf/tst-tls19mod1.c b/libc/elf/tst-tls19mod1.c new file mode 100644 index 000000000..2790097ae --- /dev/null +++ b/libc/elf/tst-tls19mod1.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +extern int bar (void); +extern int baz (void); + +int +foo (void) +{ + int v1 = bar (); + int v2 = baz (); + + printf ("bar=%d, baz=%d\n", v1, v2); + + return v1 != 666 || v2 != 42; +} diff --git a/libc/elf/tst-tls19mod2.c b/libc/elf/tst-tls19mod2.c new file mode 100644 index 000000000..cae702f67 --- /dev/null +++ b/libc/elf/tst-tls19mod2.c @@ -0,0 +1,13 @@ +static int __thread tbar __attribute__ ((tls_model ("initial-exec"))) = 666; + +void +setter (int a) +{ + tbar = a; +} + +int +bar (void) +{ + return tbar; +} diff --git a/libc/elf/tst-tls19mod3.c b/libc/elf/tst-tls19mod3.c new file mode 100644 index 000000000..e7b28016b --- /dev/null +++ b/libc/elf/tst-tls19mod3.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +static int __thread tbaz __attribute__ ((tls_model ("local-dynamic"))) = 42; + +void +setter2 (int a) +{ + tbaz = a; +} + +int +baz (void) +{ + printf ("&tbaz=%p\n", &tbaz); + return tbaz; +} diff --git a/libc/iconv/loop.c b/libc/iconv/loop.c index da11bc209..4f430628f 100644 --- a/libc/iconv/loop.c +++ b/libc/iconv/loop.c @@ -1,5 +1,5 @@ /* Conversion loop frame work. - Copyright (C) 1998-2002, 2003, 2005, 2008 Free Software Foundation, Inc. + Copyright (C) 1998-2003, 2005, 2008, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -395,10 +395,14 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, #endif /* Are there enough bytes in the input buffer? */ - if (__builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0)) + if (MIN_NEEDED_INPUT > 1 + && __builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0)) { *inptrp = inend; #ifdef STORE_REST + while (inptr < inend) + bytebuf[inlen++] = *inptr++; + inptr = bytebuf; inptrp = &inptr; inend = &bytebuf[inlen]; diff --git a/libc/iconvdata/Makefile b/libc/iconvdata/Makefile index 7faec6b2d..f4e393d1f 100644 --- a/libc/iconvdata/Makefile +++ b/libc/iconvdata/Makefile @@ -71,7 +71,7 @@ include ../Makeconfig ifeq (yes,$(build-shared)) tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \ - tst-iconv6 bug-iconv5 + tst-iconv6 bug-iconv5 bug-iconv8 tests-$(OPTION_EGLIBC_LOCALE_CODE) += bug-iconv6 tst-iconv7 ifeq ($(have-thread-library),yes) tests += bug-iconv3 diff --git a/libc/iconvdata/bug-iconv8.c b/libc/iconvdata/bug-iconv8.c new file mode 100644 index 000000000..54c6be2f6 --- /dev/null +++ b/libc/iconvdata/bug-iconv8.c @@ -0,0 +1,43 @@ +// BZ 12601 +#include <stdio.h> +#include <errno.h> +#include <iconv.h> + +static int +do_test (void) +{ + iconv_t cd; + char in[] = "\x83\xd9"; + char out[256]; + char *inbuf; + size_t inbytesleft; + char *outbuf; + size_t outbytesleft; + size_t ret; + + inbuf = in; + inbytesleft = sizeof(in) - 1; + outbuf = out; + outbytesleft = sizeof(out); + + cd = iconv_open("utf-8", "cp932"); + ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + iconv_close(cd); + + printf("result: %ld %d %ld %d\n", ret, errno, inbytesleft, inbuf[0]); + + /* + * result: -1 84 0 0 (84=EILSEQ) + * + * Error is returnd but inbuf is consumed. + * + * \x83\xd9 is valid shift-jis sequence but no character is assigned + * to it. + */ + + return (ret != -1 || errno != EILSEQ + || inbytesleft != 2 || inbuf[0] != in[0]); +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/iconvdata/cp932.c b/libc/iconvdata/cp932.c index 90ecad96b..00d83d455 100644 --- a/libc/iconvdata/cp932.c +++ b/libc/iconvdata/cp932.c @@ -1,5 +1,5 @@ /* Mapping tables for CP932 handling. - Copyright (C) 1997,1998,1999,2000,2001,2003 Free Software Foundation, Inc. + Copyright (C) 1997-2001,2003,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by MORIYAMA Masayuki <msyk@mtg.biglobe.ne.jp>, 2003. @@ -4549,8 +4549,8 @@ static const char from_ucs4_extra[229][2] = ++inptr; \ else if (ch >= 0xa1 && ch <= 0xdf) \ { \ - ch += 0xfec0; \ - ++inptr; \ + ch += 0xfec0; \ + ++inptr; \ } \ else if (__builtin_expect (ch, 0) == 0xa0 \ || __builtin_expect (ch <= 0x80, 0) \ @@ -4588,65 +4588,63 @@ static const char from_ucs4_extra[229][2] = if (__builtin_expect (ch2 < 0x40, 0) \ || __builtin_expect (ch2 > 0xfc, 0) \ || __builtin_expect (ch2 == 0x7f, 0) \ - || (__builtin_expect (idx > 0x84be, 0) && idx < 0x8740) \ - || (__builtin_expect (idx > 0x879c, 0) && idx < 0x889f) \ - || (__builtin_expect (idx > 0x88fc, 0) && idx < 0x8940) \ - || (__builtin_expect (idx > 0x9ffc, 0) && idx < 0xe040) \ - || (__builtin_expect (idx > 0xeaa4, 0) && idx < 0xed40) \ - || (__builtin_expect (idx > 0xeefc, 0) && idx < 0xf040) \ + || (__builtin_expect (idx > 0x84be, 0) && idx < 0x8740) \ + || (__builtin_expect (idx > 0x879c, 0) && idx < 0x889f) \ + || (__builtin_expect (idx > 0x88fc, 0) && idx < 0x8940) \ + || (__builtin_expect (idx > 0x9ffc, 0) && idx < 0xe040) \ + || (__builtin_expect (idx > 0xeaa4, 0) && idx < 0xed40) \ + || (__builtin_expect (idx > 0xeefc, 0) && idx < 0xf040) \ || __builtin_expect (idx > 0xfc4b, 0)) \ { \ /* This is illegal. */ \ if (! ignore_errors_p ()) \ { \ - /* This is an illegal character. */ \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ + /* This is an illegal character. */ \ + result = __GCONV_ILLEGAL_INPUT; \ + break; \ } \ \ ++inptr; \ ++*irreversible; \ continue; \ } \ - else \ - { \ - /* We could pack the data a bit more dense. The second \ - byte will never be 0x7f and it will also be never \ - >0xfc. But this would mean yet more `if's. */ \ - if (idx <= 0x84be) \ - ch = cjk_block1[(ch - 0x81) * 192 + ch2 - 0x40]; \ - else if (idx <= 0x879c) \ - ch = cjk_block2[(ch - 0x87) * 192 + ch2 - 0x40]; \ - else if (idx <= 0x88fc) \ - ch = cjk_block3[(ch - 0x88) * 192 + ch2 - 0x9f]; \ - else if (idx <= 0x9ffc) \ - ch = cjk_block4[(ch - 0x89) * 192 + ch2 - 0x40]; \ - else if (idx <= 0xeaa4) \ - ch = cjk_block5[(ch - 0xe0) * 192 + ch2 - 0x40]; \ - else if (idx <= 0xeefc) \ - ch = cjk_block6[(ch - 0xed) * 192 + ch2 - 0x40]; \ - else if (idx <= 0xf9fc) \ - ch = (ch-0xf0)*188 + ch2-((ch2<0x7f)?0x40:0x41) + 0xe000; \ - else \ - ch = cjk_block7[(ch - 0xfa) * 192 + ch2 - 0x40]; \ \ - inptr += 2; \ - } \ + /* We could pack the data a bit more dense. The second \ + byte will never be 0x7f and it will also be never \ + >0xfc. But this would mean yet more `if's. */ \ + if (idx <= 0x84be) \ + ch = cjk_block1[(ch - 0x81) * 192 + ch2 - 0x40]; \ + else if (idx <= 0x879c) \ + ch = cjk_block2[(ch - 0x87) * 192 + ch2 - 0x40]; \ + else if (idx <= 0x88fc) \ + ch = cjk_block3[(ch - 0x88) * 192 + ch2 - 0x9f]; \ + else if (idx <= 0x9ffc) \ + ch = cjk_block4[(ch - 0x89) * 192 + ch2 - 0x40]; \ + else if (idx <= 0xeaa4) \ + ch = cjk_block5[(ch - 0xe0) * 192 + ch2 - 0x40]; \ + else if (idx <= 0xeefc) \ + ch = cjk_block6[(ch - 0xed) * 192 + ch2 - 0x40]; \ + else if (idx <= 0xf9fc) \ + ch = (ch-0xf0)*188 + ch2-((ch2<0x7f)?0x40:0x41) + 0xe000; \ + else \ + ch = cjk_block7[(ch - 0xfa) * 192 + ch2 - 0x40]; \ \ if (__builtin_expect (ch, 1) == 0) \ { \ /* This is an illegal character. */ \ if (! ignore_errors_p ()) \ { \ - /* This is an illegal character. */ \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ + /* This is an illegal character. */ \ + result = __GCONV_ILLEGAL_INPUT; \ + break; \ } \ \ inptr += 2; \ ++*irreversible; \ continue; \ } \ + \ + inptr += 2; \ } \ \ put32 (outptr, ch); \ @@ -4674,7 +4672,7 @@ static const char from_ucs4_extra[229][2] = else if (ch >= 0x2010 && ch <= 0x9fa0) \ cp = from_ucs4_cjk[ch - 0x2010]; \ else if (ch >= 0xe000 && ch <= 0xe757) \ - { \ + { \ pua[0] = (ch - 0xe000) / 188 + 0xf0; \ pua[1] = (ch - 0xe000) % 188 + 0x40; \ if (pua[1] > 0x7e) \ diff --git a/libc/include/assert.h b/libc/include/assert.h index b53313de8..4b022342e 100644 --- a/libc/include/assert.h +++ b/libc/include/assert.h @@ -5,7 +5,7 @@ so it has to be repeated here. */ extern void __assert_fail (__const char *__assertion, __const char *__file, unsigned int __line, __const char *__function) - __THROW __attribute__ ((__noreturn__)); + __THROW __attribute__ ((__noreturn__)); /* Likewise, but prints the error text for ERRNUM. */ extern void __assert_perror_fail (int __errnum, __const char *__file, @@ -13,6 +13,12 @@ extern void __assert_perror_fail (int __errnum, __const char *__file, __const char *__function) __THROW __attribute__ ((__noreturn__)); +/* The real implementation of the two functions above. */ +extern void __assert_fail_base (const char *fmt, const char *assertion, + const char *file, unsigned int line, + const char *function) + __THROW __attribute__ ((__noreturn__)); + #if !defined NOT_IN_libc || defined IS_IN_rtld hidden_proto (__assert_fail) hidden_proto (__assert_perror_fail) diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index b4799d7d0..816f8ffc2 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -223,16 +223,21 @@ extern int __qfcvt_r (long double __value, int __ndigit, # define __cxa_atexit(func, arg, d) INTUSE(__cxa_atexit) (func, arg, d) # endif -#endif - extern void *__default_morecore (ptrdiff_t) __THROW; libc_hidden_proto (__default_morecore) -extern char *__abort_msg; +struct abort_msg_s +{ + unsigned int size; + char msg[0]; +}; +extern struct abort_msg_s *__abort_msg; libc_hidden_proto (__abort_msg) __END_DECLS +#endif + #undef __Need_M_And_C #endif /* include/stdlib.h */ diff --git a/libc/libio/Makefile b/libc/libio/Makefile index 6df1f4ba0..dd083c640 100644 --- a/libc/libio/Makefile +++ b/libc/libio/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2004,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 1995-2004,2006-2009,2011 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -67,7 +67,7 @@ tests = test-fmemopen tst-ext tst-ext2 \ tst-mmap2-eofsync tst-mmap-offend bug-fopena+ \ bug-ungetc2 bug-ungetc3 bug-ungetc4 \ tst-memstream1 tst-memstream2 \ - bug-memstream1 tst-popen1 + bug-memstream1 tst-popen1 bug-fclose1 tests-$(OPTION_EGLIBC_LOCALE_CODE) \ += tst-swscanf tst-fgetws tst-fopenloc tst-setvbuf1 \ tst-ungetwc1 tst-ungetwc2 bug-ftell bug-ungetwc2 \ diff --git a/libc/libio/bug-fclose1.c b/libc/libio/bug-fclose1.c new file mode 100644 index 000000000..f1e09f5d4 --- /dev/null +++ b/libc/libio/bug-fclose1.c @@ -0,0 +1,132 @@ +// BZ #12724 + +static void do_prepare (void); +#define PREPARE(argc, argv) do_prepare () +static int do_test (void); +#define TEST_FUNCTION do_test() +#include "../test-skeleton.c" + + +static int fd; + + +static void +do_prepare (void) +{ + fd = create_temp_file ("bug-fclose1.", NULL); + if (fd == -1) + { + printf ("cannot create temporary file: %m\n"); + exit (1); + } +} + + +static int +do_test (void) +{ + static const char pattern[] = "hello world"; + + /* Prepare a seekable file. */ + if (write (fd, pattern, sizeof pattern) != sizeof pattern) + { + printf ("cannot write pattern: %m\n"); + return 1; + } + if (lseek (fd, 1, SEEK_SET) != 1) + { + printf ("cannot seek after write: %m\n"); + return 1; + } + + /* Create an output stream visiting the file; when it is closed, all + other file descriptors visiting the file must see the new file + position. */ + int fd2 = dup (fd); + if (fd2 < 0) + { + printf ("cannot duplicate descriptor for writing: %m\n"); + return 1; + } + FILE *f = fdopen (fd2, "w"); + if (f == NULL) + { + printf ("first fdopen failed: %m\n"); + return 1; + } + if (fputc (pattern[1], f) != pattern[1]) + { + printf ("fputc failed: %m\n"); + return 1; + } + if (fclose (f) != 0) + { + printf ("first fclose failed: %m\n"); + return 1; + } + errno = 0; + if (lseek (fd2, 0, SEEK_CUR) != -1) + { + printf ("lseek after fclose after write did not fail\n"); + return 1; + } + if (errno != EBADF) + { + printf ("lseek after fclose after write did not fail with EBADF: %m\n"); + return 1; + } + off_t o = lseek (fd, 0, SEEK_CUR); + if (o != 2) + { + printf ("\ +lseek on original descriptor after first fclose returned %ld, expected 2\n", + (long int) o); + return 1; + } + + /* Likewise for an input stream. */ + fd2 = dup (fd); + if (fd2 < 0) + { + printf ("cannot duplicate descriptor for reading: %m\n"); + return 1; + } + f = fdopen (fd2, "r"); + if (f == NULL) + { + printf ("second fdopen failed: %m\n"); + return 1; + } + char c = fgetc (f); + if (c != pattern[2]) + { + printf ("getc returned %c, expected %c\n", c, pattern[2]); + return 1; + } + if (fclose (f) != 0) + { + printf ("second fclose failed: %m\n"); + return 1; + } + errno = 0; + if (lseek (fd2, 0, SEEK_CUR) != -1) + { + printf ("lseek after fclose after read did not fail\n"); + return 1; + } + if (errno != EBADF) + { + printf ("lseek after fclose after read did not fail with EBADF: %m\n"); + return 1; + } + o = lseek (fd, 0, SEEK_CUR); + if (o != 3) + { + printf ("\ +lseek on original descriptor after second fclose returned %ld, expected 3\n", + (long int) o); + return 1; + } + + return 0; +} diff --git a/libc/libio/fileops.c b/libc/libio/fileops.c index 9b03a9c55..1f7356540 100644 --- a/libc/libio/fileops.c +++ b/libc/libio/fileops.c @@ -161,19 +161,27 @@ int _IO_new_file_close_it (fp) _IO_FILE *fp; { - int write_status, close_status; if (!_IO_file_is_open (fp)) return EOF; - if ((fp->_flags & _IO_NO_WRITES) == 0 - && (fp->_flags & _IO_CURRENTLY_PUTTING) != 0) + int write_status; + if (_IO_in_put_mode (fp)) write_status = _IO_do_flush (fp); + else if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL + && !_IO_in_backup (fp)) + { + off64_t o = _IO_SEEKOFF (fp, 0, _IO_seek_cur, 0); + if (o == WEOF) + write_status = EOF; + else + write_status = _IO_SYSSEEK (fp, o, SEEK_SET) < 0 ? EOF : 0; + } else write_status = 0; INTUSE(_IO_unsave_markers) (fp); - close_status = _IO_SYSCLOSE (fp); + int close_status = _IO_SYSCLOSE (fp); /* Free buffer. */ #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T diff --git a/libc/libio/tst_putwc.c b/libc/libio/tst_putwc.c index 1fd21e26c..c6e7a9dbd 100644 --- a/libc/libio/tst_putwc.c +++ b/libc/libio/tst_putwc.c @@ -1,5 +1,5 @@ /* Simple test of putwc in the C locale. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000. @@ -74,13 +74,16 @@ do_test (void) /* Now close the file, open it again, and read again. */ if (fclose (fp) != 0) { - printf ("failure during fclose(): %m"); + printf ("failure during fclose: %m\n"); res = 1; } fp = fopen (outname, "r"); if (fp == NULL) - error (EXIT_FAILURE, errno, "cannot reopen file"); + { + printf ("cannot reopen file: %m\n"); + return 1; + } /* We can remove the file now. */ remove (outname); @@ -104,7 +107,7 @@ do_test (void) if (fclose (fp) != 0) { - puts ("failure during fclose()"); + printf ("failure during fclose: %m\n"); res = 1; } diff --git a/libc/localedata/ChangeLog b/libc/localedata/ChangeLog index dd2b292f8..8ea8c6885 100644 --- a/libc/localedata/ChangeLog +++ b/libc/localedata/ChangeLog @@ -1,3 +1,9 @@ +2011-05-14 Ulrich Drepper <drepper@gmail.com> + + [BZ #12582] + * localedata/charmaps/en_SG (LC_TIME): Fix time formats. + Patch by KH Teo <b3virq3b@gmail.com>. + 2011-05-09 Ulrich Drepper <drepper@gmail.com> [BZ #11487] diff --git a/libc/localedata/locales/en_SG b/libc/localedata/locales/en_SG index 0e9196c1f..71ae52b26 100644 --- a/libc/localedata/locales/en_SG +++ b/libc/localedata/locales/en_SG @@ -117,19 +117,20 @@ mon "<U004A><U0061><U006E><U0075><U0061><U0072><U0079>";"<U0046><U0065>< am_pm "<U0041><U004D>";"<U0050><U004D>" % % Appropriate date and time representation -% %A %d,%B,%Y %I:%M:%S %Z -d_t_fmt "<U0025><U0041><U0020><U0025><U0064><U002C><U0025><U0042><U002C><U0025><U0059><U0020><U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053><U0020><U0025><U0070><U0020><U0025><U005A>" +% %a %d %b %Y %r +d_t_fmt "<U0025><U0061><U0020><U0025><U0064><U0020><U0025><U0062><U0020><U0025><U0059><U0020><U0025><U0072>" % % Appropriate date representation -% %A %d,%B,%Y -d_fmt "<U0025><U0041><U0020><U0025><U0064><U002C><U0025><U0042><U002C><U0025><U0059>" +% %d/%m/%Y +d_fmt "<U0025><U0064><U002F><U0025><U006D><U002F><U0025><U0059>" % % Appropriate time representation -% %I:%M:%S %Z -t_fmt "<U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053><U0020><U0020><U0025><U005A>" +% %T +t_fmt "<U0025><U0054>" % % Appropriate 12 h time representation (%r) -t_fmt_ampm "<U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053><U0020><U0025><U0070><U0020><U0025><U005A>" +% %I:%M:%S %p +t_fmt_ampm "<U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053><U0020><U0025><U0070>" % END LC_TIME diff --git a/libc/login/Makefile b/libc/login/Makefile index 7877fd90f..705a451e6 100644 --- a/libc/login/Makefile +++ b/libc/login/Makefile @@ -34,6 +34,7 @@ CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"' others = pt_chown others-$(OPTION_EGLIBC_UTMP) += utmpdump +others-pie = pt_chown install-others-programs = $(inst_libexecdir)/pt_chown distribute := utmp-private.h utmp-equal.h pty-private.h @@ -71,9 +72,6 @@ CFLAGS-pt_chown.c = $(pt_chown-cflags) LDLIBS-pt_chown = $(libcap) ifeq (yesyes,$(have-fpie)$(build-shared)) LDFLAGS-pt_chown = -Wl,-z,now - -$(objpfx)pt_chown: $(objpfx)pt_chown.o - $(+link-pie) endif # pt_chown needs to be setuid root. diff --git a/libc/nscd/Makefile b/libc/nscd/Makefile index 15c3c7b9f..9e1821546 100644 --- a/libc/nscd/Makefile +++ b/libc/nscd/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1998,2000,2002-2009 Free Software Foundation, Inc. +# Copyright (C) 1998,2000,2002-2009,2011 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -45,9 +45,8 @@ nscd-modules += nis_hash endif ifeq ($(have-thread-library),yes) -ifneq (yesyes,$(have-fpie)$(build-shared)) others-$(OPTION_EGLIBC_INET) += nscd -endif +others-pie += nscd install-sbin-$(OPTION_EGLIBC_INET) += nscd extra-objs-$(OPTION_EGLIBC_INET) += $(nscd-modules:=.o) @@ -133,10 +132,7 @@ CFLAGS-res_hconf.c += $(nscd-cflags) CFLAGS-nis_hash.c += $(nscd-cflags) ifeq (yesyes,$(have-fpie)$(build-shared)) -relro-LDFLAGS += -Wl,-z,now - -$(objpfx)nscd: $(addprefix $(objpfx),$(nscd-modules:=.o)) - $(+link-pie) +LDFLAGS-nscd = -Wl,-z,now endif # This makes sure -DNOT_IN_libc is passed for all these modules. diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index 3c188c951..e9d0ab18f 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991,93,1995-1998,2001,02,2009 Free Software Foundation, Inc. +/* Copyright (C) 1991,1993,1995-1998,2001,2002,2009,2011 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -37,7 +38,7 @@ #endif /* Exported variable to locate abort message in core files etc. */ -char *__abort_msg __attribute__ ((nocommon)); +struct abort_msg_s *__abort_msg __attribute__ ((nocommon)); libc_hidden_def (__abort_msg) /* We must avoid to run in circles. Therefore we remember how far we diff --git a/libc/sysdeps/generic/elf/backtracesymsfd.c b/libc/sysdeps/generic/elf/backtracesymsfd.c index f0ab71587..c38ddbf18 100644 --- a/libc/sysdeps/generic/elf/backtracesymsfd.c +++ b/libc/sysdeps/generic/elf/backtracesymsfd.c @@ -1,5 +1,5 @@ /* Write formatted list with names for addresses in backtrace to a file. - Copyright (C) 1998,2000,2003,2005,2009 Free Software Foundation, Inc. + Copyright (C) 1998,2000,2003,2005,2009,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -28,7 +28,7 @@ #if __ELF_NATIVE_CLASS == 32 # define WORD_WIDTH 8 #else -/* We assyme 64bits. */ +/* We assume 64bits. */ # define WORD_WIDTH 16 #endif @@ -45,6 +45,7 @@ __backtrace_symbols_fd (array, size, fd) for (cnt = 0; cnt < size; ++cnt) { char buf[WORD_WIDTH]; + char buf2[WORD_WIDTH]; Dl_info info; struct link_map *map; size_t last = 0; @@ -59,7 +60,6 @@ __backtrace_symbols_fd (array, size, fd) if (info.dli_sname != NULL || map->l_addr != 0) { - char buf2[WORD_WIDTH]; size_t diff; iov[last].iov_base = (void *) "("; diff --git a/libc/sysdeps/ia64/backtrace.c b/libc/sysdeps/ia64/backtrace.c index 5cefb86ae..d4ff29102 100644 --- a/libc/sysdeps/ia64/backtrace.c +++ b/libc/sysdeps/ia64/backtrace.c @@ -1,5 +1,5 @@ /* Return backtrace of current program state. - Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2003-2005, 2007, 2009, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -27,14 +27,26 @@ struct trace_arg { void **array; - int cnt, size; + _Unwind_Word cfa; + int cnt; + int size; }; #ifdef SHARED static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); +static _Unwind_Word (*unwind_getcfa) (struct _Unwind_Context *); static void *libgcc_handle; + +/* Dummy version in case libgcc_s does not contain the real code. */ +static _Unwind_Word +dummy_getcfa (struct _Unwind_Context *ctx __attribute__ ((unused))) +{ + return 0; +} + + static void init (void) { @@ -47,10 +59,13 @@ init (void) unwind_getip = __libc_dlsym (libgcc_handle, "_Unwind_GetIP"); if (unwind_getip == NULL) unwind_backtrace = NULL; + unwind_getcfa = (__libc_dlsym (libgcc_handle, "_Unwind_GetCFA") + ?: dummy_getcfa); } #else # define unwind_backtrace _Unwind_Backtrace # define unwind_getip _Unwind_GetIP +# define unwind_getcfa _Unwind_GetCFA #endif static _Unwind_Reason_Code @@ -65,8 +80,12 @@ backtrace_helper (struct _Unwind_Context *ctx, void *a) arg->array[arg->cnt] = (void *) unwind_getip (ctx); /* Check whether we make any progress. */ - if (arg->cnt > 0 && arg->array[arg->cnt - 1] == arg->array[arg->cnt]) + _Unwind_Word cfa = unwind_getcfa (ctx); + + if (arg->cnt > 0 && arg->array[arg->cnt - 1] == arg->array[arg->cnt] + && cfa == arg->cfa) return _URC_END_OF_STACK; + arg->cfa = cfa; } if (++arg->cnt == arg->size) return _URC_END_OF_STACK; @@ -78,7 +97,7 @@ __backtrace (array, size) void **array; int size; { - struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; + struct trace_arg arg = { .array = array, .cfa = 0, .size = size, .cnt = -1 }; #ifdef SHARED __libc_once_define (static, once); diff --git a/libc/sysdeps/posix/libc_fatal.c b/libc/sysdeps/posix/libc_fatal.c index 4f11c0fcb..f3847011f 100644 --- a/libc/sysdeps/posix/libc_fatal.c +++ b/libc/sysdeps/posix/libc_fatal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-1995,1997,2000,2004,2005,2009 +/* Copyright (C) 1993-1995,1997,2000,2004,2005,2009,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,6 +20,7 @@ #include <atomic.h> #include <errno.h> #include <fcntl.h> +#include <ldsodefs.h> #include <paths.h> #include <stdarg.h> #include <stdbool.h> @@ -125,18 +126,28 @@ __libc_message (int do_abort, const char *fmt, ...) if (TEMP_FAILURE_RETRY (__writev (fd, iov, nlist)) == total) written = true; - char *buf = do_abort ? malloc (total + 1) : NULL; - if (buf != NULL) + if (do_abort) { - char *wp = buf; - for (int cnt = 0; cnt < nlist; ++cnt) - wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len); - *wp = '\0'; - - /* We have to free the old buffer since the application might - catch the SIGABRT signal. */ - char *old = atomic_exchange_acq (&__abort_msg, buf); - free (old); + total = ((total + 1 + GLRO(dl_pagesize) - 1) + & ~(GLRO(dl_pagesize) - 1)); + struct abort_msg_s *buf = __mmap (NULL, total, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + if (buf != MAP_FAILED) + { + buf->size = total; + char *wp = buf->msg; + for (int cnt = 0; cnt < nlist; ++cnt) + wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len); + *wp = '\0'; + + /* We have to free the old buffer since the application might + catch the SIGABRT signal. */ + struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, + buf); + if (old != NULL) + __munmap (old, old->size); + } } } diff --git a/libc/sysdeps/pthread/aio_misc.c b/libc/sysdeps/pthread/aio_misc.c index c82acbbc2..ca3d1111e 100644 --- a/libc/sysdeps/pthread/aio_misc.c +++ b/libc/sysdeps/pthread/aio_misc.c @@ -1,5 +1,5 @@ /* Handle general operations. - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007, 2009 + Copyright (C) 1997-2001, 2003, 2004, 2006, 2007, 2009, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -26,6 +26,7 @@ #include <pthread.h> #include <stdlib.h> #include <unistd.h> +#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> #include <aio_misc.h> @@ -87,7 +88,7 @@ static int idle_thread_count; static struct aioinit optim = { 20, /* int aio_threads; Maximal number of threads. */ - 64, /* int aio_num; Number of expected simultanious requests. */ + 64, /* int aio_num; Number of expected simultaneous requests. */ 0, 0, 0, @@ -282,9 +283,10 @@ __aio_init (const struct aioinit *init) if (pool == NULL) { optim.aio_threads = init->aio_threads < 1 ? 1 : init->aio_threads; + assert (powerof2 (ENTRIES_PER_ROW)); optim.aio_num = (init->aio_num < ENTRIES_PER_ROW ? ENTRIES_PER_ROW - : init->aio_num & ~ENTRIES_PER_ROW); + : init->aio_num & ~(ENTRIES_PER_ROW - 1)); } if (init->aio_idle_time != 0) diff --git a/libc/sysdeps/unix/sysv/linux/libc_fatal.c b/libc/sysdeps/unix/sysv/linux/libc_fatal.c index 4206bb206..501433b11 100644 --- a/libc/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/libc/sysdeps/unix/sysv/linux/libc_fatal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-1995,1997,2000,2002-2005,2009 +/* Copyright (C) 1993-1995,1997,2000,2002-2005,2009,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,6 +20,7 @@ #include <atomic.h> #include <errno.h> #include <fcntl.h> +#include <ldsodefs.h> #include <paths.h> #include <stdarg.h> #include <stdbool.h> @@ -28,6 +29,7 @@ #include <string.h> #include <sysdep.h> #include <unistd.h> +#include <sys/mman.h> #include <sys/syslog.h> #include <execinfo.h> #include <gnu/option-groups.h> @@ -135,18 +137,28 @@ __libc_message (int do_abort, const char *fmt, ...) if (cnt == total) written = true; - char *buf = do_abort ? malloc (total + 1) : NULL; - if (buf != NULL) + if (do_abort) { - char *wp = buf; - for (int cnt = 0; cnt < nlist; ++cnt) - wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len); - *wp = '\0'; - - /* We have to free the old buffer since the application might - catch the SIGABRT signal. */ - char *old = atomic_exchange_acq (&__abort_msg, buf); - free (old); + total = ((total + 1 + GLRO(dl_pagesize) - 1) + & ~(GLRO(dl_pagesize) - 1)); + struct abort_msg_s *buf = __mmap (NULL, total, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + if (__builtin_expect (buf != MAP_FAILED, 1)) + { + buf->size = total; + char *wp = buf->msg; + for (int cnt = 0; cnt < nlist; ++cnt) + wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len); + *wp = '\0'; + + /* We have to free the old buffer since the application might + catch the SIGABRT signal. */ + struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, + buf); + if (old != NULL) + __munmap (old, old->size); + } } } |