* autogen: libltdl needs autoheader

* demo/Makefile.am: renamed hell.debug to hell.static
  (we're demonstrating static linking, not debugging)
* tests/demo*: ditto
* doc/libtool.texi (libltdl): documented new lt_dlopen(NULL)
  feature
* libltdl/acconfig.h: required for config.h
* libltdl/configure.in: use config.h
* libltdl/ltdl.c: use config.h, support lt_dlopen(NULL)
  (returns a handle for the program itself)
* ltconfig.in: minor reformatting
* ltmain.in: in lt_preloaded_symbols always define
  the program's symbols first, for -export-dynamic list all
  program symbols together, -export-symbols was broken for
  programs, minor reformatting
* mdemo/Makefile.am: renamed mdemo.debug to mdemo.static
* tests/mdemo*: ditto, mdemo.test was completely broken
This commit is contained in:
Thomas Tanner 1999-02-11 23:48:25 +00:00
parent ebd5366e02
commit 17915a088c
18 changed files with 154 additions and 75 deletions

View File

@ -1,3 +1,23 @@
1999-02-11 Thomas Tanner <tanner@gmx.de>
* autogen: libltdl needs autoheader
* demo/Makefile.am: renamed hell.debug to hell.static
(we're demonstrating static linking, not debugging)
* tests/demo*: ditto
* doc/libtool.texi (libltdl): documented new lt_dlopen(NULL)
feature
* libltdl/acconfig.h: required for config.h
* libltdl/configure.in: use config.h
* libltdl/ltdl.c: use config.h, support lt_dlopen(NULL)
(returns a handle for the program itself)
* ltconfig.in: minor reformatting
* ltmain.in: in lt_preloaded_symbols always define
the program's symbols first, for -export-dynamic list all
program symbols together, -export-symbols was broken for
programs, minor reformatting
* mdemo/Makefile.am: renamed mdemo.debug to mdemo.static
* tests/mdemo*: ditto, mdemo.test was completely broken
1999-02-10 Alexandre Oliva <oliva@dcc.unicamp.br>
* ltconfig.in (irix5*, irix6*, osf3*, osf4*): do not use

View File

@ -19,6 +19,7 @@ for sub in demo depdemo libltdl mdemo cdemo; do
rm -f acinclude.m4
cp ../libtool.m4 acinclude.m4
aclocal
autoheader
automake --gnits --add-missing
autoconf
cd ..

View File

@ -20,16 +20,16 @@ else
BUILD_helldl =
endif
bin_PROGRAMS = hell hell.debug $(BUILD_helldl)
bin_PROGRAMS = hell hell.static $(BUILD_helldl)
# Build hell from main.c and libhello.la
hell_SOURCES = main.c
hell_LDADD = libhello.la
# Create an easier-to-debug version of hell.
hell_debug_SOURCES = main.c
hell_debug_LDADD = libhello.la
hell_debug_LDFLAGS = $(STATIC)
# Create a statically linked version of hell.
hell_static_SOURCES = main.c
hell_static_LDADD = libhello.la
hell_static_LDFLAGS = $(STATIC)
if BINARY_HELLDL

View File

@ -2612,7 +2612,8 @@ Return 0 on success, otherwise the number of errors.
@deftypefun lt_dlhandle lt_dlopen (const char *@var{filename})
Open the module with the file name @var{filename} and return a
handle for it. @code{lt_dlopen} is able to open libtool dynamic
modules, preloaded static modules and native dynamic libraries.
modules, preloaded static modules, the program itself and
native dynamic libraries.
Unresolved symbols in the module are resolved using its dependency
libraries and previously dlopened modules. If the executable using this
@ -2621,6 +2622,10 @@ symbols in the executable will also be used to resolve references in the
module. Libltdl tries to resolve the symbols immediately and returns
@code{NULL} if that fails.
If @var{filename} is NULL @code{lt_dlopen} will return a handle
for the program itself, which can be used to access its symbols
if it was linked with @code{-export-dynamic}.
If libltdl cannot find the library and the file name @var{filename} does
not have a directory component it will additionally search in the
following search paths for the module (in the order as follows):

View File

@ -2,6 +2,7 @@ dnl Process this file with autoconf to create configure.
dnl Initialize the libltdl package.
AC_INIT(ltdl.c)
AM_INIT_AUTOMAKE(libltdl,1.0,-)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE

View File

@ -20,6 +20,10 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define _LTDL_COMPILE_
#if HAVE_CONFIG_H
#include <config.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif
@ -608,14 +612,19 @@ presym_open (handle, filename)
{
lt_dlsymlists_t *lists = preloaded_symbols;
if (!filename) {
last_error = file_not_found_error;
return 1;
}
if (!lists) {
last_error = no_symbols_error;
return 1;
}
if (!filename) {
if (!default_preloaded_symbols) {
last_error = file_not_found_error;
return 1;
} else {
handle->handle = (lt_ptr_t) default_preloaded_symbols;
return 0;
}
}
while (lists) {
const lt_dlsymlist *syms = lists->syms;
@ -765,8 +774,14 @@ tryall_dlopen (handle, filename)
/* check whether the module was already opened */
cur = handles;
while (cur && strcmp(cur->filename, filename))
while (cur) {
if (!cur->filename && !filename)
break;
if (cur->filename && filename &&
strcmp(cur->filename, filename))
break;
cur = cur->next;
}
if (cur) {
cur->usage++;
*handle = cur;
@ -774,18 +789,22 @@ tryall_dlopen (handle, filename)
}
cur = *handle;
cur->filename = strdup(filename);
if (!cur->filename) {
last_error = memory_error;
return 1;
}
if (filename) {
cur->filename = strdup(filename);
if (!cur->filename) {
last_error = memory_error;
return 1;
}
} else
cur->filename = 0;
while (type) {
if (type->lib_open(cur, filename) == 0)
break;
type = type->next;
}
if (!type) {
free(cur->filename);
if (cur->filename)
free(cur->filename);
return 1;
}
cur->type = type;
@ -1026,8 +1045,20 @@ lt_dlopen (filename)
char *dir = 0, *name = 0;
if (!filename) {
last_error = file_not_found_error;
return 0;
handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
if (!handle) {
last_error = memory_error;
return 0;
}
handle->usage = 0;
newhandle = handle;
if (tryall_dlopen(handle, 0) != 0) {
free(newhandle);
return 0;
}
if (newhandle != handle)
free(newhandle);
return handle;
}
basename = strrchr(filename, '/');
if (basename) {

View File

@ -1128,13 +1128,13 @@ else
allow_undefined_flag=
if test "$with_gcc" = yes; then
if strings `${CC} -print-prog-name=collect2` | \
grep resolve_lib_name >/dev/null
grep resolve_lib_name >/dev/null
then
# We have reworked collect2
hardcode_direct=yes
# We have reworked collect2
hardcode_direct=yes
else
# We have old collect2
hardcode_direct=unsupported
# We have old collect2
hardcode_direct=unsupported
fi
archive_cmds='$CC -shared ${wl}-bnoentry -o $objdir/$soname $libobjs $deplibs $linkopts'
else

View File

@ -431,14 +431,14 @@ compiler."
# All platforms use -DPIC, to notify preprocessed assembler code.
command="$base_compile $pic_flag -DPIC $srcfile"
if test "$build_old_libs" = yes; then
lo_libobj="$libobj"
lo_libobj="$libobj"
dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$dir" = "X$libobj"; then
dir="$objdir"
else
dir="$dir/$objdir"
fi
libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
if test -d "$dir"; then
$show "$rm $libobj"
@ -501,7 +501,7 @@ compiler."
# If we have no pic_flag, then copy the object into place and finish.
if test -z "$pic_flag" && test "$build_old_libs" = yes; then
# Rename the .lo from within objdir to obj
if test -f $obj; then
if test -f $obj; then
$show $rm $obj
$run $rm $obj
fi
@ -580,8 +580,8 @@ compiler."
# Create an invalid libtool object if no PIC, so that we do not
# accidentally link it into a program.
if test "$build_libtool_libs" != yes; then
$show "echo timestamp > $libobj"
$run eval "echo timestamp > \$libobj" || exit $?
$show "echo timestamp > $libobj"
$run eval "echo timestamp > \$libobj" || exit $?
else
# Move the .lo from within objdir
$show "$mv $libobj $lo_libobj"
@ -748,6 +748,7 @@ compiler."
exit 1
fi
prev=
continue
;;
release)
release="-$arg"
@ -1390,8 +1391,8 @@ compiler."
# How the heck are we supposed to write a wrapper for a shared library?
if test -n "$link_against_libtool_libs"; then
$echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
exit 1
$echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
exit 1
fi
if test -n "$dlfiles$dlprefiles"; then
@ -1716,7 +1717,7 @@ EOF
# but so what?
potlib="$potent_lib"
while test -h "$potlib" 2>/dev/null; do
potliblink=`ls -ld $potlib | sed 's/.* -> //'`
potliblink=`ls -ld $potlib | sed 's/.* -> //'`
case "$potliblink" in
/*) potlib="$potliblink";;
*) potlib=`$echo "X$potlib" \
@ -1822,13 +1823,13 @@ EOF
# Ensure that we have .o objects for linkers which dislike .lo
# (e.g. aix) incase we are running --disable-static
for obj in $libobjs; do
oldobj=`echo $obj | $Xsed -e "$lo2o"`
test -f $oldobj || ${LN_S} $obj $oldobj
done
for obj in $libobjs; do
oldobj=`echo $obj | $Xsed -e "$lo2o"`
test -f $oldobj || ${LN_S} $obj $oldobj
done
# Use standard objects if they are pic
test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
if test -n "$whole_archive_flag_spec"; then
if test -n "$convenience"; then
@ -2086,11 +2087,6 @@ EOF
case "$dlsyms" in
"") ;;
*.c)
if test "$export_dynamic" = yes && test -z "$export_symbols"; then
# Add our own program objects to the preloaded list.
dlprefiles=`$echo "X$objs $dlprefiles" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
fi
# Discover the nlist of each of the dlfiles.
nlist="$objdir/${output}.nm"
@ -2123,8 +2119,17 @@ extern \"C\" {
/* External symbol declarations for the compiler. */\
"
if test "$export_dynamic" = yes && test -n "$export_symbols"; then
sed -e 's/^\(.*\)/\1 \1/' < "$export_symbols" > "$nlist"
if test "$export_dynamic" = yes; then
if test -n "$export_symbols"; then
$run eval 'sed -e "s/^\(.*\)/\1 \1/" < "$export_symbols" > "$nlist"'
else
# Add our own program objects to the preloaded list.
progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
for arg in $progfiles; do
$show "extracting global C symbols from \`$arg'"
$run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
done
fi
fi
for arg in $dlprefiles; do
@ -2169,10 +2174,24 @@ lt_preloaded_symbols[] =
{\
"
if test "$export_dynamic" = yes && test -n "$export_symbols"; then
echo >> "$output_objdir/$dlsyms" "\
# First entry is always the program itself
echo >> "$output_objdir/$dlsyms" "\
{\"${output}\", (lt_ptr_t) 0},"
sed 's/^\(.*\)/ {"\1", (lt_ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
if test "$export_dynamic" = yes; then
if test -n "$export_symbols"; then
sed 's/^\(.*\)/ {"\1", (lt_ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
else
$rm "$nlist"
for arg in $progfiles; do
eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
done
if test -f "$nlist"; then
sed 's/^\(.*\) \(.*\)$/ {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
else
echo '/* NONE */' >> "$output_objdir/$dlsyms"
fi
fi
fi
for arg in $dlprefiles; do
@ -2284,7 +2303,7 @@ static const void *lt_preloaded_setup() {
fi
if test -n "$runpath_var"; then
if test -n "$perm_rpath"; then
if test -n "$perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $perm_rpath; do
@ -2292,7 +2311,7 @@ static const void *lt_preloaded_setup() {
done
compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command"
fi
if test -n "$finalize_perm_rpath"; then
if test -n "$finalize_perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $finalize_perm_rpath; do

View File

@ -16,7 +16,7 @@ libfoo2_la_LDFLAGS = $(LIBADD_M) -module
noinst_HEADERS = foo.h
bin_PROGRAMS = mdemo mdemo.debug
bin_PROGRAMS = mdemo mdemo.static
../libltdl/libltdl.la: ../libtool ../libltdl/libtool \
$(srcdir)/../libltdl/ltdl.c $(srcdir)/../libltdl/ltdl.h
@ -33,8 +33,8 @@ mdemo_LDFLAGS = -export-dynamic ## FIXME: remove this when libtool and libltdl
mdemo_LDADD = ../libltdl/libltdl.la "-dlopen" foo1.la "-dlopen" libfoo2.la
mdemo_DEPENDENCIES = ../libltdl/libltdl.la foo1.la libfoo2.la
# Create an easier-to-debug version of mdemo.
mdemo_debug_SOURCES = $(mdemo_SOURCES)
mdemo_debug_LDFLAGS = $(STATIC) $(mdemo_LDFLAGS)
mdemo_debug_LDADD = $(mdemo_LDADD)
mdemo_debug_DEPENDENCIES = $(mdemo_DEPENDENCIES)
# Create a statically linked version of mdemo.
mdemo_static_SOURCES = $(mdemo_SOURCES)
mdemo_static_LDFLAGS = $(STATIC) $(mdemo_LDFLAGS)
mdemo_static_LDADD = $(mdemo_LDADD)
mdemo_static_DEPENDENCIES = $(mdemo_DEPENDENCIES)

View File

@ -20,9 +20,9 @@ fi
echo "Executing uninstalled programs in ../demo"
status=0
if ../demo/hell.debug| grep 'Welcome to GNU Hell'; then :
if ../demo/hell.static| grep 'Welcome to GNU Hell'; then :
else
echo "$0: cannot execute ../demo/hell.debug" 1>&2
echo "$0: cannot execute ../demo/hell.static" 1>&2
status=1
fi

View File

@ -25,9 +25,9 @@ $make install || exit 1
echo "= Executing installed programs"
status=0
if $prefix/bin/hell.debug | grep 'Welcome to GNU Hell'; then :
if $prefix/bin/hell.static | grep 'Welcome to GNU Hell'; then :
else
echo "$0: cannot execute $prefix/bin/hell.debug" 1>&2
echo "$0: cannot execute $prefix/bin/hell.static" 1>&2
status=1
fi

View File

@ -55,7 +55,8 @@ fi
if $prefix/bin/hell | grep 'GNU Hell'; then :
else
echo "$0: warning: cannot execute $prefix/bin/hell" 1>&2
echo "$0: cannot execute $prefix/bin/hell" 1>&2
exit 1
fi
echo "= Running make uninstall in ../demo"

View File

@ -1,5 +1,5 @@
#! /bin/sh
# mdemo-conf.test - try configuring the ../libltdl and ../mdemo subdirectories
# mdemo-conf.test - try configuring the ../mdemo subdirectory
# Test script header.
need_prefix=yes

View File

@ -20,9 +20,9 @@ fi
echo "Executing uninstalled programs in ../mdemo"
status=0
if ../mdemo/mdemo.debug ../mdemo/foo1.la ../mdemo/libfoo2.la; then :
if ../mdemo/mdemo.static ../mdemo/foo1.la ../mdemo/libfoo2.la; then :
else
echo "$0: cannot execute ../mdemo/mdemo.debug" 1>&2
echo "$0: cannot execute ../mdemo/mdemo.static" 1>&2
status=1
fi

View File

@ -26,9 +26,9 @@ $make install || exit 1
echo "= Executing installed programs"
status=0
if $prefix/bin/mdemo.debug $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
if $prefix/bin/mdemo.static $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
else
echo "$0: cannot execute $prefix/bin/mdemo.debug" 1>&2
echo "$0: cannot execute $prefix/bin/mdemo.static" 1>&2
status=1
fi

View File

@ -1,5 +1,5 @@
#! /bin/sh
# mdemo-conf.test - try configuring the ../libltdl and ../mdemo subdirectories
# mdemo-conf.test - try configuring the ../mdemo subdirectory
# Test script header.
need_prefix=yes

View File

@ -1,5 +1,5 @@
#! /bin/sh
# mdemo-conf.test - try configuring the ../libltdl and ../mdemo subdirectories
# mdemo-conf.test - try configuring the ../mdemo subdirectory
# Test script header.
need_prefix=yes

View File

@ -31,15 +31,15 @@ make || exit 1
# Try running the program.
echo "= Executing uninstalled programs"
if ./hell.debug | grep 'GNU Hell'; then :
if ./mdemo.static foo1.la libfoo2.la; then :
else
echo "$0: cannot execute ./hell.debug" 1>&2
echo "$0: cannot execute ./mdemo.static" 1>&2
exit 1
fi
if ./hell | grep 'GNU Hell'; then :
if ./mdemo foo1.la libfoo2.la; then :
else
echo "$0: cannot execute ./hell" 1>&2
echo "$0: cannot execute ./mdemo" 1>&2
exit 1
fi
@ -47,15 +47,16 @@ echo "= Running make install in ../mdemo"
make install || exit 1
echo "= Executing installed programs"
if $prefix/bin/hell.debug | grep 'GNU Hell'; then :
if $prefix/bin/mdemo.static $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
else
echo "$0: cannot execute $prefix/bin/hell.debug" 1>&2
echo "$0: cannot execute $prefix/bin/mdemo.static" 1>&2
exit 1
fi
if $prefix/bin/hell | grep 'GNU Hell'; then :
if $prefix/bin/mdemo $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
else
echo "$0: warning: cannot execute $prefix/bin/hell" 1>&2
echo "$0: cannot execute $prefix/bin/mdemo" 1>&2
exit 1
fi
echo "= Running make uninstall in ../mdemo"