[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
make libltdl work on platforms without loader
From: |
Ralf Wildenhues |
Subject: |
make libltdl work on platforms without loader |
Date: |
Sun, 28 Nov 2004 13:21:45 +0100 |
User-agent: |
Mutt/1.5.6+20040722i |
Dearest libtool-patches audience,
I'd very much like the approval of the following patches, which
finally make libltdl work again on static platforms! :-)
OK to apply to HEAD and branch-2-0?
Cheers,
Ralf
patch #1:
This cute typo (leftover from some incomplete renaming?) was almost
responsible for physical damage.
* config/ltmain.m4sh (func_mode_link): $dlsymsobj is really
$symfileobj, bug exposed only in the static preloading case
(symfileobj is created, but not linked into output).
Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 ltmain.m4sh
--- config/ltmain.m4sh 22 Nov 2004 22:28:48 -0000 1.1.2.21
+++ config/ltmain.m4sh 28 Nov 2004 09:48:18 -0000
@@ -6182,7 +6182,7 @@
build_libtool_libs=no
else
oldobjs="$old_deplibs $non_pic_objects"
- if test "$preload" = yes && test -f "$dlsymsobj"; then
+ if test "$preload" = yes && test -f "$symfileobj"; then
oldobjs="$oldobjs $symfileobj"
fi
fi
patch #2:
On a platform with only the preopen loader, the symfileobj for
libltdl*.la will not be created, simply because there is no lalib
to be dlpreopened. However, the ltdl code requires the symbol
lt_$(LIBLTDL)_LTX_preloaded_symbols to be present (program link time
failure). I guess the proper fix would probably adding a switch to
`libtool --mode=link' which would force output of the symfileobj.
The quickest solution I could come up with was just adding a dummy
loader in case there is no other loader. We can still do it right
sometime later.
I hate bootstrapping corner cases.
* libltdl/loaders/dummy.c: new file, dummy loader that doesn't
do anything and always fails.
* m4/ltdl.m4 (LT_LIB_DLLOAD), libltdl/loaders/Makefile.am:
In case of no other loader, use the dummy loader to force
symfileobj creation.
Index: m4/ltdl.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/ltdl.m4,v
retrieving revision 1.20.2.2
diff -u -r1.20.2.2 ltdl.m4
--- m4/ltdl.m4 10 Nov 2004 13:20:52 -0000 1.20.2.2
+++ m4/ltdl.m4 28 Nov 2004 09:48:27 -0000
@@ -413,7 +413,8 @@
[AC_DEFINE([HAVE_LIBDL], [1],
[Define if you have the libdl library or equivalent.])
LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes"
- LT_DLLOADERS="$LT_DLLOADERS dlopen.la"])])])
+ LT_DLLOADERS="$LT_DLLOADERS dlopen.la"],
+ LT_DLLOADERS="$LT_DLLOADERS dummy.la")])])
if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen"
= xyes
then
lt_save_LIBS="$LIBS"
Index: libltdl/loaders/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/Makefile.am,v
retrieving revision 1.3.2.3
diff -u -r1.3.2.3 Makefile.am
--- libltdl/loaders/Makefile.am 23 Nov 2004 12:47:19 -0000 1.3.2.3
+++ libltdl/loaders/Makefile.am 28 Nov 2004 09:48:20 -0000
@@ -37,7 +37,7 @@
## use convenience libraries for that purpose:
noinst_LTLIBRARIES = $(LT_DLLOADERS)
EXTRA_LTLIBRARIES = dlopen.la dld_link.la dyld.la load_add_on.la \
- loadlibrary.la shl_load.la
+ loadlibrary.la shl_load.la dummy.la
## Build loaders (other than preopen) as modules:
dlopen_la_LIBADD = ../libdlloader.la $(LIBADD_DLOPEN)
@@ -52,7 +52,7 @@
## libtoolize --ltdl can find them later:
ltdldatadir = $(pkgdatadir)/libltdl/loaders
ltdldata_DATA = Makefile.am dld_link.c dlopen.c dyld.c \
- load_add_on.c loadlibrary.c shl_load.c
+ load_add_on.c loadlibrary.c shl_load.c dummy.c
../libdlloader.la:
cd ..; $(MAKE) $(AM_MAKEFLAGS) libdlloader.la
--- /dev/null 2004-09-14 22:52:52.000000000 +0200
+++ libltdl/loaders/dummy.c 2004-11-28 10:01:11.000000000 +0100
@@ -0,0 +1,114 @@
+/* dummy.c -- the dummy loader that always fails
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#include "lt__private.h"
+
+/* Use the preprocessor to rename non-static symbols to avoid namespace
+ collisions when the loader code is statically linked into libltdl.
+ Use the "<module_name>_LTX_" prefix so that the symbol addresses can
+ be fetched from the preloaded symbol list by lt_dlsym(): */
+#define get_vtable dummy_LTX_get_vtable
+
+LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+
+
+/* Boilerplate code to set up the vtable for hooking this loader into
+ libltdl's loader list: */
+static lt_module vm_open (lt_user_data loader_data, const char *filename);
+static int vm_close (lt_user_data loader_data, lt_module module);
+static void * vm_sym (lt_user_data loader_data, lt_module module,
+ const char *symbolname);
+
+/* Return the vtable for this loader, only the name and sym_prefix
+ attributes (plus the virtual function implementations, obviously)
+ change between loaders. */
+lt_dlvtable *
+get_vtable (lt_user_data loader_data)
+{
+ static lt_dlvtable *vtable = 0;
+
+ if (!vtable)
+ {
+ vtable = lt__zalloc (sizeof *vtable);
+ }
+
+ if (vtable && !vtable->name)
+ {
+ vtable->name = "lt_dummy";
+#if defined(DLSYM_USCORE)
+ vtable->sym_prefix = "_";
+#endif
+ vtable->module_open = vm_open;
+ vtable->module_close = vm_close;
+ vtable->find_sym = vm_sym;
+ vtable->dlloader_data = loader_data;
+ vtable->priority = LT_DLLOADER_PREPEND;
+ }
+
+ if (vtable && (vtable->dlloader_data != loader_data))
+ {
+ LT__SETERROR (INIT_LOADER);
+ return 0;
+ }
+
+ return vtable;
+}
+
+
+
+/* --- IMPLEMENTATION --- */
+
+
+/* A function called through the vtable to open a module with this
+ loader. Returns an opaque representation of the newly opened
+ module for processing with this loader's other vtable functions. */
+static lt_module
+vm_open (lt_user_data loader_data, const char *filename)
+{
+ LT__SETERROR (CANNOT_OPEN);
+ return NULL;
+}
+
+
+/* A function called through the vtable when a particular module
+ should be unloaded. */
+static int
+vm_close (lt_user_data loader_data, lt_module module)
+{
+ return 0;
+}
+
+
+/* A function called through the vtable to get the address of
+ a symbol loaded from a particular module. */
+static void *
+vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+{
+ LT__SETERROR (SYMBOL_NOT_FOUND);
+ return NULL;
+}
- make libltdl work on platforms without loader,
Ralf Wildenhues <=