From 8c7eb9e5c9acaaf877c6b65d512f7832ce0e50b6 Mon Sep 17 00:00:00 2001 From: Charles Wilson Date: Wed, 22 Sep 2004 08:50:34 +0000 Subject: [PATCH] * ltmain.in (func_generate_dlsyms) [cygwin, mingw]: when creating a .exp file for an executable, also create a .def file, and add that file to the link command via SYMFILES. This causes binutils to generate an .edata section, and allows self dlopening to work. * NEWS: Updated. --- ChangeLog | 6 ++++++ NEWS | 1 + config/ltmain.in | 33 +++++++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9ea85f2..418885f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2004-09-22 Charles Wilson + * ltmain.in (func_generate_dlsyms) [cygwin, mingw]: when creating + a .exp file for an executable, also create a .def file, and add + that file to the link command via SYMFILES. This causes binutils + to generate an .edata section, and allows self dlopening to work. + * NEWS: Updated. + * m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER): better quoting for postinstall_cmds and postuninstall_cmds to allow spaces in install paths. diff --git a/NEWS b/NEWS index b1118c39..5fee1426 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ New in 1.9d: 2004-??-??; CVS version 1.9c, Libtool team: types have been exchanged. See libltdl/slist.c for documentation. * libltdl is C89 compatible again. lt_dlsymbol type removed, and lt_dlsymlist structure changed to avoid using C99 flexible arrays. +* Support self dlopening for executables on cygwin and mingw. * Improved support for linux-gnu/ia64. * Fixed some memory leaks in libltdl. diff --git a/config/ltmain.in b/config/ltmain.in index 6566c725..69ed2f04 100644 --- a/config/ltmain.in +++ b/config/ltmain.in @@ -1019,8 +1019,18 @@ extern \"C\" { export_symbols="$output_objdir/$output.exp" $run $RM $export_symbols $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* ) + $run eval "${SED} -e '1iEXPORTS'"' < "$export_symbols" > "$output_objdir/$output.def"' + ;; + esac else $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + case $host in + *cygwin | *mingw* ) + $run eval "${SED} -e '1iEXPORTS'"' < "$output_objdir/$output.exp" > "$output_objdir/$output.def"' + ;; + esac $run eval '$GREP -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' $run eval '$MV "$nlist"T "$nlist"' fi @@ -1142,8 +1152,21 @@ static const void *lt_preloaded_setup() { # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + case $host in + *cygwin* | *mingw* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + ;; + esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" @@ -5828,8 +5851,10 @@ EOF esac case $host in *cygwin* | *mingw* ) - cwrappersource=`$echo ${objdir}/lt-${output}.c` - cwrapper=`$echo ${output}.exe` + output_name=`basename $output` + output_path=`dirname $output` + cwrappersource=`$echo "$output_path/$objdir/lt-$output_name.c"` + cwrapper=`$echo "$output_path/$output_name.exe"` $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15