diff --git a/ChangeLog b/ChangeLog index b318cd0f..d5453015 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1999-02-21 Thomas Tanner + + * libltdl/ltdl.c (lt_dlopen): use newhandle instead of handle + when dlopening the executable + * libtool.m4 (AC_LIBTOOL_DLOPEN): removed the redundant "yes: " + prefix for lt_cv_dlopen, renamed lt_cv_dlopen_LIBS + to lt_cv_dlopen_libs (more consistent) + * ltmain.in: implemented -dl[pre]open self, necessary for + lt_dlopen(NULL), generation of exported symbols was broken + 1999-02-20 Alexandre Oliva * ltmain.in: avoid duplication of -L switches, it sometimes breaks diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index edc92786..228126bf 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -1048,8 +1048,8 @@ lt_dlopen (filename) } handle->usage = 0; newhandle = handle; - if (tryall_dlopen(&handle, 0) != 0) { - lt_dlfree(newhandle); + if (tryall_dlopen(&newhandle, 0) != 0) { + lt_dlfree(handle); return 0; } goto register_handle; diff --git a/libtool.m4 b/libtool.m4 index 3d4fbe49..ec4f032e 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -121,21 +121,21 @@ exec 5>>./config.log # AC_LIBTOOL_DLOPEN - check for dlopen support AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_CACHE_VAL(lt_cv_dlopen, -[lt_cv_dlopen=no lt_cv_dlopen_LIBS= -AC_CHECK_FUNC(dlopen, [lt_cv_dlopen="yes: dlopen"], - [AC_CHECK_LIB(dl, dlopen, [lt_cv_dlopen="yes: dlopen" lt_cv_dlopen_LIBS="-ldl"], - [AC_CHECK_LIB(dld, dld_link, [lt_cv_dlopen="yes: dld_link" lt_cv_dlopen_LIBS="-ldld"], - [AC_CHECK_FUNC(shl_load, [lt_cv_dlopen="yes: shl_load"], - [AC_CHECK_FUNC(LoadLibrary, [lt_cv_dlopen="yes: LoadLibrary"])] +[lt_cv_dlopen=no lt_cv_dlopen_libs= +AC_CHECK_FUNC(dlopen, [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB(dl, dlopen, [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB(dld, dld_link, [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC(shl_load, [lt_cv_dlopen="shl_load"], + [AC_CHECK_FUNC(LoadLibrary, [lt_cv_dlopen="LoadLibrary"])] )] )] )] )]) case "$lt_cv_dlopen" in -"yes: dlopen") +dlopen) AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, - [LT_SAVE_LIBS="$LIBS"; LIBS="$lt_cv_dlopen_LIBS $LIBS" + [LT_SAVE_LIBS="$LIBS"; LIBS="$lt_cv_dlopen_libs $LIBS" AC_TRY_RUN([ #include #include diff --git a/ltmain.in b/ltmain.in index 880e537a..428e4b77 100644 --- a/ltmain.in +++ b/ltmain.in @@ -802,6 +802,7 @@ compiler." avoid_version=no dlfiles= dlprefiles= + dlself=no export_dynamic=no export_symbols= export_symbols_regex= @@ -865,6 +866,13 @@ compiler." fi case "$arg" in *.la | *.lo) ;; # We handle these cases below. + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" = no; then + dlself=yes + fi + ;; *) dlprefiles="$dlprefiles $arg" test "$prev" = dlfiles && dlfiles="$dlfiles $arg" @@ -949,12 +957,6 @@ compiler." else arg= fi - 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 ;; @@ -2008,9 +2010,9 @@ EOF fi # Prepare the list of exported symbols - if test -z "$run" && test -z "$export_symbols"; then - $show "extracting global symbols from \`$libname'" + if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "extracting global symbols from \`$libname'" export_symbols="$objdir/$libname.exp" $run $rm $export_symbols eval cmds=\"$export_symbols_cmds\" @@ -2028,9 +2030,10 @@ EOF $run eval '$mv "$export_symbols"T "$export_symbols"' fi fi - if test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi # Do each of the archive commands. @@ -2168,6 +2171,11 @@ EOF $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 fi + if test "$dlself" = yes && test "$export_dynamic" = no; then + $echo "$modename: error: \`-dlopen self' requires \`-export-dynamic'" 1>&2 + exit 1 + fi + if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do @@ -2226,7 +2234,7 @@ EOF fi dlsyms= - if test -n "$dlfiles$dlprefiles"; then + if test -n "$dlfiles$dlprefiles" || test "$dlself" = yes; then if test -n "$NM" && test -n "$global_symbol_pipe"; then dlsyms="${outputname}S.c" else @@ -2270,7 +2278,7 @@ extern \"C\" { /* External symbol declarations for the compiler. */\ " - if test "$export_dynamic" = yes && test "$dlopen_self" = no; then + if test "$dlself" = yes; then if test -n "$export_symbols"; then $run eval 'sed -e "s/^\(.*\)/\1 \1/" < "$export_symbols" > "$nlist"' else @@ -2330,7 +2338,7 @@ lt_preloaded_symbols[] = {\ " - if test "$export_dynamic" = yes && test "$dlopen_self" = no; then + if test "$dlself" = yes; then # First entry is the program itself echo >> "$output_objdir/$dlsyms" "\ {\"@PROGRAM@\", (lt_ptr_t) 0},"