1999-03-11 Alexandre Oliva <oliva@dcc.unicamp.br>
+ * ltconfig.in: (global_symbol_pipe) extract symbol tag from the
+ output of NM too
+ (global_symbol_to_cdecl): new variable; convert the output of
+ global_symbol_pipe to valid C declarations; on HP/UX, convert
+ text symbols to function declarations
+ * libtool.m4: similar modifications
+ * doc/libtool.texi: document new variable
+ * ltmain.in: use global_symbol_to_cdecl to generate lt_dlpreopened
+ symbols; avoid extracting symbol lists from dlpreopened files
+ twice; do not filter symbols from dlpreopened libraries
+ * TODO: fixed HP/UX dlpreopening problem
+
* ltmain.in (-static, -all-static): set dlopen_self to
$dlopen_self_static regardless of link_static_flag or pic_flag
* check whether the "file" command is available
-* Tom Lane adds that HP-UX's linker, at least (I've also found this on
-AIX 4), distinguishes between global function and global variable
-references. This means that we cannot declare every symbol as `extern
-char'. Find a workaround.
-
* Inter-library dependencies should be fully tracked by libtool
and need to work for ltlibraries too. This requires looking up
installed libtool libraries for transparent support.
raw symbols followed by their C names. For example:
@example
-$ @kbd{$NM | $global_symbol_pipe}
-@var{symbol1} @var{C-symbol1}
-@var{symbol2} @var{C-symbol2}
-@var{symbol3} @var{C-symbol3}
+$ @kbd{eval "$NM progname | $global_symbol_pipe"}
+D @var{symbol1} @var{C-symbol1}
+T @var{symbol2} @var{C-symbol2}
+C @var{symbol3} @var{C-symbol3}
@dots{}
$
@end example
+
+The first column contains the symbol type (used to tell data from code
+on some platforms), but its meaning is system dependent.
+@end defvar
+
+@defvar global_symbol_to_cdecl
+A pipeline that translates the output of @var{global_symbol_pipe} into
+proper C declarations. On platforms whose linkers differentiate code
+from data, such as HP/UX, data symbols will be declared as such, and
+code symbols will be declared as functions. On platforms that don't
+care, everything is assumed to be data.
@end defvar
@defvar hardcode_action
## configuration script generated by Autoconf, you may include it under
## the same distribution terms that you use for the rest of that program.
-# serial 34 AC_PROG_LIBTOOL
+# serial 35 AC_PROG_LIBTOOL
AC_DEFUN(AC_PROG_LIBTOOL,
[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
AC_SUBST(NM)
])
-# AC_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
+# AC_SYS_NM_PARSE - Check for command to grab the raw symbol name followed
# by C symbol name from nm.
AC_DEFUN(AC_SYS_NM_PARSE,
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
# Transform the above into a raw symbol and a C symbol.
-ac_symxfrm='\1 \1'
+ac_symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+ac_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
# Define system-specific variables.
case "$host_os" in
cygwin* | mingw*)
ac_symcode='[ABCDGISTW]'
;;
+hpux*)
+ ac_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+ ;;
irix*)
ac_symcode='[BCDEGRST]'
;;
# Try without a prefix undercore, then with it.
for ac_symprfx in "" "_"; do
- # Write the raw and C identifiers.
- # Unlike in ltconfig.in, we need $ac_symprfx before $ac_symxfrm here,
- # otherwise AC_SYS_SYMBOL_UNDERSCORE will always be false
- ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]$ac_symcode[ ][ ]*$ac_symprfx$ac_sympat$/$ac_symprfx$ac_symxfrm/p'"
+ ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($ac_symcode\)[ ][ ]*\($ac_symprfx\)$ac_sympat$/$ac_symxfrm/p'"
# Check to see that the pipe works correctly.
ac_pipe_works=no
EOF
# Now generate the symbol file.
- sed 's/^.* \(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
+ eval "$ac_global_symbol_to_cdecl"' < "$ac_nlist" >> conftest.c'
cat <<EOF >> conftest.c
#if defined (__STDC__) && __STDC__
changequote([,])dnl
{
EOF
- sed 's/^\(.*\) \(.*\)$/ {"\1", (lt_ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
+ sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
cat <<\EOF >> conftest.c
{0, (lt_ptr_t) 0}
};
ac_nlist=conftest.nm
if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
# See whether the symbols have a leading underscore.
- if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
+ if egrep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
ac_cv_sys_symbol_underscore=yes
else
- if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
+ if egrep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
:
else
echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
# included in the symbol list
include_expsyms=
# exclude_expsyms can be an egrep regular expression of symbols to exclude
-# it will be wrapped by `^(' and `) ', so one must not match beginning or
+# it will be wrapped by ` (' and `)$', so one must not match beginning or
# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
# as well as any symbol that contains `d'.
exclude_expsyms=
sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
# Transform the above into a raw symbol and a C symbol.
-symxfrm='\1 \1'
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
# Define system-specific variables.
case "$host_os" in
cygwin* | mingw*)
symcode='[ABCDGISTW]'
;;
+hpux*) # Its linker distinguishes data from code symbols
+ global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+ ;;
irix*)
symcode='[BCDEGRST]'
;;
for ac_symprfx in "" "_"; do
# Write the raw and C identifiers.
- global_symbol_pipe="sed -n -e 's/^.*[ ]$symcode[ ][ ]*$ac_symprfx$sympat$/$symxfrm/p'"
+ global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'"
# Check to see that the pipe works correctly.
pipe_works=no
EOF
# Now generate the symbol file.
- sed 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> conftest.c
+ eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c'
cat <<EOF >> conftest.c
#if defined (__STDC__) && __STDC__
lt_preloaded_symbols[] =
{
EOF
- sed 's/^\(.*\) \(.*\)$/ {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
+ sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
cat <<\EOF >> conftest.c
{0, (lt_ptr_t) 0}
};
break
else
global_symbol_pipe=
+ global_symbol_to_cdecl=
fi
done
echo "$ac_t$pipe_works" 1>&6
RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \
file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \
- finish_cmds finish_eval global_symbol_pipe hardcode_libdir_flag_spec \
- hardcode_libdir_separator sys_lib_search_path_spec \
+ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
+ hardcode_libdir_flag_spec hardcode_libdir_separator \
+ sys_lib_search_path_spec \
compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
case "$var" in
# Take the output of nm and produce a listing of raw symbols and C names.
global_symbol_pipe=$global_symbol_pipe
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$global_symbol_to_cdecl
+
# This is the shared library runtime path variable.
runpath_var=$runpath_var
nlist="$objdir/${output}.nm"
if test -d $objdir; then
- $show "$rm $nlist ${nlist}T"
- $run $rm "$nlist" "${nlist}T"
+ $show "$rm $nlist ${nlist}S ${nlist}T"
+ $run $rm "$nlist" "${nlist}S" "${nlist}T"
else
$show "$mkdir $objdir"
$run $mkdir $objdir
if test "$dlself" = yes; then
$show "generating symbol list for \`$output'"
+ echo ': @PROGRAM@ ' > "$nlist"
+
# Add our own program objects to the symbol list.
progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
for arg in $progfiles; do
done
if test -n "$exclude_expsyms"; then
- $run eval 'egrep -v "^($exclude_expsyms)" "$nlist" > "$nlist"T'
+ $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
$run eval '$mv "$nlist"T "$nlist"'
fi
if test -n "$export_symbols_regex"; then
- $show "egrep -e \"$export_symbols_regex\" \"$nlist\" > \"$nlist\"T"
$run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
- $show "$mv \"$nlist\"T \"$nlist\""
$run eval '$mv "$nlist"T "$nlist"'
fi
if test -z "$export_symbols"; then
export_symbols="$objdir/$output.exp"
$run $rm $export_symbols
+ $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ else
+ $run $rm $export_symbols
+ $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$objdir/$output.exp"'
+ $run eval 'grep -f "$objdir/$output.exp" < "$nlist" > "$nlist"T'
+ $run eval 'mv "$nlist"T "$nlist"'
fi
-
- sed -e 's/^.* \(.*\)$/\1/' < "$nlist" > "$export_symbols"
fi
for arg in $dlprefiles; do
$show "extracting global C symbols from \`$arg'"
+ name=`echo "$arg" | sed -e 's%^.*/%%'`
+ $run eval 'echo ": $name " >> "$nlist"'
$run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
done
# Make sure we have at least an empty file.
test -f "$nlist" || : > "$nlist"
- if test -n "$exclude_expsyms"; then
- $run eval 'egrep -v "^($exclude_expsyms)" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
# Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- $mv "$nlist"T "$nlist"
+ if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+ :
else
- $rm "$nlist"T
+ grep -v "^: " < "$nlist" > "$nlist"S
fi
if test -n "$exclude_expsyms"; then
- egrep -v "^($exclude_expsyms) " "$nlist" > "$nlist"T
- $mv "$nlist"T "$nlist"
+ egrep -v " ($exclude_expsyms)$" "$nlist"S > "$nlist"T
+ $mv "$nlist"T "$nlist"S
fi
- if test -f "$nlist"; then
- sed -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$output_objdir/$dlsyms"
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
else
echo '/* NONE */' >> "$output_objdir/$dlsyms"
fi
{\
"
- if test "$dlself" = yes; then
- # First entry is the program itself
- echo >> "$output_objdir/$dlsyms" "\
- {\"@PROGRAM@\", (lt_ptr_t) 0},"
- sed 's/^\(.*\)/ {"\1", (lt_ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
- fi
-
- for arg in $dlprefiles; do
- name=`echo "$arg" | sed -e 's%^.*/%%'`
- echo >> "$output_objdir/$dlsyms" "\
- {\"$name\", (lt_ptr_t) 0},"
- eval "$NM $arg | $global_symbol_pipe > '$nlist'"
-
- if test -f "$nlist"; then
- if test -n "$exclude_expsyms"; then
- egrep -v "^($exclude_expsyms) " "$nlist" > "$nlist"T
- $mv "$nlist"T "$nlist"
- fi
-
- sed 's/^\(.*\) \(.*\)$/ {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
- else
- echo '/* NONE */' >> "$output_objdir/$dlsyms"
- fi
- done
+ sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \
+ -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \
+ < "$nlist" >> "$output_objdir/$dlsyms"
$echo >> "$output_objdir/$dlsyms" "\
{0, (lt_ptr_t) 0}