Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 5 Feb 2002 08:38:38 +0000 (08:38 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 5 Feb 2002 08:38:38 +0000 (08:38 +0000)
* elf/dl-load.c (_dl_map_object_from_fd): Handle PT_TLS program
header entry.
* elf/dl-support.c: Define _dl_initimage_list and _dl_tls_module_cnt.

ChangeLog
elf/dl-load.c
elf/dl-support.c

index fed1b48..4fef0aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,11 @@
 2002-02-05  Ulrich Drepper  <drepper@redhat.com>
 
        * elf/rtld.c (dl_main): Read PT_TLS entry of the executable.
+       * elf/dl-load.c (_dl_map_object_from_fd): Handle PT_TLS program
+       header entry.
        * sysdeps/generic/ldsodefs.h (struct rtld_global): Add
        _dl_tls_module_cnt.
+       * elf/dl-support.c: Define _dl_initimage_list and _dl_tls_module_cnt.
 
 2002-02-04  Ulrich Drepper  <drepper@redhat.com>
 
index cf64ebc..a4e2421 100644 (file)
@@ -938,6 +938,30 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 #endif
          }
          break;
+
+#ifdef USE_TLS
+       case PT_TLS:
+         l->l_tls_blocksize = ph->p_memsz;
+         l->l_tls_initimage_size = ph->p_filesz;
+         /* Since we don't know the load address yet only store the
+            offset.  We will adjust it later.  */
+         l->l_tls_initimage = (void *) ph->p_offset;
+
+       /* This is the first element of the initialization image list.
+          It is created as a circular list so that we can easily
+          append to it.  */
+         if (GL(dl_initimage_list) == NULL)
+           GL(dl_initimage_list) = l->l_tls_nextimage = l;
+         else
+           {
+             l->l_tls_nextimage = GL(dl_initimage_list);
+             GL(dl_initimage_list) = l;
+           }
+
+         /* Assign the next available module ID.  */
+         l->l_tls_modid = ++GL(dl_tls_module_cnt);
+         break;
+#endif
        }
 
     /* Now process the load commands and map segments into memory.  */
@@ -1007,6 +1031,12 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
     l->l_map_start = c->mapstart + l->l_addr;
     l->l_map_end = l->l_map_start + maplength;
 
+#ifdef USE_TLS
+    /* Adjust the address of the TLS initialization image.  */
+    if (l->l_tls_initimage != NULL)
+      l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
+#endif
+
     while (c < &loadcmds[nloadcmds])
       {
        if (c->mapend > c->mapstart
index 9a9436e..10446dc 100644 (file)
@@ -137,6 +137,16 @@ int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
    At this time it is not anymore a problem to modify the tables.  */
 __libc_lock_define_initialized_recursive (, _dl_load_lock)
 
+#ifdef USE_TLS
+/* Beginning of the list of link maps for objects which contain
+   thread-local storage sections.  This will be traversed to
+   initialize new TLS blocks.  */
+struct link_map *_dl_initimage_list;
+
+/* Count the number of modules which define TLS data.  */
+size_t _dl_tls_module_cnt;
+#endif
+
 
 #ifdef HAVE_AUX_VECTOR
 int _dl_clktck;