]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-03-18 Ulrich Drepper <drepper@redhat.com>
authorRoland McGrath <roland@gnu.org>
Wed, 6 Apr 2005 02:50:11 +0000 (02:50 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 6 Apr 2005 02:50:11 +0000 (02:50 +0000)
[BZ #821]
* include/link.h (struct link_map): Remove l_opencount.  Add l_removed.
Change type of l_idx to int.
* elf/dl-close.c: Basically rewrite.  Do not use l_opencount to
determine whether a DSO has to be unloaded.  Instead compute this
in this function.
* elf/dl-deps.c: No need to manipulate l_opencount anymore.
* elf/dl-lookup.c: Likewise.
* elf/rtld.c: Likewise
* elf/dl-open.c: Likewise.  Use l_init_called to determine whether
object was just loaded.
* elf/dl-fini.c: Bump l_direct_opencount instead of l_opencount.
* elf/dl-load.c (_dl_map_object_from_fd): Do not recognize DSO which
is about to be unloaded as a match.
(_dl_map_object): Likewise.
* elf/do-lookup.h (do_lookup_x): Do not look into DSO which is about
to be unloaded.
* elf/circleload1.c: Don't use l_opencount anymore.
* elf/neededtest.c: Likewise.
* elf/neededtest2.c: Likewise.
* elf/neededtest3.c: Likewise.
* elf/neededtest4.c: Likewise.
* elf/unload.c: Likewise.
* elf/unload2.c: Likewise.
* elf/loadtest.c: Likewise.

12 files changed:
elf/circleload1.c
elf/dl-deps.c
elf/dl-load.c
elf/do-lookup.h
elf/loadtest.c
elf/neededtest.c
elf/neededtest2.c
elf/neededtest3.c
elf/neededtest4.c
elf/unload.c
elf/unload2.c
include/link.h

index 7ac101a799c340d8ce6c7b8794fe4f67c9b2172d..1fb885cf507019a09ce83243a64dc17b7a1e7dac 100644 (file)
@@ -27,7 +27,7 @@ check_loaded_objects (const char **loaded)
   for (lm = _r_debug.r_map; lm; lm = lm->l_next)
     {
       if (lm->l_name && lm->l_name[0])
-       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_opencount);
+       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
       if (lm->l_type == lt_loaded && lm->l_name)
        {
          int match = 0;
index a1c16d7310606dc19f051aadec3b9b703a8e3e14..acc8fc3a07200b9fee169bd0f429e9be3ebd7d3a 100644 (file)
@@ -566,8 +566,6 @@ Filters not supported with LD_TRACE_PRELINKING"));
          {
            /* A direct or transitive dependency is also on the list
               of relocation dependencies.  Remove the latter.  */
-           --map->l_reldeps[i]->l_opencount;
-
            for (j = i + 1; j < map->l_reldepsact; ++j)
              map->l_reldeps[j - 1] = map->l_reldeps[j];
 
index 17b90ae8b865e83363ee4df6b61d65425c68fb0d..85e03720c6e81b0b27dbeac82c36f1d5960681aa 100644 (file)
@@ -841,7 +841,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 
   /* Look again to see if the real name matched another already loaded.  */
   for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
-    if (l->l_ino == st.st_ino && l->l_dev == st.st_dev)
+    if (l->l_removed == 0 && l->l_ino == st.st_ino && l->l_dev == st.st_dev)
       {
        /* The object is already loaded.
           Just bump its reference count and return it.  */
@@ -1826,7 +1826,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
       /* If the requested name matches the soname of a loaded object,
         use that object.  Elide this check for names that have not
         yet been opened.  */
-      if (__builtin_expect (l->l_faked, 0) != 0)
+      if (__builtin_expect (l->l_faked, 0) != 0
+         || __builtin_expect (l->l_removed, 0) != 0)
        continue;
       if (!_dl_name_match_p (name, l))
        {
index e57d9df26dae85f7bb35ee9af82865fc31e3a5f3..88de3fe26f286ceb48bd6630d575ebede5d7edbc 100644 (file)
@@ -52,6 +52,10 @@ do_lookup_x (const char *undef_name, unsigned long int hash,
       if ((type_class & ELF_RTYPE_CLASS_COPY) && map->l_type == lt_executable)
        continue;
 
+      /* Do not look into objects which are going to be removed.  */
+      if (map->l_removed)
+       continue;
+
       /* Print some debugging info if wanted.  */
       if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0))
        _dl_debug_printf ("symbol=%s;  lookup in file=%s\n",
index 6b8f4bb7d084d41c77d2710141d6345bf01b070b..ee106ea1523e83f45907de2423422150dd17c4fb 100644 (file)
@@ -73,8 +73,8 @@ static const struct
 #define OUT \
   for (map = _r_debug.r_map; map != NULL; map = map->l_next)                 \
     if (map->l_type == lt_loaded)                                            \
-      printf ("name = \"%s\", opencount = %d\n",                             \
-             map->l_name, (int) map->l_opencount);                           \
+      printf ("name = \"%s\", direct_opencount = %d\n",                              \
+             map->l_name, (int) map->l_direct_opencount);                    \
   fflush (stdout)
 
 
@@ -183,8 +183,8 @@ main (int argc, char *argv[])
   for (map = _r_debug.r_map; map != NULL; map = map->l_next)
     if (map->l_type == lt_loaded)
       {
-       printf ("name = \"%s\", opencount = %d\n",
-               map->l_name, (int) map->l_opencount);
+       printf ("name = \"%s\", direct_opencount = %d\n",
+               map->l_name, (int) map->l_direct_opencount);
        result = 1;
       }
 
index e6e99bfc6db5ae92b58b4f27e08d4222d5af666a..6c7a952066ca70e431b5ee7105af39c1ed47aeb2 100644 (file)
@@ -27,7 +27,7 @@ check_loaded_objects (const char **loaded)
   for (lm = _r_debug.r_map; lm; lm = lm->l_next)
     {
       if (lm->l_name && lm->l_name[0])
-       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_opencount);
+       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
       if (lm->l_type == lt_loaded && lm->l_name)
        {
          int match = 0;
index cf111bc303d94a3de4f21a3745423dc6f9b99009..b682f15792bd72a2816999f83d2e8466d1bca923 100644 (file)
@@ -27,7 +27,7 @@ check_loaded_objects (const char **loaded)
   for (lm = _r_debug.r_map; lm; lm = lm->l_next)
     {
       if (lm->l_name && lm->l_name[0])
-       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_opencount);
+       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
       if (lm->l_type == lt_loaded && lm->l_name)
        {
          int match = 0;
index 38b3c6c6b718418c605c80dfea84b284525a453d..ea1dcf47949a6ddb82c2e9bc11c87d455922b3e4 100644 (file)
@@ -27,7 +27,7 @@ check_loaded_objects (const char **loaded)
   for (lm = _r_debug.r_map; lm; lm = lm->l_next)
     {
       if (lm->l_name && lm->l_name[0])
-       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_opencount);
+       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
       if (lm->l_type == lt_loaded && lm->l_name)
        {
          int match = 0;
index 04ab10e4c9b48db0264a604de9fc7d2f6693e597..7514bed4990a9761f559d065670dd8ce9d70e4da 100644 (file)
@@ -27,7 +27,7 @@ check_loaded_objects (const char **loaded)
   for (lm = _r_debug.r_map; lm; lm = lm->l_next)
     {
       if (lm->l_name && lm->l_name[0])
-       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_opencount);
+       printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
       if (lm->l_type == lt_loaded && lm->l_name)
        {
          int match = 0;
index 4fd82b7e3a220931a6e8442c2e6988eec74cb894..ffb33482c0d6b2e56076d04313a3d77a144c87dd 100644 (file)
@@ -12,8 +12,8 @@
 #define OUT \
   for (map = _r_debug.r_map; map != NULL; map = map->l_next)                 \
     if (map->l_type == lt_loaded)                                            \
-      printf ("name = \"%s\", opencount = %d\n",                             \
-             map->l_name, (int) map->l_opencount);                           \
+      printf ("name = \"%s\", direct_opencount = %d\n",                              \
+             map->l_name, (int) map->l_direct_opencount);                    \
   fflush (stdout)
 
 typedef struct
index 7a380534338bca77bf6ac7c253164e45fd2b8b8b..e14c6f06afdcf286c087e2009607bc6d3a3f6450 100644 (file)
@@ -9,8 +9,8 @@
 #define OUT \
   for (map = _r_debug.r_map; map != NULL; map = map->l_next)                 \
     if (map->l_type == lt_loaded)                                            \
-      printf ("name = \"%s\", opencount = %d\n",                             \
-             map->l_name, (int) map->l_opencount);                           \
+      printf ("name = \"%s\", direct_opencount = %d\n",                              \
+             map->l_name, (int) map->l_direct_opencount);                    \
   fflush (stdout)
 
 int
index 3078b72a87c7bc0be5bd11a73c38deb20f1288ee..7c801e94ee5733768a9eb4ee36c2f93f27271687 100644 (file)
@@ -177,7 +177,7 @@ struct link_map
     Elf_Symndx l_nbuckets;
     const Elf_Symndx *l_buckets, *l_chain;
 
-    unsigned int l_opencount;  /* Counter for direct and indirect usage.  */
+    unsigned int l_dummy_opencount;  /* Used to be l_opencount, now unused.  */
     unsigned int l_direct_opencount; /* Reference count for dlopen/dlclose.  */
     enum                       /* Where this object came from.  */
       {
@@ -199,6 +199,8 @@ struct link_map
                                       should be called on this link map
                                       when relocation finishes.  */
     unsigned int l_used:1;     /* Nonzero if the DSO is used.  */
+    unsigned int l_removed:1;  /* Nozero if the object cannot be used anymore
+                                  since it is removed.  */
     /* Array with version names.  */
     unsigned int l_nversions;
     struct r_found_version *l_versions;
@@ -255,7 +257,7 @@ struct link_map
     ElfW(Word) l_flags;
 
     /* Temporarily used in `dl_close'.  */
-    unsigned int l_idx;
+    int l_idx;
 
     struct link_map_machine l_mach;