]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
From Ahmed Masud <masud@googgun.com>
authorGary V. Vaughan <gary@gnu.org>
Fri, 6 Apr 2001 00:29:14 +0000 (00:29 +0000)
committerGary V. Vaughan <gary@gnu.org>
Fri, 6 Apr 2001 00:29:14 +0000 (00:29 +0000)
* libltdl/ltdl.c (sys_shl_open):  Return a NULL module handle
for self opening.
(sys_shl_close):  Be careful not to close a NULL module handle.
(sys_shl_sym):  Allow shl_findsym() to open NULL modules, but
discard the modified module address it returns.

ChangeLog
libltdl/ltdl.c

index 5804e4d723abc802f000072f679b6df8a2420c7b..a3bae8933d56c952c25f84b6c6a424cf5d213547 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2001-04-05  Gary V. Vaughan  <gvv@techie.com>
 
+       From Ahmed Masud <masud@googgun.com>
+       * libltdl/ltdl.c (sys_shl_open):  Return a NULL module handle
+       for self opening.
+       (sys_shl_close):  Be careful not to close a NULL module handle.
+       (sys_shl_sym):  Allow shl_findsym() to open NULL modules, but 
+       discard the modified module address it returns.
+
        * libltdl/ltdl.c (lt_dlopen):  When reading the .la file,
        reallocate the line buffer size if the line overflows the
        original buffer.
index 0855af3a4031d30ac98096576f7c4a47bbe898f4..b7417ceb5cae09403a2f7e05b90278170f357d25 100644 (file)
@@ -689,11 +689,22 @@ sys_shl_open (loader_data, filename)
 {
   lt_module module = shl_load (filename, LT_BIND_FLAGS, 0L);
 
-  if (!module)
+  if (!filename)
     {
-      MUTEX_SETERROR (LT_DLSTRERROR (CANNOT_OPEN));
+      /* A NULL handle is used to get symbols from self and everything
+         else already loaded that was exported with -E compiler flag.  */
+      module = (lt_module) 0;
     }
+  else
+    {
+      module = shl_load (filename, LT_BIND_FLAGS, 0L);
 
+      if (!module)
+       {
+         MUTEX_SETERROR (LT_DLSTRERROR (CANNOT_OPEN));
+       }
+    }
+  
   return module;
 }
 
@@ -704,7 +715,7 @@ sys_shl_close (loader_data, module)
 {
   int errors = 0;
 
-  if (shl_unload ((shl_t) (module)) != 0)
+  if (module && (shl_unload ((shl_t) (module)) != 0))
     {
       MUTEX_SETERROR (LT_DLSTRERROR (CANNOT_CLOSE));
       ++errors;
@@ -719,20 +730,25 @@ sys_shl_sym (loader_data, module, symbol)
      lt_module module;
      const char *symbol;
 {
-  lt_ptr address;
+  int    is_module_self = (module == (lt_module) 0);
+  lt_ptr address        = 0;
 
-  if (module && shl_findsym ((shl_t*) &module,
-                            symbol, TYPE_UNDEFINED, &address) == 0)
+  /* shl_findsym considers zero valued MODULE as an indicator to saerch
+     for a symbol among all loaded (and exported) symbols including those
+     in the main executable.  However, it sets MODULE to a valid module
+     address which breaks the semantics of libltdl's module management.  */
+  if (shl_findsym ((shl_t*) &module, symbol, TYPE_UNDEFINED, &address) == 0)
     {
-      if (address)
+      if (!address)
        {
-         return address;
+         MUTEX_SETERROR (LT_DLSTRERROR (SYMBOL_NOT_FOUND));
        }
-
-      MUTEX_SETERROR (LT_DLSTRERROR (SYMBOL_NOT_FOUND));
     }
+  
+  if (is_module_self)
+    module = (lt_module) 0;
 
-  return 0;
+  return address;
 }
 
 static struct lt_user_dlloader sys_shl = {
@@ -2048,6 +2064,7 @@ lt_dlopen (filename)
       char     *dlname = 0, *old_name = 0;
       char     *libdir = 0, *deplibs = 0;
       char     *line;
+      size_t   line_len;
       int      error = 0;
 
       /* if we can't find the installed flag, it is probably an