diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2011-05-15 12:22:50 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2011-05-15 12:22:50 +0000 |
commit | bc5b8c65ef17547cbab9141d66798bbb3cae9c2a (patch) | |
tree | c41d5e47bf1ebffbe2fc7461f0131e7a8b16dc49 /libc/sysdeps/unix | |
parent | c0ce886c9f6b0580924e4f21180602f5e72d6570 (diff) | |
download | eglibc2-bc5b8c65ef17547cbab9141d66798bbb3cae9c2a.tar.gz |
Merge changes between r13800 and r13831 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@13832 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/unix')
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/libc_fatal.c | 36 |
1 files changed, 24 insertions, 12 deletions
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); + } } } |