libbacktrace: support MiniDebugInfo

libbacktrace/ChangeLog:
	PR libbacktrace/93608
	Add support for MiniDebugInfo.
	* elf.c (struct elf_view): Define.  Replace most uses of
	backtrace_view with elf_view.
	(elf_get_view): New static functions.  Replace most calls of
	backtrace_get_view with elf_get_view.
	(elf_release_view): New static functions.  Replace most calls of
	backtrace_release_view with elf_release_view.
	(elf_uncompress_failed): Rename from elf_zlib_failed.  Change all
	callers.
	(LZMA_STATES, LZMA_POS_STATES, LZMA_DIST_STATES): Define.
	(LZMA_DIST_SLOTS, LZMA_DIST_MODEL_START): Define.
	(LZMA_DIST_MODEL_END, LZMA_FULL_DISTANCES): Define.
	(LZMA_ALIGN_SIZE, LZMA_LEN_LOW_SYMBOLS): Define.
	(LZMA_LEN_MID_SYMBOLS, LZMA_LEN_HIGH_SYMBOLS): Define.
	(LZMA_LITERAL_CODERS_MAX, LZMA_LITERAL_CODER_SIZE): Define.
	(LZMA_PROB_IS_MATCH_LEN, LZMA_PROB_IS_REP_LEN): Define.
	(LZMA_PROB_IS_REP0_LEN, LZMA_PROB_IS_REP1_LEN): Define.
	(LZMA_PROB_IS_REP2_LEN, LZMA_PROB_IS_REP0_LONG_LEN): Define.
	(LZMA_PROB_DIST_SLOT_LEN, LZMA_PROB_DIST_SPECIAL_LEN): Define.
	(LZMA_PROB_DIST_ALIGN_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_MATCH_LEN_LOW_LEN): Define.
	(LZMA_PROB_MATCH_LEN_MID_LEN): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_REP_LEN_LOW_LEN): Define.
	(LZMA_PROB_REP_LEN_MID_LEN): Define.
	(LZMA_PROB_REP_LEN_HIGH_LEN): Define.
	(LZMA_PROB_LITERAL_LEN): Define.
	(LZMA_PROB_IS_MATCH_OFFSET, LZMA_PROB_IS_REP_OFFSET): Define.
	(LZMA_PROB_IS_REP0_OFFSET, LZMA_PROB_IS_REP1_OFFSET): Define.
	(LZMA_PROB_IS_REP2_OFFSET): Define.
	(LZMA_PROB_IS_REP0_LONG_OFFSET): Define.
	(LZMA_PROB_DIST_SLOT_OFFSET): Define.
	(LZMA_PROB_DIST_SPECIAL_OFFSET): Define.
	(LZMA_PROB_DIST_ALIGN_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_MID_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_REP_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_REP_LEN_MID_OFFSET): Define.
	(LZMA_PROB_REP_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_LITERAL_OFFSET): Define.
	(LZMA_PROB_TOTAL_COUNT): Define.
	(LZMA_IS_MATCH, LZMA_IS_REP, LZMA_IS_REP0): Define.
	(LZMA_IS_REP1, LZMA_IS_REP2, LZMA_IS_REP0_LONG): Define.
	(LZMA_DIST_SLOT, LZMA_DIST_SPECIAL, LZMA_DIST_ALIGN): Define.
	(LZMA_MATCH_LEN_CHOICE, LZMA_MATCH_LEN_CHOICE2): Define.
	(LZMA_MATCH_LEN_LOW, LZMA_MATCH_LEN_MID): Define.
	(LZMA_MATCH_LEN_HIGH, LZMA_REP_LEN_CHOICE): Define.
	(LZMA_REP_LEN_CHOICE2, LZMA_REP_LEN_LOW): Define.
	(LZMA_REP_LEN_MID, LZMA_REP_LEN_HIGH, LZMA_LITERAL): Define.
	(elf_lzma_varint): New static function.
	(elf_lzma_range_normalize): New static function.
	(elf_lzma_bit, elf_lzma_integer): New static functions.
	(elf_lzma_reverse_integer): New static function.
	(elf_lzma_len, elf_uncompress_lzma_block): New static functions.
	(elf_uncompress_lzma): New static function.
	(backtrace_uncompress_lzma): New function.
	(elf_add): Add memory and memory_size parameters.  Change all
	callers.  Look for .gnu_debugdata section, and, if found,
	decompress it and use it for symbols and debug info.  Permit the
	descriptor parameter to be -1.
	* internal.h (backtrace_uncompress_lzma): Declare.
	* mtest.c: New file.
	* xztest.c: New file.
	* configure.ac: Check for nm, xz, and comm programs.  Check for
	liblzma library.
	(HAVE_MINIDEBUG): Define.
	* Makefile.am (mtest_SOURCES): Define.
	(mtest_CFLAGS, mtest_LDADD): Define.
	(TESTS): Add mtest_minidebug if HAVE_MINIDEBUG.
	(%_minidebug): New pattern rule, if HAVE_MINIDEBUG.
	(xztest_SOURCES, xztest_CFLAGS, xztest_LDADD): Define.
	(xztest_alloc_SOURCES, xztest_alloc_CFLAGS): Define
	(xztest_alloc_LDADD): Define.
	(BUILDTESTS): Add mtest, xztest, xztest_alloc.
	(CLEANFILES): Add files created by minidebug pattern.
	(btest.lo): Correct INCDIR reference.
	(mtest.lo, xztest.lo, ztest.lo): New targets.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* Makefile.in: Regenerate.

