commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd/libstore typed.c


From: Roland McGrath
Subject: hurd/libstore typed.c
Date: Mon, 04 Aug 2003 14:05:21 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd
Branch:         
Changes by:     Roland McGrath <address@hidden> 03/08/04 14:05:21

Modified files:
        libstore       : typed.c 

Log message:
        2003-08-04  Roland McGrath  <address@hidden>
        
        * typed.c (store_find_class): Use dlopen/dlclose on the names found by
        looking through the list instead of passing list elements directly to
        dlsym, which is not kosher.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/libstore/typed.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: hurd/libstore/typed.c
diff -u hurd/libstore/typed.c:1.7 hurd/libstore/typed.c:1.8
--- hurd/libstore/typed.c:1.7   Sat Aug  2 18:02:03 2003
+++ hurd/libstore/typed.c       Mon Aug  4 14:05:21 2003
@@ -1,6 +1,6 @@
 /* Support for opening `typed' stores
 
-   Copyright (C) 1997,98,2001,02,03 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,2001,2002,2003 Free Software Foundation, Inc.
    Written by Miles Bader <address@hidden>
 
    This file is part of the GNU Hurd.
@@ -64,32 +64,44 @@
      and examine each one's "store_std_classes" section.  */
 # pragma weak _r_debug
 # pragma weak dlsym
+# pragma weak dlopen
+# pragma weak dlclose
 # pragma weak dlerror
   if (dlsym)
     {
       struct link_map *map;
       for (map = _r_debug.r_map; map != 0; map = map->l_next)
        {
-         const struct store_class *const *start;
-         const struct store_class *const *stop;
-         start = dlsym (map, "__start_store_std_classes");
-         if (start == 0)
+         const struct store_class *const *start, *const *stop;
+
+         /* We cannot just use MAP directly because it may not have been
+            opened by dlopen such that its data structures are fully set
+            up for dlsym.  */
+         void *module = dlopen (map->l_name, RTLD_NOLOAD);
+         if (module == 0)
            {
-             (void) dlerror ();        /* Required to avoid a leak! */
+             (void) dlerror (); /* Required to avoid a leak! */
              continue;
            }
-         if (start == __start_store_std_classes)
-           continue;
-         stop = dlsym (map, "__stop_store_std_classes");
-         if (stop == 0)
+
+         start = dlsym (map, "__start_store_std_classes");
+         if (start == 0)
+           (void) dlerror ();  /* Required to avoid a leak! */
+         else if (start != __start_store_std_classes) /*  */
            {
-             (void) dlerror ();        /* Required to avoid a leak! */
-             continue;
+             stop = dlsym (map, "__stop_store_std_classes");
+             if (stop == 0)
+               (void) dlerror (); /* Required to avoid a leak! */
+             else
+               for (cl = start; cl < stop; ++cl)
+                 if (strlen ((*cl)->name) == (clname_end - name)
+                     && strncmp (name, (*cl)->name, (clname_end - name)) == 0)
+                   {
+                     dlclose (module);
+                     return *cl;
+                   }
            }
-         for (cl = start; cl < stop; ++cl)
-           if (strlen ((*cl)->name) == (clname_end - name)
-               && strncmp (name, (*cl)->name, (clname_end - name)) == 0)
-             return *cl;
+         dlclose (module);
        }
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]