This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
dtv array bounds
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 18 Feb 2005 10:39:34 +1030
- Subject: dtv array bounds
Mainline and glibc-2_3-branch fail this assert on at least i686 and
powerpc64, and probably all targets, when running dlfcn/tststatic,
dlfcn/tststatic2, and elf/tst-tls9-static. Which means init_static_tls
is trashing other global variables. Even if this is only on static
tls, glibc should not do this, thus this assert.
2005-02-18 Alan Modra <amodra@bigpond.net.au>
* elf/dl-reloc.c (_dl_nothread_init_static_tls): Assert that dtv
array index is within bounds.
Index: elf/dl-reloc.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-reloc.c,v
retrieving revision 1.97
diff -u -p -r1.97 dl-reloc.c
--- elf/dl-reloc.c 6 Jan 2005 22:40:26 -0000 1.97
+++ elf/dl-reloc.c 15 Feb 2005 03:17:22 -0000
@@ -115,6 +115,7 @@ cannot allocate memory in static TLS blo
void
_dl_nothread_init_static_tls (struct link_map *map)
{
+ dtv_t *dtv;
# if TLS_TCB_AT_TP
void *dest = (char *) THREAD_SELF - map->l_tls_offset;
# elif TLS_DTV_AT_TP
@@ -123,9 +124,12 @@ _dl_nothread_init_static_tls (struct lin
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
# endif
+ dtv = THREAD_DTV ();
+ assert (map->l_tls_modid <= dtv[-1].counter);
+
/* Fill in the DTV slot so that a later LD/GD access will find it. */
- THREAD_DTV ()[map->l_tls_modid].pointer.val = dest;
- THREAD_DTV ()[map->l_tls_modid].pointer.is_static = true;
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
/* Initialize the memory. */
memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
--
Alan Modra
IBM OzLabs - Linux Technology Centre