Close #38
This commit is contained in:
Ian Lance Taylor
2020-09-14 14:01:56 -07:00
parent 2f5efbfa32
commit 77bcaa99f5
9 changed files with 2911 additions and 164 deletions

224
configure vendored
View File

@@ -635,6 +635,16 @@ LTLIBOBJS
LIBOBJS
NATIVE_FALSE
NATIVE_TRUE
HAVE_LIBLZMA_FALSE
HAVE_LIBLZMA_TRUE
HAVE_MINIDEBUG_FALSE
HAVE_MINIDEBUG_TRUE
HAVE_COMM_FALSE
HAVE_COMM_TRUE
COMM
HAVE_XZ_FALSE
HAVE_XZ_TRUE
XZ
HAVE_DSYMUTIL_FALSE
HAVE_DSYMUTIL_TRUE
HAVE_OBJCOPY_DEBUGLINK_FALSE
@@ -802,7 +812,8 @@ LIBS
CPPFLAGS
CPP
OBJCOPY
DSYMUTIL'
DSYMUTIL
NM'
# Initialize some variables set by options.
@@ -1456,6 +1467,7 @@ Some influential environment variables:
CPP C preprocessor
OBJCOPY location of objcopy
DSYMUTIL location of dsymutil
NM location of nm
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -11269,7 +11281,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11272 "configure"
#line 11284 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11375,7 +11387,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11378 "configure"
#line 11390 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12944,6 +12956,196 @@ else
fi
# Extract the first word of "nm", so it can be a program name with args.
set dummy nm; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_NM+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$NM"; then
ac_cv_prog_NM="$NM" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_NM="nm"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
NM=$ac_cv_prog_NM
if test -n "$NM"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5
$as_echo "$NM" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Extract the first word of "xz", so it can be a program name with args.
set dummy xz; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_XZ+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$XZ"; then
ac_cv_prog_XZ="$XZ" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_XZ="xz"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
XZ=$ac_cv_prog_XZ
if test -n "$XZ"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $XZ" >&5
$as_echo "$XZ" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$XZ" != ""; then
HAVE_XZ_TRUE=
HAVE_XZ_FALSE='#'
else
HAVE_XZ_TRUE='#'
HAVE_XZ_FALSE=
fi
# Extract the first word of "comm", so it can be a program name with args.
set dummy comm; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_COMM+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$COMM"; then
ac_cv_prog_COMM="$COMM" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_COMM="comm"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
COMM=$ac_cv_prog_COMM
if test -n "$COMM"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5
$as_echo "$COMM" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$COMM" != ""; then
HAVE_COMM_TRUE=
HAVE_COMM_FALSE='#'
else
HAVE_COMM_TRUE='#'
HAVE_COMM_FALSE=
fi
if test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != ""; then
HAVE_MINIDEBUG_TRUE=
HAVE_MINIDEBUG_FALSE='#'
else
HAVE_MINIDEBUG_TRUE='#'
HAVE_MINIDEBUG_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_auto_decoder in -llzma" >&5
$as_echo_n "checking for lzma_auto_decoder in -llzma... " >&6; }
if ${ac_cv_lib_lzma_lzma_auto_decoder+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llzma $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char lzma_auto_decoder ();
int
main ()
{
return lzma_auto_decoder ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lzma_lzma_auto_decoder=yes
else
ac_cv_lib_lzma_lzma_auto_decoder=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_auto_decoder" >&5
$as_echo "$ac_cv_lib_lzma_lzma_auto_decoder" >&6; }
if test "x$ac_cv_lib_lzma_lzma_auto_decoder" = xyes; then :
$as_echo "#define HAVE_LIBLZMA 1" >>confdefs.h
fi
if test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes; then
HAVE_LIBLZMA_TRUE=
HAVE_LIBLZMA_FALSE='#'
else
HAVE_LIBLZMA_TRUE='#'
HAVE_LIBLZMA_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tests can run" >&5
$as_echo_n "checking whether tests can run... " >&6; }
if ${libbacktrace_cv_sys_native+:} false; then :
@@ -13160,6 +13362,22 @@ if test -z "${HAVE_DSYMUTIL_TRUE}" && test -z "${HAVE_DSYMUTIL_FALSE}"; then
as_fn_error $? "conditional \"HAVE_DSYMUTIL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_XZ_TRUE}" && test -z "${HAVE_XZ_FALSE}"; then
as_fn_error $? "conditional \"HAVE_XZ\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_COMM_TRUE}" && test -z "${HAVE_COMM_FALSE}"; then
as_fn_error $? "conditional \"HAVE_COMM\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_MINIDEBUG_TRUE}" && test -z "${HAVE_MINIDEBUG_FALSE}"; then
as_fn_error $? "conditional \"HAVE_MINIDEBUG\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBLZMA_TRUE}" && test -z "${HAVE_LIBLZMA_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBLZMA\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NATIVE_TRUE}" && test -z "${NATIVE_FALSE}"; then
as_fn_error $? "conditional \"NATIVE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5