From: Gordon Matzigkeit Date: Mon, 21 Jul 1997 17:31:05 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release-1-0b~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5bd0f665eb52d8dd076b83c1bf7e37dbfdc4b59;p=thirdparty%2Flibtool.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 6649b031f..9c1753a39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +Mon Jul 21 09:46:02 1997 Gordon Matzigkeit + + * ltmain.sh.in (link): Finish full integration for `-dlopen' and + `-dlpreopen'. + Fix two silly typos where I used a compile_command in place of a + finalize_command, and vice versa. + Change the wrapper script to check a hardcoded path only if the + argv[0] method fails. This is a compromise for the previous two + patches, and should solve the majority of problems with wrapper + scripts. From Kenneth Albanowski. + + * demo/Makefile.am (helldl_LDFLAGS): Add `-export-dynamic' and + `-dlpreopen' for building helldl. + + * demo/dlmain.c (main): Succeed, even if none of the libhello + symbols have been preloaded. + +Sun Jul 20 10:17:04 1997 Gordon Matzigkeit + + * ltconfig.in (global_symbol_pipe): Add `U' to the accepted global + symbol types. This means that we will get duplicate symbols, but + we'll also be sure to get all global symbols used by the program. + + * ltconfig.in (pipe_works), ltmain.sh.in (link): Sort and make + symbol output unique. + Sat Jul 19 21:54:33 1997 Gordon Matzigkeit * ltconfig.in (pipe_works): Check to make sure our guessed diff --git a/NEWS b/NEWS index 151c1c292..959ddd0a6 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,7 @@ NEWS - list of user-visible changes between releases of GNU libtool. New in 1.0a: * Bug fixes. * Full support for dynamically loaded modules, even on static-only - platforms, via a new `-dlopen' link flag. + platforms, via new `-dlopen' and `-pre-dlopen' link flags. * New tests for a BSD-compatible `nm' program, required for dlopened modules. * FIXME: Deleted `dlname' mode, now that the internal structure of `.la' diff --git a/README b/README index 4c95700f9..c9e086979 100644 --- a/README +++ b/README @@ -9,7 +9,6 @@ details. Libtool supports building static libraries on all platforms. Shared library support has been implemented for these platforms: - All ELF targets that use both the GNU C compiler (gcc) and GNU ld AIX 3.x (*-*-aix3*) AIX 4.x (*-*-aix4*) Digital/UNIX 3.x, 4.x, a.k.a. OSF/1 (*-*-osf3*, *-*-osf4*) @@ -22,6 +21,7 @@ Shared library support has been implemented for these platforms: SCO OpenServer 5.x (*-*-sco3.2v5*) Solaris 2.x (*-*-solaris2*) SunOS 4.x, a.k.a. Solaris 1.x (*-*-sunos4*) + All ELF targets that use both the GNU C compiler (gcc) and GNU ld See the file NEWS for a description of recent changes to libtool. diff --git a/TODO b/TODO index 759067fe9..9f3299496 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,9 @@ is to have undocumented utility libraries, where only the shared version is installed. +* We could use libtool object convenience libraries that resolve +symbols to be included in a libtool archive. + * Somehow we need to make sure that static libraries never appear in $deplibs. If a program linked against a library doesn't contain the basename of the library (or is the same size), then the library is @@ -10,12 +13,6 @@ probably static. * A better check to detect broken collect2 on AIX, once the bug is fixed in GCC. -* We could use libtool object convenience libraries that resolve -symbols to be included in a libtool archive. - -* Add a flag to make sure at least a null dld_preloaded_symbols is -generated. - * Implement full multi-language support. Currently, this is only for C++, but there are beginnings of this in the manual (Other Languages). This includes writing libtool not to be so dependent on the compiler diff --git a/demo/Makefile.am b/demo/Makefile.am index d7b8c00f4..b2e9f33f3 100644 --- a/demo/Makefile.am +++ b/demo/Makefile.am @@ -28,9 +28,9 @@ hell_static_SOURCES = main.c hell_static_LDADD = libhello.la hell_static_LDFLAGS = -static -# Create a version of hell that does its own dlopening. +# Create a version of hell that does a preloaded dlopen. helldl_SOURCES = dlmain.c -helldl_LDFLAGS = -dlopen libhello.la +helldl_LDFLAGS = -export-dynamic -dlpreopen libhello.la TESTS = run.test diff --git a/demo/dlmain.c b/demo/dlmain.c index 307796249..e724e3803 100644 --- a/demo/dlmain.c +++ b/demo/dlmain.c @@ -37,8 +37,9 @@ main (int argc, char **argv) int (*phello)() = 0; int *pnothing = 0; - printf ("Welcome to GNU Hell **dynamically**!\n"); + printf ("Welcome to *modular* GNU Hell!\n"); + /* Look up the symbols we require for this demonstration. */ s = dld_preloaded_symbols; while (s->name) { @@ -67,10 +68,7 @@ main (int argc, char **argv) return 1; } else - { - fprintf (stderr, "did not find the `foo' function\n"); - return 2; - } + fprintf (stderr, "did not find the `foo' function\n"); if (phello) { @@ -78,10 +76,7 @@ main (int argc, char **argv) return 3; } else - { - fprintf (stderr, "did not find the `hello' function\n"); - return 4; - } + fprintf (stderr, "did not find the `hello' function\n"); return 0; } diff --git a/ltconfig.in b/ltconfig.in index d5e53614c..8aa0ecdcd 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -742,21 +742,21 @@ echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 # This is a sane default that works on at least a few old systems. # [It comes from Ultrix. What could be older than Ultrix?!! ;)] -global_symbol_pipe="sed '/^.* [BCDEGRST] /!d; s/^.* [BCDEGRST] \(.*\)$/\1 \1/'" +global_symbol_pipe="sed '/^.* [BCDEGRSTU] /!d; s/^.* [BCDEGRSTU] \(.*\)$/\1 \1/'" # Take a first stab at what the pipe should be. if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then # We're using GNU nm. - global_symbol_pipe="sed '/^.* [BCDGIST] /!d; s/^.* [BCDGIST] \(.*\)$/\1 \1/'" + global_symbol_pipe="sed '/^.* [ABCDGISTU] /!d; s/^.* [ABCDGISTU] \(.*\)$/\1 \1/'" else # It's the system nm. case "$host_os" in aix*) # Delete symbols that begin with a dot. - global_symbol_pipe="sed '/^.* [BCDT] [^.]/!d; s/^.* [BCDT] \(.*\)$/\1 \1/'" + global_symbol_pipe="sed '/^.* [BCDTU] [^.]/!d; s/^.* [BCDTU] \(.*\)$/\1 \1/'" ;; solaris2*) - global_symbol_pipe="sed '/^.* [BDT] /!d; s/^.* [BDT] \(.*\)$/\1 \1/'" + global_symbol_pipe="sed '/^.* [BDTU] /!d; s/^.* [BDTU] \(.*\)$/\1 \1/'" ;; esac fi @@ -775,6 +775,9 @@ if { (eval echo $progname:751: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } # Now try to grab the symbols. if { echo "$progname:752: eval \"$NM conftest.o | $global_symbol_pipe > conftest.nm\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > conftest.nm 2>&5"; } && test -s conftest.nm; then + # Try sorting and uniquifying the output. + sort conftest.nm | uniq > conftest.nmT && mv -f conftest.nmT conftest.nm + # Make sure that we snagged all the symbols we need. if egrep ' nm_test_var$' conftest.nm >/dev/null; then if egrep ' nm_test_func$' conftest.nm >/dev/null; then diff --git a/ltmain.sh.in b/ltmain.sh.in index eaac8d540..929e434df 100644 --- a/ltmain.sh.in +++ b/ltmain.sh.in @@ -293,6 +293,7 @@ if test -z "$show_help"; then finalize_shlibpath= deplibs= dlfiles= + dlprefiles= export_dynamic=no hardcode_libdirs= install_libdir= @@ -332,17 +333,18 @@ if test -z "$show_help"; then esac case "$prev" in - dlopen) - if test -z "$dlfiles"; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$compile_command @SYMFILE@" - fi - dlfiles="$dlfiles $arg" - prev= + dlfiles|dlprefiles) + case "$arg" in + *.la) ;; # We handle this case below. + *) + dlprefiles="$dlprefiles $arg" + test "$prev" = dlfiles && dlfiles="$dlfiles $arg" + prev= + ;; + esac ;; *) - eval "$prev=\$arg" + eval "$prev=\"\$arg\"" prev= continue ;; @@ -356,14 +358,24 @@ if test -z "$show_help"; then -allow-undefined) allow_undefined=yes ;; -dlopen) - prev=dlopen + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles continue ;; -export-dynamic) - export_dynamic=yes - compile_command="$compile_command "`eval echo "$export_dynamic_flag"` - finalize_command="$finalize_command "`eval echo "$export_dynamic_flag"` + if test "$export_dynamic" != yes; then + export_dynamic=yes + compile_command="$compile_command "`eval echo "$export_dynamic_flag"` + finalize_command="$finalize_command "`eval echo "$export_dynamic_flag"` + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + fi continue ;; @@ -431,6 +443,7 @@ if test -z "$show_help"; then *.la) # A libtool-controlled library. + dlname= libdir= library_names= old_library= @@ -473,6 +486,31 @@ if test -z "$show_help"; then dir="$dir/$objdir" fi + # This library was specified with -dlopen. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test -z "$dlname"; then + # If there is no dlname, we need to preload. + prev=dlprefiles + else + # We should not create a dependency on this library. + prev= + continue + fi + fi + + # The library was specified with -dlpreopen. + if test "$prev" = dlprefiles; then + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + dlprefiles="$dlprefiles $dir/$old_library" + else + dlprefiles="$dlprefiles $dir/$linklib" + fi + prev= + fi + if test "$build_libtool_libs" = yes && test -n "$library_names"; then link_against_libtool_libs="$link_against_libtool_libs $arg" if test -n "$shlibpath_var"; then @@ -636,11 +674,11 @@ if test -z "$show_help"; then exit 1 fi - if test -n "$dlfiles"; then + if test -n "$dlfiles$dlprefiles"; then echo "$progname: warning: \`-dlopen' is ignored while creating libtool libraries" 1>&2 # Nullify the symbol file. - compile_command=`echo "$compile_command" | sed "s%@SYMFILE@%%"` - finalize_command=`echo "$finalize_command" | sed "s%@SYMFILE@%%"` + compile_command=`echo "$compile_command" | sed "s% @SYMFILE@%%"` + finalize_command=`echo "$finalize_command" | sed "s% @SYMFILE@%%"` fi if test -z "$install_libdir"; then @@ -816,11 +854,11 @@ if test -z "$show_help"; then echo "$progname: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2 fi - if test -n "$dlfiles"; then + if test -n "$dlfiles$dlprefiles"; then echo "$progname: warning: \`-dlopen' is ignored while creating objects" 1>&2 # Nullify the symbol file. - compile_command=`echo "$compile_command" | sed "s%@SYMFILE@%%"` - finalize_command=`echo "$finalize_command" | sed "s%@SYMFILE@%%"` + compile_command=`echo "$compile_command" | sed "s% @SYMFILE@%%"` + finalize_command=`echo "$finalize_command" | sed "s% @SYMFILE@%%"` fi if test -n "$install_libdir"; then @@ -907,69 +945,29 @@ if test -z "$show_help"; then # Transform all the library objects into standard objects. compile_command=`echo "$compile_command " | sed 's/\.lo /.o /g; s/ $//'` finalize_command=`echo "$finalize_command " | sed 's/\.lo /.o /g; s/ $//'` - dlfiles=`echo "$dlfiles " | sed 's/\.lo /.o /g; s/ $//'` fi - if test -n "$dlfiles"; then - if test -z "$global_symbol_pipe" || test -z "$NM"; then - echo "$progname: not configured to extract global symbols from \`-dlopen' files" 1>&2 - exit 1 - fi + if test "$export_dynamic" = yes && test -n "$global_symbol_pipe" && test -n "$NM"; then + # Add our own program objects to the preloaded list. + dlprefiles=`echo "$objs$libobjs$dlprefiles " | sed 's/\.lo /.o/g; s/ $//'` # Discover the nlist of each of the dlfiles. dlsyms="$objdir/${output}S.c" - nlist="$objdir/${output}.syms" + nlist="$objdir/${output}.nm" - $run rm -f $nlist - for arg in $dlfiles; do - pre_dlname= - case "$arg" in - *.a | *.o) pre_dlname="$arg" ;; - *.la) - # We already checked for libtool archive validity above. - - # Find the directory that the archive lives in. - ltlib=`echo "$arg" | sed 's%^.*/%%'` - dir=`echo "$arg" | sed 's%/[^/]*$%%'` - test "X$dir" = "X$arg" && dir=. - - # Read the libtool archive. - old_library= - library_names= - . $dir/$ltlib - - # Prefer the new library to the old one. - if test -n "$library_names"; then - set dummy $library_names - pre_dlname="$2" - else - pre_dlname="$old_library" - fi - - if test -f "$dir/$objdir/$pre_dlname"; then - pre_dlname="$dir/$objdir/$pre_dlname" - elif test -f "$dir/$pre_dlname"; then - pre_dlname="$dir/$pre_dlname" - else - echo "$progname: cannot find \`$pre_dlname' in \`$dir/$objdir' or \`$dir'" 1>&2 - pre_dlname= - fi - ;; - esac - - if test -z "$pre_dlname"; then - echo "$progname: \`$arg' is not a dlopenable file" 1>&2 - exit 1 - fi - - echo "extracting global symbols from \`$pre_dlname'" - $run eval "$NM $pre_dlname | $global_symbol_pipe >> $nlist" + $run rm -f "$nlist" "$nlist"T + for arg in $dlprefiles; do + echo "extracting global symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done # Parse the name list into a C file. echo "creating $dlsyms" if test -z "$run"; then - cat < $dlsyms + # Try sorting and uniquifying the output. + sort "$nlist" | uniq > "$nlist"T && mv -f "$nlist"T "$nlist" + + cat < "$dlsyms" /* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION */ @@ -977,12 +975,12 @@ if test -z "$show_help"; then EOF if test -f "$nlist"; then # Prevent the only kind of circular reference mistake we can make. - sed '/ dld_preloaded_symbols$/d; s/^.* \(.*\)$/extern char \1;/' < $nlist >> $dlsyms + sed '/ dld_preloaded_symbols$/d; s/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$dlsyms" else - echo "/* NONE */" >> $dlsyms + echo "/* NONE */" >> "$dlsyms" fi - cat <<\EOF >> $dlsyms + cat <<\EOF >> "$dlsyms" #if defined (__STDC__) && __STDC__ # define __ptr_t void * @@ -1000,23 +998,31 @@ dld_preloaded_symbols[] = EOF if test -f "$nlist"; then - sed 's/^\(.*\) \(.*\)$/ {"\1", \&\2},/' < $nlist >> $dlsyms + sed 's/^\(.*\) \(.*\)$/ {"\1", \&\2},/' < "$nlist" >> "$dlsyms" fi - cat <<\EOF >> $dlsyms + cat <<\EOF >> "$dlsyms" {0}, }; EOF fi - $run rm -f "$nlist" + $run rm -f "$nlist" "$nlist"T # Now compile the dynamic symbol file. - $show "(cd $objdir && $CC -c ${output}S.c)" - $run eval "(cd $objdir && $CC -c ${output}S.c)" || exit $? + $show "(cd $objdir && $CC -c '${output}S.c')" + $run eval "(cd $objdir && $CC -c '${output}S.c')" || exit $? # Transform the symbol file into the correct name. compile_command=`echo "$compile_command" | sed "s%@SYMFILE@%$objdir/${output}S.o%"` finalize_command=`echo "$finalize_command" | sed "s%@SYMFILE@%$objdir/${output}S.o%"` + elif test "$export_dynamic" != yes; then + test -n "$dlfiles$dlprefiles" && echo "$progname: warning: \`-dlopen' and \`-dlpreopen' are ignored without \`-export-dynamic'" 1>&2 + else + echo "$progname: not configured to extract global symbols from dlpreopened files" 1>&2 + + # Nullify the symbol file. + compile_command=`echo "$compile_command" | sed "s% @SYMFILE@%%"` + finalize_command=`echo "$finalize_command" | sed "s% @SYMFILE@%%"` fi if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then @@ -1033,8 +1039,8 @@ EOF if test $status -ne 0 && test -n "$link_static"; then echo "$progname: cannot link \`$output' statically; retrying semi-dynamically" 1>&2 compile_command=`echo "$compile_command " | sed "s% $link_static % %;s/ $//"` - $show "$finalize_command" - $run $finalize_command + $show "$compile_command" + $run $compile_command status=$? fi exit $status @@ -1133,8 +1139,12 @@ else # Try to get the absolute directory name. absdir=\`cd "\$thisdir" && pwd\` test -n "\$absdir" && thisdir="\$absdir" + progdir="\$thisdir/$objdir" - program="$output" + program='$output' + + # If the \$0 dir failed (maybe due to symlink), try a hardcoded dir. + test -f "\$progdir/\$program" || progdir='`pwd`/$objdir' if test -f "\$progdir/\$program"; then # Run the actual program with our arguments. @@ -1172,7 +1182,7 @@ EOF exit 1 else # The program doesn't exist. - echo "\$0: error: \$progdir/\$program does not exist" 1>&2 + echo "\$0: error: neither \$thisdir/$objdir/\$program nor \$progdir/\$program exists" 1>&2 echo "This script is just a wrapper for \$program." 1>&2 echo "See the $PACKAGE documentation for more information." 1>&2 exit 1 @@ -1822,7 +1832,8 @@ a program from several object files. The following components of LINK-COMMAND are treated specially: -allow-undefined allow a libtool library to reference undefined symbols - -dlopen FILE link in FILE and add its symbols to dld_preloaded_symbols + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME diff --git a/tests/demo-exec.test b/tests/demo-exec.test index 0babad1c9..2a224776b 100755 --- a/tests/demo-exec.test +++ b/tests/demo-exec.test @@ -31,7 +31,7 @@ else exit 1 fi -if ../demo/helldl | egrep -e '(Welcome to GNU Hell|unsupported)'; then : +if ../demo/helldl | egrep -e '(Welcome to .*GNU Hell|unsupported)'; then : else echo "$0: cannot execute ../demo/helldl" 1>&2 exit 1 diff --git a/tests/demo-inst.test b/tests/demo-inst.test index 281939f4e..419cafdfe 100755 --- a/tests/demo-inst.test +++ b/tests/demo-inst.test @@ -43,7 +43,7 @@ else status=1 fi -if $prefix/bin/helldl | egrep -e '(Welcome to GNU Hell|unsupported)'; then : +if $prefix/bin/helldl | egrep -e '(Welcome to .*GNU Hell|unsupported)'; then : else echo "$0: cannot execute $prefix/bin/helldl" 1>&2