This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] BZ #14545: Always check dtv before freeing dtv[-1]
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 6 Sep 2012 12:43:20 -0700 (PDT)
- Subject: Re: [PATCH] BZ #14545: Always check dtv before freeing dtv[-1]
- References: <20120905202107.GA22504@intel.com>
> diff --git a/csu/libc-tls.c b/csu/libc-tls.c
> index b00a5cc..eb9c502 100644
> --- a/csu/libc-tls.c
> +++ b/csu/libc-tls.c
> @@ -65,6 +65,8 @@ size_t _dl_tls_static_size = 2048;
> size_t _dl_tls_static_used;
> /* Alignment requirement of the static TLS block. */
> size_t _dl_tls_static_align;
> +/* Initial dtv of the main thread, not allocated with normal malloc. */
> +void *_dl_initial_dtv = &static_dtv[1];
Make this 'void *const' so it stays in .rodata.
Better yet, make static_dtv a global _dl_static_dtv and put:
#ifndef SHARED
# define _dl_initial_dtv ((void *) &_dl_static_dtv[1])
#endif
into ldsodefs.h so we don't waste a data word on this at all.
Thanks,
Roland