Ian Lance Taylor
0b9b49cf4a
libbacktrace: make backtrace_syminfo_to_full_callback_moredata static
...
* elf.c (backtrace_syminfo_to_full_callback_moredata): Move to
elf.c from fileline.c and make static.
* fileline.c (backtrace_syminfo_to_full_callback_moredata):
Moved to elf.c.
* internal.h (backtrace_syminfo_to_full_callback_moredata): Don't
declare.
2026-09-03 12:30:32 -07:00
Ian Lance Taylor
735c54d9dc
libbacktrace: handle MOREDATA correctly without debug info
...
Based on patch from Andi Kleen.
* elf.c (elf_nodebug): Handle state->moredata.
* fileline.c (backtrace_syminfo_to_full_callback): Remove
incorrect comment about MOREDATA.
(backtrace_syminfo_to_full_callback_moredata): New function.
* internal.h (backtrace_syminfo_to_full_callback_moredata):
Declare.
* strippedtest.c: New file.
* configure.ac: check whether objcopy supports --strip-debug.
* Makefile.am (strippedtest_SOURCES): New variable.
(strippedtest_CFLAGS, strippedtest_LDFLAGS): Likewise.
(strippedtest_LDADD): Likewise.
(check_PROGRAMS): Add strippedtest.
(MAKETESTS): Add strippedtest_stripped
(%_stripped): New rule.
* configure, Makefile.in: Regenerate.
2026-09-01 15:17:39 -07:00
Ian Lance Taylor
6f8310e238
libbacktrace: support returning discriminator field
...
Based on patch from Andi Kleen.
* backtrace.h (backtrace_create_state): Rewrite comment to change
threaded parameter to flags.
(backtrace_full_callback, backtrace_syminfo_callback): Document
behavior change if moredata flag is set.
(struct backtrace_moredata): Define.
* backtrace-supported.h.in (BACKTRACE_SUPPORTS_MOREDATA): Define.
* internal.h (struct backtrace_state): Add moredata field.
(BACKTRACE_MOREDATA_VERSION): Define.
* state.c (backtrace_create_state): Change threaded parameter to
flags. Set state moredata field based on flags.
* dwarf.c (struct line): Add disc field.
(struct function): Add caller_disc field.
(call_callback): New static function.
(add_line): Add disc parameter. Change all callers. Store disc
in new line value.
(read_line_program): Track discriminator value.
(read_line_info): Initialize disc field in final line entry.
(read_function_entry): Handle DW_AT_GNU_discriminator.
(report_inlined_functions): Add disc parameter. Change all
callers. Call call_callback rather than calling callback
directly.
(dwarf_lookup_pc): Handle inlined discriminators. Call
call_callback rather than calling callback directly.
(dwarf_fileline): Call call_callback rather than calling callback
directly.
* elf.c (elf_syminfo): Pass moredata if requested.
* macho.c (macho_syminfo): Likewise.
* pecoff.c (coff_syminfo): Likewise.
* xcoff.c (xcoff_syminfo): Likewise.
(xcoff_lookup_pc): Likewise.
* backtrace.c: #include <string.h>.
(unwind): Pass moredata if requested.
* unknown.c: #include <string.h>.
(unknown_fileline): Pass moredata if requested.
* fileline.c (backtrace_syminfo_to_full_callback): Add comment
about moredata.
* mdtest.c: New test file.
* Makefile.am (mdtest_SOURCES): Define.
(mdtest_CFLAGS, mdtest_LDFLAGS, mdtest_LDADD): Define.
(BUILDTESTS): Add mdtest.
* Makefile.in: Regenerate.
2026-07-06 12:42:21 -07:00
Ian Lance Taylor
5f4a6d4941
libbacktrace: set table field for zstd RLE sequence
...
Patch from Ivan Molodetskikh.
* elf.c (elf_zstd_unpack_seq_decode): Set table field for RLE
sequence.
* zstdtest.c (tests): Add rle-sequence-tables test.
2026-06-27 09:09:58 -07:00
Ian Lance Taylor
058d953bb7
libbacktrace: support window size in zstd decompression
...
Reportedly this occurs on AerynOS.
Patch from Ivan Molodetskikh.
* elf.c (elf_zstd_decompress_frame): Support a compressed block
that does not set the single segment flag.
* zstdtest.c (tests): Add tests without single segment.
2026-06-27 08:53:22 -07:00
Ian Lance Taylor
549b81b43b
libbacktrace: support compressed block with no sequences
...
* elf.c (elf_zstd_decompress_frame): Support a compressed block
with no sequences, only literals.
Fixes #164
2026-06-01 21:39:35 -07:00
Dhruv Chawla
9477521bc1
libbacktrace: Fix typos in various files
...
Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com >
libbacktrace/ChangeLog:
* allocfail.sh: Fix typos.
* elf.c (elf_fetch_bits): Likewise.
2026-06-01 21:36:45 -07:00
Ian Lance Taylor
96664e69b1
libbacktrace: support multiple zstd frames
...
Based on patch by GitHub user ofats.
* elf.c (elf_zstd_decompress_frame): New static function,
broken out of elf_zstd_decompress.
(elf_zstd_decompress): Call elf_zstd_decompress_frame in a loop.
* zstdtest.c (test_large): Compress the file in chunks.
2026-05-03 18:30:11 -07:00
Jakub Jelinek
42962d2cfb
Update copyright years.
2026-05-03 18:21:13 -07:00
Jakub Jelinek
bdd324c192
Update copyright years.
2026-05-03 18:20:27 -07:00
Ian Lance Taylor
b9e40069c0
libbacktrace: use correct names in #undef of ELF macros
...
Patch from Joseph Koshy.
* elf.c (ELFMAGn): In #undef rename from ELF_MAGn.
2025-11-06 11:30:33 -08:00
Ian Lance Taylor
0034e33946
libbacktrace: add cast to avoid undefined shift
...
Patch from pgerell@github.
* elf.c (elf_uncompress_lzma_block): Add casts to avoid
potentially shifting a value farther than its type size.
2025-02-10 15:04:43 -08:00
Ian Lance Taylor
78af4ffa26
libbacktrace: add casts to avoid undefined shifts
...
Patch from pgerell@github.
* elf.c (elf_fetch_bits): Add casts to avoid potentially shifting
a value farther than its type size.
(elf_fetch_bits_backward): Likewise.
(elf_uncompress_lzma_block): Likewise.
(elf_uncompress_lzma): Likewise.
2025-01-30 15:24:13 -08:00
Ian Lance Taylor
7e2b7da3d6
libbacktrace: use __has_attribute for fallthrough
...
Also convert some FALLTHROUGH comments to ATTRIBUTE_FALLTHROUGH.
* internal.h: Use __has_attribute to check for fallthrough
attribute.
* elf.c (elf_zstd_decompress): Use ATTRIBUTE_FALLTHROUGH rather
than a FALLTHROUGH comment.
2024-07-18 11:37:33 -07:00
Ian Lance Taylor
1dd5c408fe
libbacktrace: support FDPIC
...
Based on patch by Max Filippov.
* internal.h: If FDPIC, #include <link.h> and/or <sys/link.h>.
(libbacktrace_using_fdpic): Define.
(struct libbacktrace_base_address): Define.
(libbacktrace_add_base): Define.
(backtrace_dwarf_add): Change base_address to struct
libbacktrace_base_address.
* dwarf.c (struct dwarf_data): Change base_address to struct
libbacktrace_base_address.
(add_ranges, find_address_ranges, build_ddress_map): Likewise.
(build_dwarf_data, build_dwarf_add): Likewise.
(add_low_high_range): Change base_address to struct
libbacktrace_base_address. Use libbacktrace_add_base.
(add_ranges_from_ranges, add_ranges_from_rnglists): Likewise.
(add_line): Use libbacktrace_add_base.
* elf.c (elf_initialize_syminfo): Change base_address to struct
libbacktrace_base_address. Use libbacktrace_add_base.
(elf_add): Change base_address to struct
libbacktrace_base_address.
(phdr_callback): Likewise. Initialize base_address.m.
(backtrace_initialize): If using FDPIC, don't call elf_add with
main executable; always use dl_iterate_phdr.
* macho.c (macho_add_symtab): Change base_address to struct
libbacktrace_base_address. Use libbacktrace_add_base.
(macho_syminfo): Change base_address to struct
libbacktrace_base_address.
(macho_add_fat, macho_add_dsym, macho_add): Likewise.
(backtrace_initialize): Likewise. Initialize base_address.m.
* pecoff.c (coff_initialize_syminfo): Change base_address to
struct libbacktrace_base_address. Use libbacktrace_add_base.
(coff_add): Change base_address to struct
libbacktrace_base_address. Initialize base_address.m.
2024-07-15 17:29:35 -07:00
Ian Lance Taylor
febbb9bff9
libbacktrace: avoid infinite recursion
...
We could get an infinite recursion in an odd case in which a
.gnu_debugdata section was added to a debug file, and mini_debuginfo
was put into the debug file, and the debug file was put into a
/usr/lib/debug directory to be found by build ID. This combination
doesn't really make sense but we shouldn't get an infinite recursion.
* elf.c (elf_add): Don't use .gnu_debugdata if we are already
reading a debuginfo file.
* Makefile.am (m2test_*): New test targets.
(CHECK_PROGRAMS): Add m2test.
(MAKETESTS): Add m2test_minidebug2.
(%_minidebug2): New pattern.
(CLEANFILES): Remove minidebug2 files.
* Makefile.in: Regenerate.
Fixes #129
2024-07-11 19:36:00 -07:00
Martin Liska
5aa92540f0
libbacktrace: fix UBSAN issues
...
Fix issues mentioned in the PR.
PR libbacktrace/103167
libbacktrace/ChangeLog:
* elf.c (elf_uncompress_lzma_block): Cast to unsigned int.
(elf_uncompress_lzma): Likewise.
* xztest.c (test_samples): memcpy only if v > 0.
2024-07-11 18:40:13 -07:00
Ian Lance Taylor
8c05bcb94f
libbacktrace: update copyright years
2024-07-11 18:14:01 -07:00
Ian Lance Taylor
e3e64ddd18
libbacktrace: suggest how to fix missing debug info
...
* elf.c (elf_nodebug): Suggest -g.
* macho.c (macho_nodebug): Suggest -g and dsymutil.
* pecoff.c (coff_nodebug): Suggest -g.
Fixes #122
2024-07-11 15:42:10 -07:00
Ian Lance Taylor
4ead348bb4
libbacktrace: it's OK if zstd decompressor sees no backward bits
...
* elf.c (elf_fetch_bits_backward) Don't fail if no bits are
available.
2024-06-26 09:12:25 -07:00
Ian Lance Taylor
7ead8c1ea2
libbacktrace: don't assume compressed section is aligned
...
Patch originally by GitHub user ubyte at
https://github.com/ianlancetaylor/libbacktrace/pull/120 .
* elf.c (elf_uncompress_chdr): Don't assume compressed section is
aligned.
2024-03-08 13:57:13 -08:00
Ian Lance Taylor
28824f2cc9
libbacktrace: skip all LZMA block header padding bytes
...
* elf.c (elf_uncompress_lzma_block): Skip all header padding bytes
and verify that they are zero.
Fixes #118
2024-03-02 12:18:17 -08:00
Ian Lance Taylor
592e9c8727
libbacktrace: use real .opd for debuginfo on ppc64 v1 ABI
...
PR libbacktrace/114201
* elf.c (elf_add): Add caller_opd parameter. Change all callers.
Release opd data after all recursive calls.
2024-03-02 07:09:12 -08:00
Ian Lance Taylor
36cfdc18ed
libbacktrace: read symbol table of debuginfo file
...
These become another symbol table to search. This is needed if people
use --strip-all rather than --strip-debug when adding a debuglink
section.
Patch is from GitHub user pickard1.
Fixes #113
* elf.c (elf_add): Add the symbol table from a debuginfo file.
* Makefile.am (MAKETESTS): Add buildidfull and gnudebuglinkfull
variants of buildid and gnudebuglink tests.
(%_gnudebuglinkfull, %_buildidfull): New patterns.
* Makefile.in: Regenerate.
2024-02-29 19:48:38 -08:00
Ian Lance Taylor
cdb64b688d
libbacktrace: minor fixes for zstd decompression
...
* elf.c (elf_zstd_read_fse): Call elf_fetch_bits after reading
bits, not before. Add unlikely for error case.
(elf_zstd_offset_table): Regenerate.
(elf_zstd_read_huff): Clear 13 entries in weight_mark, not 12.
(elf_zstd_read_literals): For a single stream adjust by
total_streams_size, not compressed_size.
2023-03-28 13:10:54 -07:00
Ian Lance Taylor
da7eff2f37
libbacktrace: unpack literals into output buffer
...
* elf.c (elf_fetch_backward_init): New static function.
(ZSTD_TABLE_SIZE): Use huffman scratch space size rather than
literal size.
(ZSTD_TABLE_WORK_LIT_SIZE): Don't define.
(elf_zstd_read_huff): Use elf_fetch_backward_init.
(elf_zstd_read_literals): New static function.
(ZSTD_LIT_RAW, ZSTD_LIT_RLE, ZSTD_LIT_HUFF): Don't define.
(struct elf_zstd_literals): Don't define.
(elf_zstd_literal_output): Remove static function.
(elf_zstd_decompress): Use elf_fetch_backward_init and
elf_zstd_read_literals. Rewrite literal copying.<
2022-12-16 18:53:11 -08:00
Ian Lance Taylor
fd9442f7b5
libbacktrace: rewrite and simplify main zstd loop
...
* elf.c (ZSTD_TABLE_*): Use elf_zstd_fse_baseline_entry.
(ZSTD_ENCODE_BASELINE_BITS): Define.
(ZSTD_DECODE_BASELINE, ZSTD_DECODE_BASEBITS): Define.
(elf_zstd_literal_length_base): New static const array.
(elf_zstd_match_length_base): Likewise.
(struct elf_zstd_fse_baseline_entry): Define.
(elf_zstd_make_literal_baseline_fse): New static function.
(elf_zstd_make_offset_baseline_fse): Likewise.
(elf_zstd_make_match_baseline_fse): Likewise.
(print_table, main): Use elf_zstd_fse_baseline_entry.
(elf_zstd_lit_table, elf_zstd_match_table): Likewise.
(elf_zstd_offset_table): Likewise.
(struct elf_zstd_seq_decode): Likewise. Remove use_rle and rle
fields.
(elf_zstd_unpack_seq_decode): Use elf_zstd_fse_baseline_entry,
taking a conversion function. Convert RLE to FSE.
(elf_zstd_literal_length_baseline): Remove.
(elf_zstd_literal_length_bits): Remove.
(elf_zstd_match_length_baseline): Remove.
(elf_zstd_match_length_bits): Remove.
(elf_zstd_decompress): Use elf_zstd_fse_baseline_entry. Rewrite
and simplify main loop.
2022-12-09 17:47:18 -08:00
Ian Lance Taylor
c992dd8a9b
libbacktrace: support zstd decompression
...
Support decompressing --compress-debug-sections=zstd.
* configure.ac: Check for zstd library and
--compress-debug-sections=zstd linker option.
* Makefile.am (zstdtest_*): New targets.
(zstdtest_alloc_*, ctestzstd_*): New targets.
(BUILDTESTS): Add zstdtest, zstdtest_alloc, ctestzstd as
appropriate.
* elf.c (ELFCOMPRESS_ZSTD): Define.
(elf_fetch_bits): Rename from elf_zlib_fetch. Update uses.
(elf_fetch_bits_backward): New static function.
(ZLIB_HUFFMAN_*): Rename from HUFFMAN_*. Update uses.
(ZLIB_TABLE_*): Rename from ZDEBUG_TABLE_*. Update uses.
(ZSTD_TABLE_*): Define.
(struct elf_zstd_fse_entry): Define.
(elf_zstd_read_fse): New static function.
(elf_zstd_build_fse): Likewise.
(lit): Define if BACKTRACE_GENERATE_ZSTD_FSE_TABLES.
(match, offset, next, print_table, main): Likewise.
(elf_zstd_lit_table): New static const array.
(elf_zstd_match_table, elf_zstd_offset_table): Likewise.
(elf_zstd_read_huff): New static function.
(struct elf_zstd_seq_decode): Define.
(elf_zstd_unpack_seq_decode): New static function.
(ZSTD_LIT_*): Define.
(struct elf_zstd_literals): Define.
(elf_zstd_literal_output): New static function.
(ZSTD_LITERAL_LENGTH_BASELINE_OFFSET): Define.
(elf_zstd_literal_length_baseline): New static const array.
(elf_zstd_literal_length_bits): Likewise.
(ZSTD_MATCH_LENGTH_BASELINE_OFFSET): Define.
(elf_zstd_match_length_baseline): New static const array.
(elf_zstd_match_length_bits): Likewise.
(elf_zstd_decompress): New static function.
(ZDEBUG_TABLE_SIZE): New definition.
(elf_uncompress_chdr): Support ELF_COMPRESS_ZSTD.
(backtrace_uncompress_zstd): New function.
(elf_add): Use ZLIB_TABLE_SIZE for zlib-gnu sections.
* internal.h (backtrace_uncompress_zstd): Declare.
* zstdtest.c: New file.
* configure, config.h.in, Makefile.in: Regenerate.
2022-12-07 16:27:12 -08:00
Ian Lance Taylor
8602fda64e
libbacktrace: check for sys/link.h
...
QNX uses sys/link.h rather than link.h for dl_iterate_phdr
Fixes #86
* configure.ac: Check for sys/link.h. Use either link.h or
sys/link.h when checking for dl_iterate_phdr.
* elf.c: Include sys/link.h if available.
* configure, config.h.in: Regenerate.
2022-07-08 10:35:17 -07:00
Ian Lance Taylor
4d2dd0b172
libbacktrace: don't skip initial aligned byte in uncompressed block
...
Patch from Rui Ueyama, who says:
libbacktrace occasionally fails to decompress compressed debug info
even though the sections contain valid zlib streams. The cause of the
issue is an off-by-one error.
If a zlib data block is a plain data (uncompressed data), the next two
bytes contain the size of the block. These two bytes value is byte-
aligned, so if we read-ahead more than 8 bits, we need to unread it.
So, the correct condition to determine whether or not we need to
unread a byte is bits >= 8 and not bits > 8. Due to this error,
if the last read bits happened to end at a byte boundary, the next
byte would be skipped. That caused the decompression failure.
This bug was originally reported against the mold linker.
rui314/mold#402
* elf.c (elf_zlib_inflate): Don't skip initial aligned byte in
uncompressed block.
2022-04-05 16:10:04 -07:00
Jakub Jelinek
5496ee0a1a
Update copyright years.
2021-01-18 14:56:19 -08:00
Ian Lance Taylor
73eb1803b1
libbacktrace: use __attribute__((__fallthrough__))
...
Use an attribute rather than a comment when falling through a switch case.
* internal.h (ATTRIBUTE_FALLTHROUGH): Define.
* elf.c (elf_zlib_inflate): Use ATTRIBUTE_FALLTHROUGH.
2020-10-20 11:50:23 -07:00
Ian Lance Taylor
c8a81d4e3a
libbacktrace: use ELF symbol table if no debug info available
...
PR libbacktrace/97080
* fileline.c (backtrace_syminfo_to_full_callback): New function.
(backtrace_syminfo_to_full_error_callback): New function.
* elf.c (elf_nodebug): Call syminfo_fn if possible.
* internal.h (struct backtrace_call_full): Define.
(backtrace_syminfo_to_full_callback): Declare.
(backtrace_syminfo_to_full_error_callback): Declare.
* mtest.c (f3): Only check all[i] if data.index permits.
2020-09-27 17:29:53 -07:00
Ian Lance Taylor
77bcaa99f5
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
2020-09-27 17:28:39 -07:00
Ian Lance Taylor
7206f5bd06
libbacktrace: don't crash if ELF file has no sections
...
Patch from Roland McGrath.
Fixes #41
2020-05-09 20:36:19 -07:00
Ian Lance Taylor
ca0de0517f
libbacktrace: don't free ELF strtab if error occurs after saving syminfo
...
Fixes #29
2020-02-19 10:32:09 -08:00
Ian Lance Taylor
bd02146d90
Update copyright years.
2020-02-18 18:46:13 -08:00
Ian Lance Taylor
aced4e1f2a
libbacktrace: if debug info large or split, read sections individually
...
Fixes #29
2020-02-15 17:58:09 -08:00
Ian Lance Taylor
559ab7cab4
libbacktrace: update to current version from GCC trunk
...
This adds DWARF 5 support as well as an enhanced testsuite.
Patch assembled by Than McIntosh.
2019-12-23 18:55:51 -08:00
Ian Lance Taylor
012b950b37
Copy changes from GCC:
...
2018-04-17 Ian Lance Taylor <iant@golang.org >
* backtrace.c (backtrace_full): When testing whether we can
allocate memory, call mmap directly, and munmap the memory.
2018-04-04 Jakub Jelinek <jakub@redhat.com >
PR other/85161
* elf.c (elf_zlib_fetch): Fix up predefined macro names in test for
big endian, only use 32-bit loads if endianity macros are predefined
and indicate big or little endian.
2018-02-15 Jakub Jelinek <jakub@redhat.com >
PR other/82368
* elf.c (SHT_PROGBITS): Undefine and define.
2018-02-14 Jakub Jelinek <jakub@redhat.com >
PR other/82368
* elf.c (EM_PPC64, EF_PPC64_ABI): Undefine and define.
(struct elf_ppc64_opd_data): New type.
(elf_initialize_syminfo): Add opd argument, handle symbols
pointing into the PowerPC64 ELFv1 .opd section.
(elf_add): Read .opd section on PowerPC64 ELFv1, pass pointer
to structure with .opd data to elf_initialize_syminfo.
2018-01-19 Tony Reix <tony.reix@atos.net >
* xcoff.c (xcoff_incl_compare): New function.
(xcoff_incl_search): New function.
(xcoff_process_linenos): Use bsearch to find include file.
(xcoff_initialize_fileline): Sort include file information.
Fixes #13
2018-04-17 07:04:02 -07:00
Ian Lance Taylor
177940370e
* elf.c (elf_add): Close descriptor if we use a debugfile.
...
* btest.c (check_open_files): New static function.
(main): Call check_open_files.
2018-01-31 15:24:01 -08:00
Ian Lance Taylor
811741b03b
* elf.c (elf_open_debugfile_by_debuglink): Don't check CRC if the
...
desired CRC is zero.
(elf_add): Don't clear *found_sym and *found_dwarf if debuginfo.
2018-01-25 10:14:34 -08:00
Ian Lance Taylor
f2c17c0417
libbacktrace: update to GCC SVN revision 256776
...
This brings in this patch:
* elf.c (codes) [GENERATE_FIXED_HUFFMAN_TABLE]: Fix size to be
288.
(main) [GENERATE_FIXED_HUFFMAN_TABLE]: Pass 288 to
elf_zlib_inflate_table. Generate elf_zlib_default_dist_table.
(elf_zlib_default_table): Update.
(elf_zlib_default_dist_table): New static array.
(elf_zlib_inflate): Use elf_zlib_default_dist_table for dist table
for block type 1.
* ztest.c (struct zlib_test): Add uncompressed_len.
(tests): Initialize uncompressed_len field. Add new test case.
(test_samples): Use uncompressed_len field.
2018-01-16 17:39:45 -08:00
Than McIntosh
17f687d2b9
Update from gcc trunk version of libbacktrace at svn rev 256427. ( #8 )
...
Includes (among other things) support for compressed debug sections,
a variety of bugfixes, and expanded test coverage.
2018-01-12 10:26:02 -08:00
Ian Lance Taylor
ba79a27ee9
all: remove meaningless trailing whitespace
2016-09-11 06:45:37 -07:00
Ian Lance Taylor
84241313f2
libbacktrace: initial commit
...
This is a standalone version of the libbacktrace library that I
originally wrote for GCC. This is a copy of libbacktrace from GCC
trunk, with all dependencies incorporated here.
2016-09-10 07:59:09 -07:00