]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
*** empty log message ***
authorThomas Tanner <tanner@gmx.de>
Thu, 14 Jan 1999 16:31:23 +0000 (16:31 +0000)
committerThomas Tanner <tanner@gmx.de>
Thu, 14 Jan 1999 16:31:23 +0000 (16:31 +0000)
ChangeLog
libltdl/ltdl.c
libltdl/ltdl.h
mdemo/Makefile.am

index 57f2e3f10b8b90c6724ff85860b06b18841b84d6..795f87da9d2bbec71d1943f60ec92ad6530793ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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>
 
index e2142695920ebc212f5c0b2230641eaa675db520..0e93215f61c294d055b773f8ef1bd7dc27415f5f 100644 (file)
@@ -65,10 +65,12 @@ static const char *invalid_handle_error = "invalid handle";
 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));
@@ -250,8 +252,13 @@ dl_sym (handle, symbol)
 
 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
@@ -354,7 +361,7 @@ shl_sym (handle, symbol)
 
 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
@@ -422,7 +429,7 @@ dld_sym (handle, symbol)
 
 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
@@ -486,7 +493,7 @@ wll_sym (handle, symbol)
 
 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
@@ -503,13 +510,15 @@ typedef struct lt_dlsymlists_t {
        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;
 }
 
@@ -530,8 +539,7 @@ presym_free_symlists ()
 static int
 presym_exit ()
 {
-       /* Don't reset preloaded_symbols here; adding/removing symbols
-           should be unrelated with init/exit */
+       presym_free_symlists();
        return 0;
 }
 
@@ -613,10 +621,6 @@ presym_sym (handle, symbol)
 {
        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)
@@ -629,7 +633,7 @@ presym_sym (handle, symbol)
 
 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
@@ -682,6 +686,8 @@ lt_dlpreopen (preloaded)
                return presym_add_symlist(preloaded);
        else {
                presym_free_symlists();
+               if (default_preloaded_symbols)
+                       return lt_dlpreopen(default_preloaded_symbols);
                return 0;
        }
 #else
@@ -690,6 +696,19 @@ lt_dlpreopen (preloaded)
 #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 ()
 {
@@ -831,9 +850,6 @@ find_library (handle, filename, have_dir, basename, search_path)
        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;
@@ -894,10 +910,6 @@ find_file (filename, basename, have_dir, search_path)
        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;
@@ -965,7 +977,7 @@ lt_dlopen (filename)
        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;
        
@@ -982,7 +994,7 @@ lt_dlopen (filename)
        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, '.');
@@ -1012,11 +1024,17 @@ lt_dlopen (filename)
                        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);
@@ -1079,11 +1097,14 @@ lt_dlopen (filename)
                        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);
@@ -1138,8 +1159,7 @@ lt_dlclose (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
@@ -1147,7 +1167,7 @@ lt_dlsym (handle, symbol)
        lt_dlhandle handle;
        const char *symbol;
 {
-       int     lensym, lenhand;
+       int     lensym;
        char    lsym[LT_SYMBOL_LENGTH];
        char    *sym;
        lt_ptr_t address;
@@ -1161,27 +1181,25 @@ lt_dlsym (handle, symbol)
                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" */
@@ -1193,14 +1211,12 @@ lt_dlsym (handle, 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;
@@ -1214,3 +1230,13 @@ lt_dlerror ()
        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;
+}
index 3bca1ce92e02818fc3997690bf642bbc9e0e9dfe..18ccbc8d9d1593c192b6f158b2cd84dcdac1227a 100644 (file)
@@ -76,11 +76,13 @@ typedef struct {
 __BEGIN_DECLS
 _LTDLL_EXTERN int lt_dlinit __P((void));
 _LTDLL_EXTERN int lt_dlpreopen __P((const lt_dlsymlist *preloaded));
+_LTDLL_EXTERN int lt_dlpreopen_default __P((const lt_dlsymlist *preloaded));
 _LTDLL_EXTERN int lt_dlexit __P((void));
 _LTDLL_EXTERN lt_dlhandle lt_dlopen __P((const char *filename));
 _LTDLL_EXTERN int lt_dlclose __P((lt_dlhandle handle));
 _LTDLL_EXTERN lt_ptr_t lt_dlsym __P((lt_dlhandle handle, const char *name));
 _LTDLL_EXTERN const char *lt_dlerror __P((void));
+_LTDLL_EXTERN const char *lt_dlsearchpath __P((const char *search_path));
 
 extern const lt_dlsymlist lt_preloaded_symbols[];
 
index 6d9875889cf005fc477aa08b954f96cdfd3423aa..14d63e117b7a64aae2a00d00b607ff6671f10511 100644 (file)
@@ -25,11 +25,15 @@ bin_PROGRAMS = mdemo mdemo.debug
 # Create a version of mdemo that does dlopen.
 mdemo_SOURCES = main.c
 mdemo_LDADD = ../libltdl/libltdlc.la
-mdemo_LDFLAGS = -dlopen foo1.la -dlopen libfoo2.la
+mdemo_LDFLAGS = -dlopen foo1.la -dlopen libfoo2.la \
+       -export-dynamic # FIXME: remove this when libtool and libltdl \
+                       # handle dependencies of modules
 mdemo_DEPENDENCIES = ../libltdl/libltdlc.la foo1.la libfoo2.la
 
 # Create an easier-to-debug version of mdemo.
 mdemo_debug_SOURCES = main.c
 mdemo_debug_LDADD = ../libltdl/libltdlc.la
-mdemo_debug_LDFLAGS = -static -dlopen foo1.la -dlopen libfoo2.la
+mdemo_debug_LDFLAGS = -static -dlopen foo1.la -dlopen libfoo2.la \
+       -export-dynamic # FIXME: remove this when libtool and libltdl \
+                       # handle dependencies of modules
 mdemo_debug_DEPENDENCIES = ../libltdl/libltdlc.la foo1.la libfoo2.la