Let's give this another go. I've included a patch against master this
time.

For a reminder, the problem is that libltdl mangles library names for
the preload table, but libtool does not, resulting it being impossible
to look up things.

Also, some programs expect the library names in the preload table to be
unmangled so we need to change libltdl to stop doing that.

Rgds
-- 
Pierre Ossman            OpenSource-based Thin Client Technology
System Developer         Telephone: +46-13-21 46 00
Cendio AB                Web: http://www.cendio.com
From 5f136168282724689f8da99d45fd0324e85af130 Mon Sep 17 00:00:00 2001
From: Pierre Ossman <oss...@ossman.lkpg.cendio.se>
Date: Mon, 15 Feb 2010 10:43:14 +0100
Subject: [PATCH] Make libltdl stop mangling preloaded names.

Store the original name for lookup in the preload table as that is what
libtool puts in there, not the mangled version libltdl was previously
using.

Signed-off-by: Pierre Ossman <oss...@cendio.se>
---
 ChangeLog      |    7 +++++++
 libltdl/ltdl.c |   19 +++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f4b4a3f..76c2b29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-02-15  Pierre Ossman <oss...@cendio.se>
+
+	Make libltdl stop mangling preloaded names.
+	* libltdl/ltdl.c: Store the original name for lookup in the
+	preload table as that is what libtool puts in there, not the
+	mangled version libltdl was previously using.
+
 2010-01-31  Ralf Wildenhues  <ralf.wildenh...@gmx.de>
 
 	Use --email with gendocs.sh.
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
index 1fe272f..b7fc7c6 100644
--- a/libltdl/ltdl.c
+++ b/libltdl/ltdl.c
@@ -1231,19 +1231,22 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext,
       ext = base_name + LT_STRLEN (base_name);
     }
 
-  /* extract the module name from the file name */
+  /* extract the module and archive name from the file name */
   name = MALLOC (char, ext - base_name + 1);
-  if (!name)
+  archive_name = MALLOC (char, ext - base_name + LT_STRLEN (libext) + 2);
+  if (!name || !archive_name)
     {
       ++errors;
       goto cleanup;
     }
 
-  /* canonicalize the module name */
+  /* canonicalize the module name and generate the archive name */
   {
     int i;
     for (i = 0; i < ext - base_name; ++i)
       {
+	archive_name[i] = base_name[i];
+
 	if (isalnum ((unsigned char)(base_name[i])))
 	  {
 	    name[i] = base_name[i];
@@ -1254,6 +1257,10 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext,
 	  }
       }
     name[ext - base_name] = LT_EOS_CHAR;
+
+    archive_name[ext - base_name] = '.';
+    archive_name[ext - base_name + 1] = LT_EOS_CHAR;
+    strcat(archive_name, libext);
   }
 
   /* Before trawling through the filesystem in search of a module,
@@ -1264,11 +1271,9 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext,
 
       if (vtable)
 	{
-	  /* name + "." + libext + NULL */
-	  archive_name = MALLOC (char, LT_STRLEN (name) + strlen (libext) + 2);
 	  *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle));
 
-	  if ((*phandle == NULL) || (archive_name == NULL))
+	  if (*phandle == NULL)
 	    {
 	      ++errors;
 	      goto cleanup;
@@ -1277,8 +1282,6 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext,
 
 	  /* Preloaded modules are always named according to their old
 	     archive name.  */
-	  sprintf (archive_name, "%s.%s", name, libext);
-
 	  if (tryall_dlopen (&newhandle, archive_name, advise, vtable) == 0)
 	    {
 	      goto register_handle;
-- 
1.6.2.5

Attachment: signature.asc
Description: PGP signature

Reply via email to