From 94cfa949e258b1fb0dee4915a11474110f77bc6c Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Wed, 13 Jan 1999 21:39:14 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 27 +++++- cdemo/configure.in | 2 +- demo/dlmain.c | 16 ++-- demo/foo.h | 2 + doc/libtool.texi | 12 +-- libltdl/Makefile.am | 10 +-- libltdl/ltdl.c | 53 +++++------ libltdl/ltdl.h | 8 +- ltconfig.in | 13 +-- ltmain.in | 43 +++++---- mail/deplibs.html | 213 ++++++++++++++++++++++++++++++++++++++++++++ mdemo/Makefile.am | 17 ++-- mdemo/main.c | 4 + 13 files changed, 337 insertions(+), 83 deletions(-) create mode 100644 mail/deplibs.html diff --git a/ChangeLog b/ChangeLog index ea7d2856..94b8d1b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +1999-01-13 Thomas Tanner + + * demo/dlmain.c, libltdl/ltdl.c, ltconfig.in, ltmain.in, + doc/libtool.texi: renamed dld_preloaded_symbols to + lt_preloaded_symbols, symbol lists are 'const' + * cdemo/configure.in: don't check for string.h + * demo/dlmain.c: renamed dld_symlist to lt_symlist, + preloaded symbols are 'const', use lt_ptr_t instead of void* + * demo/foo.h: define lt_ptr_t + * doc/libtool.texi: document lt_preloaded_symbols correctly + * libltdl/Makefile.am, mdemo/Makefile.am: renamed libtest to libltdlc + * libltdl/ltdl.c: fixed some minor typos, renamed dldpre to presym, + bugfix: search in search_path only if we have no directory + and a search_path, in lt_dlsym() check whether symbol != 0 + * libltdl/ltdl.h: removed lt_dlpreopen_default() + * ltconfig.in (dlpreopen): removed dld_preloaded_symbol_count + * ltmain.in: added help for -avoid-versioning, -export-symbols, + -module, add @SYMFILE@ if one of -export-dynamic, -dlopen or + -dlpreopen is used + * mail/deplibs.html: added Gordon Matzigkeit's inter-library + dependencies article + * mdemo/Makefile.am: removed -export-dynamic from LDFLAGS + (no longer necessary, since libtool defines lt_preloaded_symbols + when -dlopen is used), initialize with lt_preloaded_symbols + 1999-01-13 Alexandre Oliva * doc/libtool.texi (Test descriptions): cdemo-static works, thanks @@ -21,7 +46,7 @@ * ltconfig.in (NM): PATH search was not updated like in libtool.m4, in last Alexandre Oliva's change to it (sysv4*, ncr): pass all library dependencies - * ltmain.in (dependency_libs, -R): use `dep' instead of `arg' to + * ltmain.in (dependency_libs, -R): use `deplib' instead of `arg' to iterate, otherwise we'd overwrite `arg' (convenience, old_libs): if --disable-shared, convenience libraries are just old archives, as .lo's are of no use diff --git a/cdemo/configure.in b/cdemo/configure.in index df5a5056..97f3a3b4 100644 --- a/cdemo/configure.in +++ b/cdemo/configure.in @@ -6,7 +6,7 @@ AC_PROG_CC AC_EXEEXT AM_PROG_LIBTOOL -AC_CHECK_HEADERS(string.h math.h) +AC_CHECK_HEADERS(math.h) AC_CHECK_LIB(m, cos, LIBADD_M="-lm", LIBADD_M=) AC_SUBST(LIBADD_M) diff --git a/demo/dlmain.c b/demo/dlmain.c index aa0095d6..aab440c6 100644 --- a/demo/dlmain.c +++ b/demo/dlmain.c @@ -24,21 +24,21 @@ USA. */ #include #endif -struct dld_symlist +struct lt_symlist { - char *name; - void *address; + const char *name; + lt_ptr_t address; }; -extern struct dld_symlist dld_preloaded_symbols[]; +extern const struct lt_symlist lt_preloaded_symbols[]; #ifdef __CYGWIN32__ int win32_force_data_import_address __P((void)) { - struct dld_symlist *s; + const struct lt_symlist *s; - s = dld_preloaded_symbols; + s = lt_preloaded_symbols; while (s->name) { if (!strcmp ("nothing", s->name)) @@ -56,7 +56,7 @@ main (argc, argv) int argc; char **argv; { - struct dld_symlist *s; + const struct lt_symlist *s; int (*pfoo)() = 0; int (*phello)() = 0; int *pnothing = 0; @@ -69,7 +69,7 @@ main (argc, argv) #endif /* Look up the symbols we require for this demonstration. */ - s = dld_preloaded_symbols; + s = lt_preloaded_symbols; while (s->name) { if (s->address) { diff --git a/demo/foo.h b/demo/foo.h index d0c4265e..175c019c 100644 --- a/demo/foo.h +++ b/demo/foo.h @@ -51,8 +51,10 @@ USA. */ #undef __P #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__CYGWIN32__) || defined(__cplusplus) # define __P(protos) protos +# define lt_ptr_t void* #else # define __P(protos) () +# define lt_ptr_t char* #endif #ifdef __CYGWIN32__ diff --git a/doc/libtool.texi b/doc/libtool.texi index 00c16d09..45b09f88 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -1147,7 +1147,7 @@ no effect. @item -dlpreopen @var{file} Link @var{file} into the output program, and add its symbols to -@var{dld_preloaded_symbols} (@pxref{Dlpreopening}). +@var{lt_preloaded_symbols} (@pxref{Dlpreopening}). @item -export-dynamic Allow symbols from @var{output-file} to be resolved with @code{dlsym} @@ -2373,14 +2373,16 @@ In order to use this feature, you must declare the objects you want your application to dlopen by using the @samp{-dlopen} or @samp{-dlpreopen} flags when you link your program (@pxref{Link mode}). -@deftypefn {Structure} {typedef struct} dld_symbol @{ @w{char *@var{name};} @w{ptr_t @var{address};} @} +@deftypefn {Structure} {typedef struct} +lt_symbol @{ @w{const char *@var{name};} @w{lt_ptr_t @var{address};} @} + The @var{name} attribute is a zero-terminated character string of the symbol name, such as @code{"fprintf"}. The @var{address} attribute is a generic pointer to the appropriate object, such as @code{&fprintf}. @end deftypefn -@deftypevar {dld_symbol *} dld_preloaded_symbols -An array of @var{dld_symbol} structures, representing all the preloaded +@deftypevar {const lt_symbol *} lt_preloaded_symbols +An array of @var{lt_symbol} structures, representing all the preloaded symbols linked into the program. For each @samp{-dlpreloaded} file there is an element with the @var{name} of the file and a @var{address} of @code{0}, followed by all symbols exported from this file. @@ -2391,7 +2393,7 @@ Some compilers may allow identifiers which are not valid in ANSI C, such as dollar signs. Libtool only recognizes valid ANSI C symbols (an initial ASCII letter or underscore, followed by zero or more ASCII letters, digits, and underscores), so non-ANSI symbols will not appear -in @var{dld_preloaded_symbols}. +in @var{lt_preloaded_symbols}. @node Finding the dlname @section Finding the correct name to dlopen diff --git a/libltdl/Makefile.am b/libltdl/Makefile.am index bd39633c..c0a115cf 100644 --- a/libltdl/Makefile.am +++ b/libltdl/Makefile.am @@ -12,7 +12,7 @@ LTDL_FLAGS = noinst_HEADERS = ltdl.h endif -EXTRA_LTLIBRARIES = libltdl.la libtest.la +EXTRA_LTLIBRARIES = libltdl.la libltdlc.la lib_LTLIBRARIES = @LIBLIBS@ noinst_LTLIBRARIES = @NOINSTLIBS@ @@ -22,10 +22,10 @@ libltdl_la_LDFLAGS = $(LTDL_FLAGS) libltdl_la_LIBADD = $(LIBADD_DL) libltdl_la_DEPENDENCIES = libtool -libtest_la_SOURCES = $(libltdl_la_SOURCES) -libtest_la_LDFLAGS = -libtest_la_LIBADD = $(libltdl_la_LIBADD) -libltdl_la_DEPENDENCIES = libtool +libltdlc_la_SOURCES = $(libltdl_la_SOURCES) +libltdlc_la_LDFLAGS = +libltdlc_la_LIBADD = $(libltdl_la_LIBADD) +libltdlc_la_DEPENDENCIES = libtool libtool: ../libtool ./config.status --recheck diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index f764e8ec..e2142695 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -63,7 +63,7 @@ static const char *symbol_error = "symbol not found"; static const char *memory_error = "not enough memory"; static const char *invalid_handle_error = "invalid handle"; static const char *buffer_overflow_error = "internal buffer overflow"; -static const char *shutdown_error = "libraries already shutdown"; +static const char *shutdown_error = "library already shutdown"; static const char *last_error; @@ -299,7 +299,7 @@ dl = { LT_DLTYPE_TOP, dl_init, dl_exit, #define BIND_RESTRICTED 0 #endif /* BIND_RESTRICTED */ -#define OPT_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH) +#define LTDL_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH) static int shl_init () @@ -318,8 +318,7 @@ shl_open (handle, filename) lt_dlhandle handle; const char *filename; { - handle->handle = shl_load (filename, OPT_BIND_FLAGS, 0L); - /* the hp-docs say we should better abort() if errno==ENOSYM ;( */ + handle->handle = shl_load(filename, LTDL_BIND_FLAGS, 0L); if (!handle->handle) { last_error = unknown_error; return 1; @@ -345,7 +344,7 @@ shl_sym (handle, symbol) { lt_ptr_t address; - if (shl_findsym ((shl_t) (handle->handle), symbol, TYPE_UNDEFINED, + if (shl_findsym((shl_t) (handle->handle), symbol, TYPE_UNDEFINED, &address) != 0 || !(handle->handle) || !address) { last_error = unknown_error; return 0; @@ -497,17 +496,17 @@ wll = { LT_DLTYPE_TOP, wll_init, wll_exit, #if HAVE_DLPREOPEN -/* emulate dynamic linking using dld_preloaded_symbols */ +/* emulate dynamic linking using preloaded_symbols */ typedef struct lt_dlsymlists_t { struct lt_dlsymlists_t *next; - lt_dlsymlist *syms; + const lt_dlsymlist *syms; } lt_dlsymlists_t; static lt_dlsymlists_t *preloaded_symbols = 0; static int -dldpre_init () +presym_init () { /* Don't nullify preloaded_symbols here, it would prevent one from calling lt_dlpreload_default() before lt_dlinit() */ @@ -515,7 +514,7 @@ dldpre_init () } static void -dldpre_free_symlists () +presym_free_symlists () { lt_dlsymlists_t *lists = preloaded_symbols; @@ -529,7 +528,7 @@ dldpre_free_symlists () } static int -dldpre_exit () +presym_exit () { /* Don't reset preloaded_symbols here; adding/removing symbols should be unrelated with init/exit */ @@ -537,8 +536,8 @@ dldpre_exit () } static int -dldpre_add_symlist (preloaded) - lt_dlsymlist *preloaded; +presym_add_symlist (preloaded) + const lt_dlsymlist *preloaded; { lt_dlsymlists_t *tmp; lt_dlsymlists_t *lists = preloaded_symbols; @@ -569,7 +568,7 @@ dldpre_add_symlist (preloaded) } static int -dldpre_open (handle, filename) +presym_open (handle, filename) lt_dlhandle handle; const char *filename; { @@ -584,12 +583,12 @@ dldpre_open (handle, filename) return 1; } while (lists) { - lt_dlsymlist *syms = lists->syms; + const lt_dlsymlist *syms = lists->syms; while (syms->name) { if (!syms->address && strcmp(syms->name, filename) == 0) { - handle->handle = syms; + handle->handle = (lt_ptr_t) syms; return 0; } syms++; @@ -601,14 +600,14 @@ dldpre_open (handle, filename) } static int -dldpre_close (handle) +presym_close (handle) lt_dlhandle handle; { return 0; } static lt_ptr_t -dldpre_sym (handle, symbol) +presym_sym (handle, symbol) lt_dlhandle handle; const char *symbol; { @@ -630,11 +629,11 @@ dldpre_sym (handle, symbol) static lt_dltype_t -dldpre = { LT_DLTYPE_TOP, dldpre_init, dldpre_exit, - dldpre_open, dldpre_close, dldpre_sym }; +presym = { LT_DLTYPE_TOP, presym_init, presym_exit, + presym_open, presym_close, presym_sym }; #undef LT_DLTYPE_TOP -#define LT_DLTYPE_TOP &dldpre +#define LT_DLTYPE_TOP &presym #endif @@ -676,13 +675,13 @@ lt_dlinit () int lt_dlpreopen (preloaded) - lt_dlsymlist *preloaded; + const lt_dlsymlist *preloaded; { #if HAVE_DLPREOPEN if (preloaded) - return dldpre_add_symlist(preloaded); + return presym_add_symlist(preloaded); else { - dldpre_free_symlists(); + presym_free_symlists(); return 0; } #else @@ -835,7 +834,7 @@ find_library (handle, filename, have_dir, basename, search_path) if (tryall_dlopen(handle, filename) == 0) return 0; - if (have_dir && !search_path) { + if (have_dir || !search_path) { last_error = file_not_found_error; return 1; } @@ -899,7 +898,7 @@ find_file (filename, basename, have_dir, search_path) if (file) return file; - if (have_dir && !search_path) { + if (have_dir || !search_path) { last_error = file_not_found_error; return 0; } @@ -1157,6 +1156,10 @@ lt_dlsym (handle, symbol) last_error = invalid_handle_error; return 0; } + if (!symbol) { + last_error = symbol_error; + return 0; + } lensym = strlen(symbol); if (handle->name) lenhand = strlen(handle->name); diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h index 96f5c7de..3bca1ce9 100644 --- a/libltdl/ltdl.h +++ b/libltdl/ltdl.h @@ -69,21 +69,21 @@ typedef lt_ptr_t lt_dlhandle; #endif typedef struct { - char *name; + const char *name; lt_ptr_t address; } lt_dlsymlist; __BEGIN_DECLS _LTDLL_EXTERN int lt_dlinit __P((void)); -_LTDLL_EXTERN int lt_dlpreopen __P((lt_dlsymlist *preloaded)); +_LTDLL_EXTERN int lt_dlpreopen __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)); -extern lt_dlsymlist dld_preloaded_symbols[]; -#define lt_dlpreopen_default() (lt_dlpreopen(dld_preloaded_symbols)) +extern const lt_dlsymlist lt_preloaded_symbols[]; + __END_DECLS #endif /* !_LTDL_H_ */ diff --git a/ltconfig.in b/ltconfig.in index d6c6b039..dada60aa 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -1429,12 +1429,8 @@ EOF # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" - wcout=`wc "$nlist" 2>/dev/null` - count=`$echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` - (test "$count" -ge 0) 2>/dev/null || count=-1 else rm -f "$nlist"T - count=-1 fi # Make sure that we snagged all the symbols we need. @@ -1456,15 +1452,12 @@ EOF # define lt_ptr_t char * #endif -/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */ -int dld_preloaded_symbol_count = $count; - /* The mapping between symbol names and symbols. */ -struct { - char *name; +const struct { + const char *name; lt_ptr_t address; } -dld_preloaded_symbols[] = +lt_preloaded_symbols[] = { EOF sed 's/^\(.*\) \(.*\)$/ {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c diff --git a/ltmain.in b/ltmain.in index b2c213cc..28e255d5 100644 --- a/ltmain.in +++ b/ltmain.in @@ -625,6 +625,7 @@ compiler." ltlibs= module=no objs= + preload=no prev= prevarg= release= @@ -668,6 +669,12 @@ compiler." case "$prev" in dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi case "$arg" in *.la | *.lo) ;; # We handle these cases below. *) @@ -748,10 +755,12 @@ compiler." else arg= fi - - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi fi ;; @@ -939,10 +948,10 @@ compiler." if test -n "$dependency_libs"; then # Extract -R from dependency_libs temp_deplibs= - for dep in $dependency_libs; do - case "$dep" in - -R*) xrpath="$xrpath "`echo "X$dep" | $Xsed -e 's/^-R//'`;; - *) temp_deplibs="$temp_deplibs $dep";; + for deplib in $dependency_libs; do + case "$deplib" in + -R*) xrpath="$xrpath "`echo "X$deplib" | $Xsed -e 's/^-R//'`;; + *) temp_deplibs="$temp_deplibs $deplib";; esac done dependency_libs="$temp_deplibs" @@ -1922,7 +1931,7 @@ extern \"C\" { #endif /* Prevent the only kind of declaration conflicts we can make. */ -#define dld_preloaded_symbols some_other_symbol +#define lt_preloaded_symbols some_other_symbol /* External symbol declarations for the compiler. */\ " @@ -1955,7 +1964,7 @@ extern \"C\" { $echo >> "$output_objdir/$dlsyms" "\ -#undef dld_preloaded_symbols +#undef lt_preloaded_symbols #if defined (__STDC__) && __STDC__ # define lt_ptr_t void * @@ -1964,11 +1973,11 @@ extern \"C\" { #endif /* The mapping between symbol names and symbols. */ -struct { - char *name; +const struct { + const char *name; lt_ptr_t address; } -dld_preloaded_symbols[] = +lt_preloaded_symbols[] = {\ " @@ -2016,7 +2025,7 @@ dld_preloaded_symbols[] = esac else # We keep going just in case the user didn't refer to - # dld_preloaded_symbols. The linker will fail if global_symbol_pipe + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. if test -n "$dlfiles$dlprefiles"; then $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 @@ -3182,11 +3191,15 @@ a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all + -avoid-versioning do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -release RELEASE specify package release information diff --git a/mail/deplibs.html b/mail/deplibs.html new file mode 100644 index 00000000..5d8ebf76 --- /dev/null +++ b/mail/deplibs.html @@ -0,0 +1,213 @@ + + +Libtool Inter-library Dependencies + +

Libtool

+ +

Inter-library Dependencies

+ +

About twice a week, for the last five weeks, I've been receiving +bug reports which tell me that libtool's inter-library dependency +handling is broken. + +

I know. I broke it intentionally, until I have the time to fix it +myself, or somebody else takes the time to help me with it. + +

These same people often give me a simple one-line patch which +re-enables my old, simplistic inter-library dependencies, but nobody +seems to want to test things thoroughly and come up with a real +solution. + +

If you don't care about the history, and you just want to help me +out, jump to the bottom of this document. + +

Background

+ +

Libtool's basic premise is to make static and shared libraries +behave the same way from a programmer's point of view. This allows +users to build a libtoolized package with or without shared libraries, +determined at configuration time. It does this by using a +libtool object (.lo) and libtool +archive (.la) abstraction, so that the package +maintainer can use libtool to operate on these files without making +any assumptions about their underlying representation. + +

For the most part, this abstraction works well, and has made +libtool as popular as it is today. Without this abstraction, it would +be significantly harder to port libtool to new platforms. + +

Unfortunately, what this abstraction has also done is reveal some +fundamental inconsistencies with most shared library implementations. +Every shared library implementation works well for `hello world'-type +examples, but very few are robust and well-designed so that libtool +doesn't need special tricks in order to build correct, featureful +shared libraries. + +

Providing inter-library dependencies is one feature that has +revealed these kinds of inconsistencies. + +

The problem

+ +

My orginal inter-library dependency code received rigourous testing +in beta releases of GNU +Guile. As soon as the Guile people started using my code, I +received a flood of bug reports. People were reporting that +libguile (Guile's main shared library) was failing to +link, or that programs linked against libguile were +dumping core. + +

Not good. + +

The Guile people chased this bug down to the following scenario: + +

    +
  1. The user's system has a static regexp library installed, +librx.a. + +
  2. Guile's configure script detects that the +-lrx linker option can be used to link in +librx. + +
  3. When libguile is built, the -lrx linker +option is used. + +
  4. Some linkers fail at this point, because they don't allow shared +libraries to contain or depend on static libraries. + +
  5. If the linker didn't fail, then a few programs are linked against +libguile. + +
  6. On some systems, these programs core dump because +libguile is a shared library that contains non-PIC code +(from librx). +
+ +

The interim solution

+ +

I needed some way to respond to these reports. I saw my options (in +order of my preference) as: + +

    +
  1. Write code in ltmain.sh to prevent static libraries +from appearing in inter-library dependencies. This would take some +work, but obviously is the best solution. + +
  2. Find the systems that fail, and turn off inter-library +dependencies on only those systems. + +
  3. Force the package maintainer to guarantee that static libraries +never appear in inter-library dependencies. +
+ +

I immediately vetoed the last solution, because that would violate +the whole point of using libtool, and would cause a lot of people to +waste time solving a problem that really should be fixed by libtool. + +

I preferred the first solution, but at the time of the reports, I +didn't see an obviously simple mechanism for detecting the difference +between shared and static libraries. + +

So, in the meantime, I tried turning off inter-library dependencies +on the systems that failed. + +

I quickly discovered, to my chagrin, that many systems fail. So, +it was be simpler for me to turn off all inter-library +dependencies, then find out which systems work, rather than vice +versa. + +

The current situation

+ +

I've been busy trying to avoid bankruptcy. It's been over three +months since I first turned off inter-library dependencies, and I +still haven't completed the solution I want. + +

I've been gearing up for the 1.1 release of libtool, because there +is a high demand for a stable public release. So, I'm not going to +introduce any destabilizing changes to the inter-library dependency +code until after 1.1 is released. + +

The solution

+ +

So, I want to tell you how you can help me solve the various +dilemmas surrounding this issue: + +

    +
  1. I need to find out more about the nature of the problems I ran +into with Guile. Unfortunately, I cannot reproduce them in simple +tests on my own platform (i586-pc-linux-gnulibc1), even though I think +they were reported here. I need to find out which platforms already +have perfect inter-library dependency support, how to work around the +problem on other platforms, and, more importantly, exactly +why some systems give me problems and others don't. + +

    On correct platforms, you can link any static library +against a shared library via the -lNAME option without +the linker complaining, then link a program against this library and +run it without dumping core. I know that this scenario will always +work fine on the following systems: + +

      +
    • None reported yet. +
    + +

    I also know that on some systems, you can create a shared library +linked against a static one, but running programs linked against such +a library will dump core: + +

      +
    • None reported yet. +
    + +

    Finally, there are some systems which won't even allow you to link +a shared library against a static one: + +

      +
    • Solaris 2.x +
    + +
  2. Help me figure out a good, portable way to detect if a given +-lNAME option refers to a shared library or not, since +that is needed as a workaround to the problem. Some suggestions so +far have been: + +
      +
    • Link the library against a tiny test program, and: + +
        +
      • run ldd(1) on the test program and search for + libNAME in the ldd output. +
      • use the -verbose flag for GNU ld in order to see + which library is actually linked. +
      • run some sort of other program to determine if the library was + dynamic. +
      + +
    • Track the -LDIR flags, do a search for the library, + and then check whether it is shared by: + +
        +
      • using the file(1) program. +
      • looking at its suffix. +
      +
    + +
  3. Contact any people you know who might be interested, get them to +read this page, so that they can help me solve the problem. + +
  4. Send me money, so that I can devote more of my time to solving the +problem. +
+ +

Thank you for your help, and have fun. + +


+ + +

Back to the libtool home page. + +

+Gordon Matzigkeit <gord@profitpress.com> +
+ \ No newline at end of file diff --git a/mdemo/Makefile.am b/mdemo/Makefile.am index 224c09a5..6d987588 100644 --- a/mdemo/Makefile.am +++ b/mdemo/Makefile.am @@ -18,19 +18,18 @@ noinst_HEADERS = foo.h bin_PROGRAMS = mdemo mdemo.debug -../libltdl/libtest.la: ../libltdl/libtool \ +../libltdl/libltdlc.la: ../libltdl/libtool \ $(srcdir)/../libltdl/ltdl.c $(srcdir)/../libltdl/ltdl.h - (cd ../libltdl; $(MAKE) libtest.la) + (cd ../libltdl; $(MAKE) libltdlc.la) # Create a version of mdemo that does dlopen. mdemo_SOURCES = main.c -mdemo_LDADD = ../libltdl/libtest.la -mdemo_LDFLAGS = -export-dynamic -dlopen foo1.la -dlopen libfoo2.la -mdemo_DEPENDENCIES = ../libltdl/libtest.la foo1.la libfoo2.la +mdemo_LDADD = ../libltdl/libltdlc.la +mdemo_LDFLAGS = -dlopen foo1.la -dlopen libfoo2.la +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/libtest.la -mdemo_debug_LDFLAGS = -static -export-dynamic \ - -dlopen foo1.la -dlopen libfoo2.la -mdemo_debug_DEPENDENCIES = ../libltdl/libtest.la foo1.la libfoo2.la +mdemo_debug_LDADD = ../libltdl/libltdlc.la +mdemo_debug_LDFLAGS = -static -dlopen foo1.la -dlopen libfoo2.la +mdemo_debug_DEPENDENCIES = ../libltdl/libltdlc.la foo1.la libfoo2.la diff --git a/mdemo/main.c b/mdemo/main.c index 5efc0df7..3f678160 100644 --- a/mdemo/main.c +++ b/mdemo/main.c @@ -92,6 +92,10 @@ main (int argc, char **argv) fprintf (stderr, "error during initialization: %s\n", lt_dlerror()); return 1; } + if (lt_dlpreopen(lt_preloaded_symbols) != 0) { + fprintf (stderr, "error during initialization: %s\n", lt_dlerror()); + return 1; + } for (i = 1; i < argc; i++) if (test_dl(argv[i]))