+1999-01-14 Thomas Tanner <tanner@gmx.de>
+
+ * libltdl/ltdl.c: added variable symbol prefix, added user-defined
+ library search path (can be set using lt_dlsearchpath()),
+ added default_preloaded_symbols which are independent of
+ lt_dlinit/exit
+ * libltdl/ltdl.h: added lt_dlsearchpath() and
+ lt_dlpreopen_default()
+ * mdemo/Makefile.am: use -export-dynamic until libtool
+ and libltdl are able to handle module dependencies
+
1999-01-14 Gary V. Vaughan <garyv@oranda.demon.co.uk>
* ltconfig.in (PATH_SEPARATOR): new variable to hold valid $PATH
the libtool scripts,
build the libtool scripts in builddir, not srcdir
(unfortunately this breaks building when srcdir!=objdir,
- but it was just plain wrong - need's to be fixed),
+ but it was just plain wrong - needs to be fixed),
build and install libltdl.tar.gz,
copy acinclude.m4 instead of linking them, so that we
can 'make dist' in libltdl,
- fix configuring of subdirectories
- * configure.in: remove --enable-ltdl-install - libltdl is supposed
+ fixed configuring of subdirectories
+ * configure.in: removed --enable-ltdl-install - libltdl is supposed
to be installed by packages, not by libtool itself
* libtoolize.in: new flags --ltdl and --ltdl-tar to install libltdl
in packages (--ltdl doesn't work yet),
install only the necessary libtool scripts, not just all
files in pkgdatadir
- * mdemo/Makefile.am: remove rule for libltdl configuration
+ * mdemo/Makefile.am: removed the rule for libltdl configuration
1999-01-13 Alexandre Oliva <oliva@dcc.unicamp.br>
static const char *buffer_overflow_error = "internal buffer overflow";
static const char *shutdown_error = "library already shutdown";
-static const char *last_error;
+static const char *last_error = 0;
+static const char *usr_search_path = 0;
typedef struct lt_dltype_t {
struct lt_dltype_t *next;
+ const char *sym_prefix; /* prefix for symbols */
int (*mod_init) __P((void));
int (*mod_exit) __P((void));
int (*lib_open) __P((lt_dlhandle handle, const char *filename));
static
lt_dltype_t
-dl = { LT_DLTYPE_TOP, dl_init, dl_exit,
+#ifdef NEED_USCORE
+dl = { LT_DLTYPE_TOP, "_", dl_init, dl_exit,
+ dl_open, dl_close, dl_sym };
+#else
+dl = { LT_DLTYPE_TOP, 0, dl_init, dl_exit,
dl_open, dl_close, dl_sym };
+#endif
#undef LT_DLTYPE_TOP
#define LT_DLTYPE_TOP &dl
static
lt_dltype_t
-shl = { LT_DLTYPE_TOP, shl_init, shl_exit,
+shl = { LT_DLTYPE_TOP, 0, shl_init, shl_exit,
shl_open, shl_close, shl_sym };
#undef LT_DLTYPE_TOP
static
lt_dltype_t
-dld = { LT_DLTYPE_TOP, dld_init, dld_exit,
+dld = { LT_DLTYPE_TOP, 0, dld_init, dld_exit,
dld_open, dld_close, dld_sym };
#undef LT_DLTYPE_TOP
static
lt_dltype_t
-wll = { LT_DLTYPE_TOP, wll_init, wll_exit,
+wll = { LT_DLTYPE_TOP, 0, wll_init, wll_exit,
wll_open, wll_close, wll_sym };
#undef LT_DLTYPE_TOP
const lt_dlsymlist *syms;
} lt_dlsymlists_t;
+static const lt_dlsymlist *default_preloaded_symbols = 0;
static lt_dlsymlists_t *preloaded_symbols = 0;
static int
presym_init ()
{
- /* Don't nullify preloaded_symbols here, it would prevent one
- from calling lt_dlpreload_default() before lt_dlinit() */
+ preloaded_symbols = 0;
+ if (default_preloaded_symbols)
+ return lt_dlpreopen(default_preloaded_symbols);
return 0;
}
static int
presym_exit ()
{
- /* Don't reset preloaded_symbols here; adding/removing symbols
- should be unrelated with init/exit */
+ presym_free_symlists();
return 0;
}
{
lt_dlsymlist *syms = (lt_dlsymlist*)(handle->handle);
-#if NEED_USCORE
- /* lt_dlsym will have prepended a `_', but we don't need it */
- symbol++;
-#endif
syms++;
while (syms->address) {
if (syms->address && strcmp(syms->name, symbol) == 0)
static
lt_dltype_t
-presym = { LT_DLTYPE_TOP, presym_init, presym_exit,
+presym = { LT_DLTYPE_TOP, 0, presym_init, presym_exit,
presym_open, presym_close, presym_sym };
#undef LT_DLTYPE_TOP
return presym_add_symlist(preloaded);
else {
presym_free_symlists();
+ if (default_preloaded_symbols)
+ return lt_dlpreopen(default_preloaded_symbols);
return 0;
}
#else
#endif
}
+int
+lt_dlpreopen_default (preloaded)
+ const lt_dlsymlist *preloaded;
+{
+#if HAVE_DLPREOPEN
+ default_preloaded_symbols = preloaded;
+ return 0;
+#else
+ last_error = dlpreopen_not_supported_error;
+ return 1;
+#endif
+}
+
int
lt_dlexit ()
{
char dir[FILENAME_MAX], fullname[FILENAME_MAX];
const char *p, *next;
- if (tryall_dlopen(handle, filename) == 0)
- return 0;
-
if (have_dir || !search_path) {
last_error = file_not_found_error;
return 1;
const char *p, *next;
FILE *file;
- file = fopen(filename, READTEXT_MODE);
- if (file)
- return file;
-
if (have_dir || !search_path) {
last_error = file_not_found_error;
return 0;
char dir[FILENAME_MAX];
const char *basename, *ext, *search_path;
#ifdef LTDL_SHLIBPATH_VAR
- const char *alt_search_path;
+ const char *sys_search_path;
#endif
const char *saved_error = last_error;
dir[basename - filename] = '\0';
search_path = getenv("LTDL_LIBRARY_PATH"); /* get the search path */
#ifdef LTDL_SHLIBPATH_VAR
- alt_search_path = getenv(LTDL_SHLIBPATH_VAR);
+ sys_search_path = getenv(LTDL_SHLIBPATH_VAR);
#endif
/* check whether we open a libtool module (.la extension) */
ext = strrchr(basename, '.');
last_error = memory_error;
return 0;
}
- file = find_file(filename, *dir, basename, search_path);
+ file = fopen(filename, READTEXT_MODE);
+ if (!file)
+ file = find_file(filename, *dir, basename,
+ usr_search_path);
+ if (!file)
+ file = find_file(filename, *dir, basename,
+ search_path);
#ifdef LTDL_SHLIBPATH_VAR
if (!file)
file = find_file(filename, *dir, basename,
- alt_search_path);
+ sys_search_path);
#endif
if (!file) {
free(name);
last_error = memory_error;
return 0;
}
- if (find_library(&handle, filename, *dir,
- basename, search_path)
+ if (tryall_dlopen(&handle, filename)
+ && find_library(&handle, filename, *dir,
+ basename, usr_search_path)
+ && find_library(&handle, filename, *dir,
+ basename, search_path)
#ifdef LTDL_SHLIBPATH_VAR
&& find_library(&handle, filename, *dir,
- basename, alt_search_path)
+ basename, sys_search_path)
#endif
) {
free(handle);
#define LT_SYMBOL_LENGTH 256
#undef LT_SYMBOL_OVERHEAD
-/* This accounts for the initial underscore, the _LTX_ separator */
-/* and the string terminator */
+/* This accounts for the _LTX_ separator and the string terminator */
#define LT_SYMBOL_OVERHEAD 7
lt_ptr_t
lt_dlhandle handle;
const char *symbol;
{
- int lensym, lenhand;
+ int lensym;
char lsym[LT_SYMBOL_LENGTH];
char *sym;
lt_ptr_t address;
return 0;
}
lensym = strlen(symbol);
+ if (handle->type->sym_prefix)
+ lensym += strlen(handle->type->sym_prefix);
if (handle->name)
- lenhand = strlen(handle->name);
- else
- lenhand = 0;
- if (lensym + lenhand + LT_SYMBOL_OVERHEAD < LT_SYMBOL_LENGTH)
+ lensym += strlen(handle->name);
+ if (lensym + LT_SYMBOL_OVERHEAD < LT_SYMBOL_LENGTH)
sym = lsym;
else
- sym = malloc(lensym + lenhand + LT_SYMBOL_OVERHEAD);
+ sym = malloc(lensym + LT_SYMBOL_OVERHEAD);
if (!sym) {
last_error = buffer_overflow_error;
return 0;
}
if (handle->name) {
/* this is a libtool module */
-#ifdef NEED_USCORE
- /* prefix symbol with leading underscore */
- strcpy(sym, "_");
- strcat(sym, handle->name);
-#else
- strcpy(sym, handle->name);
-#endif
+ if (handle->type->sym_prefix) {
+ strcpy(sym, handle->type->sym_prefix);
+ strcat(sym, handle->name);
+ } else
+ strcpy(sym, handle->name);
strcat(sym, "_LTX_");
strcat(sym, symbol);
/* try "modulename_LTX_symbol" */
}
}
/* otherwise try "symbol" */
-#ifdef NEED_USCORE
- /* prefix symbol with leading underscore */
- strcpy(sym, "_");
- strcat(sym, symbol);
+ if (handle->type->sym_prefix) {
+ strcpy(sym, handle->type->sym_prefix);
+ strcat(sym, handle->name);
+ } else
+ strcpy(sym, handle->name);
address = handle->type->find_sym(handle, sym);
-#else
- address = handle->type->find_sym(handle, symbol);
-#endif
if (sym != lsym)
free(sym);
return address;
last_error = 0;
return error;
}
+
+const char *
+lt_dlsearchpath (search_path)
+ const char *search_path;
+{
+ const char *old_path = usr_search_path;
+
+ usr_search_path = search_path;
+ return old_path;
+}