diff --git a/ChangeLog b/ChangeLog index d5c7b466..92fce9de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,28 @@ +Tue Jul 29 11:52:10 1997 Gordon Matzigkeit + + * ltmain.sh.in: Add NLS environment variable handling copied from + ltconfig.in. Reported by Akim Demaille. + + * demo/dlmain.c (main): Use dld_preloaded_symbol_count to display + a message about the sortedness of the symbol table. + + * ltconfig.in (nlist): Use an nlist convenience variable, so that + code can be shared directly with ltmain.sh.in. + + * ltconfig.in, ltmain.sh.in (dld_preloaded_symbol_count): Count up + the number of symbols in the dld_preloaded_symbols. Set to `-1' + if the list wasn't both sorted and counted. This allows + applications to do a quick binary search, if they are so inclined. + Fri Jul 25 10:13:49 1997 Gordon Matzigkeit * ltmain.sh.in (link): Remove code for `-version-file', since it - has been long-deprecated. - Disable static linking if hardcode_direct is unsupported. + has been long-deprecated. + + Disable static linking if hardcode_direct is unsupported and there + is no working link_static_flag. This provides correct behaviour + for all cases on AIX 3, regardless of whether collect2 is broken + or not. Reported by Mark Kettenis. * ltconfig.in: Fix typo in test polarity. From Mark Kettenis. diff --git a/NEWS b/NEWS index 682732db..c6bf3315 100644 --- a/NEWS +++ b/NEWS @@ -1,13 +1,16 @@ NEWS - list of user-visible changes between releases of GNU libtool. -New in 1.0a: +New in 1.0b: * Bug fixes. -* Full support for dynamically loaded modules, even on static-only - platforms, via new `-dlopen' and `-pre-dlopen' link flags. -* New tests for a BSD-compatible `nm' program, required for dlopened - modules. +* Full support for broken collect2 on AIX 3. Now, shared libraries + can be built with all working versions of GCC. * Deleted `dlname' mode. Dlopen applications should only use the runtime search method described in (libtool)Finding the dlname. +* Experimental support for dynamically loaded modules, even on + static-only platforms, via new `-dlopen' and `-pre-dlopen' link + flags. +* New tests for a BSD-compatible `nm' program, required for dlopened + modules. New in 1.0: * Bug fixes. diff --git a/demo/dlmain.c b/demo/dlmain.c index f52d5def..90afd7a7 100644 --- a/demo/dlmain.c +++ b/demo/dlmain.c @@ -28,6 +28,7 @@ struct dld_symlist }; extern struct dld_symlist dld_preloaded_symbols[]; +extern int dld_preloaded_symbol_count; int main (argc, argv) @@ -41,6 +42,11 @@ main (argc, argv) printf ("Welcome to *modular* GNU Hell!\n"); + if (dld_preloaded_symbol_count < 0) + printf ("Sorry, the symbol list is not sorted and unique.\n"); + else + printf ("Yippee! The symbol list is both sorted and unique.\n"); + /* Look up the symbols we require for this demonstration. */ s = dld_preloaded_symbols; while (s->name) diff --git a/doc/libtool.texi b/doc/libtool.texi index bfc5c9d0..9ac33add 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -164,7 +164,8 @@ Tips for interface design Dlopened modules -* Exporting dynamic symbols:: Preparing files to be dlopened. +* Building modules:: Creating dlopenable objects and libraries. +* Dlpreopening:: * Finding the dlname:: Choosing the right file to @code{dlopen(3)}. * Dlopen issues:: Unresolved problems that need your attention. @@ -1879,18 +1880,10 @@ interpreted language. In fact, dlopen calls are frequently used in language interpreters to provide an efficient way to extend the language. -On most operating systems, dlopened modules must be compiled as PIC. -This restriction simplifies the implementation of the @code{dlopen(3)} -family of functions by avoiding symbol relocation. ``True'' dlopen -implementations, such as the unportable GNU DLD 3 implementation -(@pxref{Top,, Introduction, dld, The DLD Manual}), don't have this -restriction, as they can perform relocation at runtime. - -As of version @value{VERSION}, libtool provides only minimal support for -dlopened modules, and this support is guaranteed to change and be -redesigned in the near future. Because there is not a very high -proportion of applications that use dlopening, adding this support to -libtool was not deemed a priority for the 1.0 release. +As of version @value{VERSION}, libtool provides experimental support for +dlopened modules, which does not radically simplify the development of +dlopening applications. However, this support is designed to be a +portable foundation for generic, higher-level dlopen functions. This chapter discusses the preliminary support that libtool offers, and how you as a dlopen application developer might use libtool to generate @@ -1899,21 +1892,23 @@ experimental features, and not to rely on them for easy answers to the problems associated with dlopened modules. @menu -* Exporting dynamic symbols:: Preparing files to be dlopened. +* Building modules:: Creating dlopenable objects and libraries. +* Dlpreopening:: * Finding the dlname:: Choosing the right file to @code{dlopen(3)}. * Dlopen issues:: Unresolved problems that need your attention. @end menu -@node Exporting dynamic symbols -@section Exporting dynamic symbols +@node Building modules +@section Building modules to dlopen -In order for a symbol to be dynamically resolved (typically using the -@code{dlsym(3)} function), it must be specially declared in the object -module where it is defined. +On some operating systems, a program symbol must be specially declared +in order to be dynamically resolved with the @code{dlsym(3)} (or +equivalent) function. Libtool provides the @samp{-export-dynamic} link flag (@pxref{Link mode}), which does this declaration. You need to use this flag if you -are linking a shared library that will be dlopened. +are linking an application program that dlopens other modules or a +libtool library that will also be dlopened. For example, if we wanted to build a shared library, @file{libhello}, that would later be dlopened by an application, we would add @@ -1936,6 +1931,42 @@ burger$ @kbd{libtool gcc -export-dynamic -o hell-dlopener main.o} burger$ @end example +@node Dlpreopening +@section Dlpreopening + +Libtool provides special support for dlopening libtool object and +libtool library files, so that their symbols can be resolved @emph{even +on platforms without any @code{dlopen(3)} and @code{dlsym(3)} +functions.}. + +Consider the following alternative ways of loading code into your +program, in order of increasing ``laziness'': + +@enumerate 1 +@item +Linking against object files that become part of the program executable, +whether or not they are referenced. If an object file cannot be found, +then the linker refuses to create the executable. + +@item +Declaring a static library to the linker, so that it is searched at link +time in order to satisfy any undefined references in the above object +files. If the static library cannot be found, then the linker refuses +to link the executable. + +@item +Declaring a shared library to the runtime linker, so that it is searched +at runtime in order to satisfy any undefined references in the above +files. If the shared library cannot be found, then the dynamic linker +aborts the program before it runs. + +@item +Dlopening a module, so that the application can resolve its own, +dynamically-computed references. If there is an error opening the +module, then the application can +@end enumerate + + @node Finding the dlname @section Finding the correct name to dlopen @cindex Names of dynamic modules diff --git a/doc/platforms.texi b/doc/platforms.texi index b463871f..7af819ca 100644 --- a/doc/platforms.texi +++ b/doc/platforms.texi @@ -23,8 +23,8 @@ mips-sgi-irix6.2 cc -n32 0.9 ok mipsel-unknown-openbsd2.1 gcc 1.0 ok powerpc-ibm-aix4.1.4.0 xlc 1.0 ok powerpc-ibm-aix4.1.4.0 gcc 1.0 ok -rs6000-ibm-aix3.2.5 xlc 0.9h ok -rs6000-ibm-aix3.2.5 gcc 0.9h ok* +rs6000-ibm-aix3.2.5 xlc 1.0a ok +rs6000-ibm-aix3.2.5 gcc 1.0a ok* sparc-sun-linux2.1.23 gcc 0.9h ok sparc-sun-sunos4.1.4 cc 1.0 ok sparc-sun-sunos4.1.4 gcc 1.0 ok @@ -34,5 +34,6 @@ sparc-sun-solaris2.5 cc 1.0a ok sparc-sun-solaris2.5 gcc 1.0a ok -------------------------------------------------------- -* Libtool will not build shared libraries because of a bug in -GCC 2.7.2.2's collect2 linker program. +* Some versions of GCC's collect2 linker program cannot link trivial +static binaries on AIX 3. For these configurations, libtool's `-static' +flag has no effect. diff --git a/ltconfig.in b/ltconfig.in index 7c075b15..62c1fabe 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -65,8 +65,6 @@ old_LN_S="$LN_S" old_NM="$NM" old_RANLIB="$RANLIB" -test -z "$AR" && AR=ar - # Parse the command line options. args= prev= @@ -275,6 +273,9 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` old_archive_cmds='$AR cru $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + # If RANLIB is not set, then run the test. if test "${RANLIB+set}" != "set"; then result=no @@ -771,23 +772,36 @@ EOF # LINENO if { (eval echo $progname:771: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then # Now try to grab the symbols. LINENO - if { echo "$progname:773: 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 + nlist=conftest.nm + if { echo "$progname:773: eval \"$NM conftest.o | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then # Try sorting and uniquifying the output. - sort conftest.nm | uniq > conftest.nmT && mv -f conftest.nmT conftest.nm + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + wcout=`wc "$nlist" 2>/dev/null` + count=`echo "$wcout" | sed 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` + test "$wcout" = "$count" && count=-1 + else + rm -f "$nlist"T + count=-1 + fi # 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 + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then # Now generate the symbol file. - sed 's/^.* \(.*\)$/extern char \1;/' < conftest.nm > conftest.c - cat <<\EOF >> conftest.c + sed 's/^.* \(.*\)$/extern char \1;/' < "$nlist" > conftest.c + + cat <> conftest.c #if defined (__STDC__) && __STDC__ # define __ptr_t void * #else # define __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; @@ -796,7 +810,7 @@ struct { dld_preloaded_symbols[] = { EOF - sed 's/^\(.*\) \(.*\)$/ {"\1", \&\2},/' < conftest.nm >> conftest.c + sed 's/^\(.*\) \(.*\)$/ {"\1", \&\2},/' < "$nlist" >> conftest.c cat <<\EOF >> conftest.c {0}, }; @@ -817,10 +831,10 @@ EOF LIBS="$save_LIBS" fi else - echo "cannot find nm_test_func in conftest.nm" >&5 + echo "cannot find nm_test_func in $nlist" >&5 fi else - echo "cannot find nm_test_var in conftest.nm" >&5 + echo "cannot find nm_test_var in $nlist" >&5 fi else echo "$progname: failed program was:" >&5 diff --git a/ltmain.sh.in b/ltmain.sh.in index 570e968a..1ce3b3f0 100644 --- a/ltmain.sh.in +++ b/ltmain.sh.in @@ -38,6 +38,13 @@ mv="mv -f" objdir=.libs rm="rm -f" +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + if test "$LTCONFIG_VERSION" != "$VERSION"; then echo "$progname: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 @@ -972,8 +979,16 @@ if test -z "$show_help"; then # Parse the name list into a C file. echo "creating $dlsyms" if test -z "$run"; then - # Try sorting and uniquifying the output. - sort "$nlist" | uniq > "$nlist"T && mv -f "$nlist"T "$nlist" + # 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 "$wcout" | sed 's/^[ ]*\([0-9][0-9]*\).*$/\1/'` + test "$wcout" = "$count" && count=-1 + else + rm -f "$nlist"T + count=-1 + fi cat < "$dlsyms" /* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ @@ -982,13 +997,13 @@ if test -z "$show_help"; then /* External symbol declarations for the compiler. */ EOF if test -f "$nlist"; then - # Prevent the only kind of circular reference mistake we can make. - sed -e '/ dld_preloaded_symbols$/d' -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$dlsyms" + # Prevent the only kind of circular reference mistakes we can make. + sed -e '/ dld_preloaded_symbol\(s\|_count\)$/d' -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$dlsyms" else echo "/* NONE */" >> "$dlsyms" fi - cat <<\EOF >> "$dlsyms" + cat <> "$dlsyms" #if defined (__STDC__) && __STDC__ # define __ptr_t void * @@ -996,6 +1011,9 @@ EOF # define __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;