summaryrefslogtreecommitdiff
path: root/libbacktrace/elf.c
Commit message (Collapse)AuthorAgeFilesLines
* libbacktrace: minor fixes for zstd decompressionIan Lance Taylor2023-03-281-20/+20
| | | | | | | | | * 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.
* Update copyright years.Jakub Jelinek2023-01-161-1/+1
|
* libbacktrace: unpack literals into output bufferIan Lance Taylor2022-12-161-636/+667
| | | | | | | | | | | | | | * 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.<
* libbacktrace: rewrite and simplify main zstd loopIan Lance Taylor2022-12-091-356/+592
| | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* libbacktrace: support zstd decompressionIan Lance Taylor2022-12-071-70/+2322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libbacktrace: check for sys/link.hIan Lance Taylor2022-07-081-1/+6
| | | | | | | | | | | QNX uses sys/link.h rather than link.h for dl_iterate_phdr Fixes https://github.com/ianlancetaylor/libbacktrace/issues/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.
* libbacktrace: don't skip initial aligned byte in uncompressed blockIan Lance Taylor2022-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Update copyright years.Jakub Jelinek2022-01-031-1/+1
|
* libbacktrace: fix UBSAN issuesMartin Liska2021-11-121-16/+16
| | | | | | | | | | | | 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.
* Update copyright years.Jakub Jelinek2021-01-041-1/+1
|
* libbacktrace: use __attribute__((__fallthrough__))Ian Lance Taylor2020-10-201-8/+8
| | | | | | | 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.
* libbacktrace: use ELF symbol table if no debug info availableIan Lance Taylor2020-09-161-12/+27
| | | | | | | | | | | 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.
* libbacktrace: support MiniDebugInfoIan Lance Taylor2020-09-141-150/+1551
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libbacktrace: don't crash if ELF file has no sectionsIan Lance Taylor2020-05-091-0/+3
| | | | | libbacktrace/ * elf.c (elf_add): Bail early if there are no section headers at all.
* libbacktrace: don't free ELF strtab if error occurs after saving syminfoIan Lance Taylor2020-05-091-0/+1
| | | | | * elf.c (elf_add): Don't free strtab if an error occurs after recording symbol information.
* libbacktrace: sometimes read debug sections individuallyIan Lance Taylor2020-05-091-19/+83
| | | | | | libbacktrace/ * elf.c (elf_add): If debug sections are very large or far apart, read them individually rather than as a single view.
* Update copyright years.Jakub Jelinek2020-01-011-1/+1
| | | | From-SVN: r279813
* libbacktrace: add DWARF 5 supportIan Lance Taylor2019-12-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dwarf.c (struct attr): Add val field. (enum attr_val_encoding): Add ATTR_VAL_ADDDRESS_INDEX, ATTR_VAL_STRING_INDEX, ATTR_VAL_RNGLISTS_INDEX. (struct line_header): Add addrsize field. (struct line_header_format): Define. (struct unit): Add str_offsets_base, addr_base, and rnglists_base fields. (read_uint24): New static function. (read_attribute): Add implicit_val parameter. Replace dwarf_str and dwarf_str_size parameters with dwarf_sections parameter. Add support for new DWARF 5 forms. Change all callers. (resolve_string): New static function. (resolve_addr_index): Likewise. (read_abbrevs): Support DW_FORM_implicit_const. (struct pcrange): Add lowpc_is_addr_index, highpc_is_addr_Index, and ranges_is_index fields. (update_pcrange): Support DWARF 5 encodings. (add_high_low_range): New static function, split out of add_ranges. (add_ranges_from_ranges): Likewise. (add_ranges_from_rnglists): New static function. (add_ranges): Just call new helper functions. (find_address_ranges): Use resolve_string for strings, after reading all attributes. Handle new DWARF 5 attributes. (build_address_map): Support DWARF 5 compilation units. (read_v2_paths): New static function, split out of read_line_header. (read_lnct): New static function. (read_line_header_format_entries): Likewise. (read_line_header): Add ddata parameter. Support DWARF 5 line headers. Call new helper functions. Change all callers. (read_line_program): Use addrsize from line program header. Don't special case directory index 0 for DWARF 5. (read_referenced_name): Use resolve_string. (read_function_entry): Handle DWARF 5 encodings. Use resolve_string. * internal.h (enum dwarf_section): Add DEBUG_ADDR, DEBUG_STR_OFFSETS, DEBUG_LINE_STR, DEBUG_RNGLISTS. * elf.c (dwarf_section_names): Add new section names. * pecoff.c (dwarf_section_names): Likewise. * xcoff.c (xcoff_add): Clear dwarf_sections before setting fields. * configure.ac: Define HAVE_DWARF5 automake conditional. * Makefile.am (dwarf5_SOURCES): New variable if HAVE_DWARF5. (dwarf5_CFLAGS, dwarf5_LDADD): Likewise. (dwarf5_alloc_SOURCES, dwarf5_alloc_CFLAGS): Likewise. (dwarf5_alloc_LDADD): Likewise. (BUILDTESTS): Add dwarf5 tests if HAVE_DWARF5. (CLEANFILES, clean-local): Define. From-SVN: r279380
* libbacktrace: simplify DWARF section handlingIan Lance Taylor2019-12-051-57/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is in preparation for adding DWARF 5 support. * internal.h (enum dwarf_section): Define. (struct dwarf_sections): Define. (backtrace_dwarf_add): Update declaration to replace specific section parameters with dwarf_sections parameter. * dwarf.c (struct dwarf_data): Replace specific section fields with dwarf_sections field. (read_attribute): Use dwarf_sections with altlink. (build_address_map): Replace specific section parameters with dwarf_sections parameter. Change all callers. (read_line_info): Use dwarf_sections with ddata. (read_referenced_name): Likewise. (add_function_ranges): Likewise. (read_function_entry): Likewise. (read_function_info): Likewise. (build_dwarf_data): Replace specific section parameters with dwarf_sections parameter. Change all callers. (backtrace_dwarf_add): Likewise. * elf.c (enum debug_section): Remove. (dwarf_section_names): Remove .zdebug names. (elf_add): Track zsections separately. Build dwarf_sections. * pecoff.c (enum debug_section): Remove. (struct debug_section_info): Remove data field. (coff_add): Build dwarf_sections. * xcoff.c (enum dwarf_section): Remove. Replace DWSECT_xxx references with DEBUG_xxx references. (xcoff_add): Build dwarf_sections. From-SVN: r278984
* [libbacktrace] Fix .gnu_debugaltlink build-id checkTom de Vries2019-01-311-2/+2
| | | | | | | | | | | | | | | The 'debugaltlink_name_len =+ 1' bug reported in PR89136 exposes the fact that the build-id is not verified for the .gnu_debugaltlink. Fix both problems. 2019-01-31 Tom de Vries <tdevries@suse.de> PR libbacktrace/89136 * elf.c (elf_add): Read build-id if with_buildid_data. Fix 'debugaltlink_name_len =+ 1'. From-SVN: r268419
* [libbacktrace] Add test-cases exercising build-id and dwzTom de Vries2019-01-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | Add test-cases b2test_buildid and b3test_dwz_buildid. The last one triggers the segfault fixed by "[backtrace] Avoid segfault" ( r268275 ). 2019-01-29 Tom de Vries <tdevries@suse.de> * install-debuginfo-for-buildid.sh.in: New script. * Makefile.am (check_PROGRAMS): Add b2test and b3test. (TESTS): Add b2test_buildid and b3test_dwz_buildid. * Makefile.in: Regenerate. * configure.ac (HAVE_ELF): Set with AM_CONDITIONAL. (READELF): Set with AC_CHECK_PROG. (install-debuginfo-for-buildid.sh): Generate with AC_CONFIG_FILES. * configure: Regenerate. * elf.c (SYSTEM_BUILD_ID_DIR): Factor out of ... (elf_open_debugfile_by_buildid): ... here. From-SVN: r268369
* [backtrace] Avoid segfaultNathan Sidwell2019-01-251-1/+1
| | | | | | | | | https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01521.html * elf.c (elf_add): Pass "" filename to recursive call with separated debug. From-SVN: r268275
* [libbacktrace] Fix strrchr segfaultTom de Vries2019-01-251-1/+1
| | | | | | | | | | | | | | | | | | | Currently, when running a libbacktrace testcase t with .gnu_debuglink to t.debug, and t.debug having a .gnu_debugaltlink to t.alt.debug, a segfault is triggered when calling strrchr with a NULL string from elf_find_debugfile_by_debuglink. The NULL string originates from the elf_add called for the .gnu_debugaltlink, which uses NULL as filename argument. Fix this by using "" as filename argument instead. 2019-01-25 Tom de Vries <tdevries@suse.de> * elf.c (elf_add): When handling .gnu_debugaltlink, call elf_add with filename == "". * Makefile.am (TESTS): Add btest_dwz_gnudebuglink. * Makefile.in: Regenerate. From-SVN: r268269
* re PR libbacktrace/88890 (libbacktrace on 32-bit system with ↵Ian Lance Taylor2019-01-181-1/+1
| | | | | | | | | | | | | _FILE_OFFSET_BITS == 64) PR libbacktrace/88890 * mmapio.c (backtrace_get_view): Change size parameter to uint64_t. Check that value fits in size_t. * read.c (backtrace_get_view): Likewise. * internal.h (backtrace_get_view): Update declaration. * elf.c (elf_add): Pass shstrhdr->sh_size to backtrace_get_view. From-SVN: r268082
* [libbacktrace] Add altlink field to struct dwarf_dataTom de Vries2019-01-171-1/+3
| | | | | | | | | | | | | | | | | Add an altlink field to struct dwarf_data, and initialize it with the pointer to the struct dwarf_data for the .gnu_debugaltlink. 2019-01-17 Tom de Vries <tdevries@suse.de> * dwarf.c (struct dwarf_data): Add altlink field. (backtrace_dwarf_add): Add and handle fileline_altlink parameter. * elf.c (elf_add): Add argument to backtrace_dwarf_add call. (phdr_callback, backtrace_initialize): Add argument to elf_add calls. * internal.h (backtrace_dwarf_add): Add fileline_altlink parameter. * pecoff.c (coff_add): Add argument to backtrace_dwarf_add call. * xcoff.c (xcoff_add): Same. From-SVN: r267994
* [libbacktrace] Return struct dwarf_data pointer from elf_addTom de Vries2019-01-171-9/+14
| | | | | | | | | | | | | | | | | Allow the caller of elf_add access to the struct dwarf_data pointer corresponding to the added elf. 2019-01-17 Tom de Vries <tdevries@suse.de> * internal.h (backtrace_dwarf_add): Add fileline_entry parameter. * dwarf.c (backtrace_dwarf_add): Add and handle fileline_entry parameter. * elf.c (elf_add): Add and handle fileline_entry parameter. Add argument to backtrace_dwarf_add call. (phdr_callback, backtrace_initialize): Add argument to elf_add calls. * pecoff.c (coff_add): Add argument to backtrace_dwarf_add call. * xcoff.c (xcoff_add): Same. From-SVN: r267993
* [libbacktrace] Read .gnu_debugaltlinkTom de Vries2019-01-171-5/+88
| | | | | | | | | | | | | Read the elf file pointed at by the .gnu_debugaltlink section, and verify that the build id matches. 2019-01-17 Tom de Vries <tdevries@suse.de> * elf.c (elf_add): Add and handle with_buildid_data and with_buildid_size parameters. Handle .gnu_debugaltlink section. (phdr_callback, backtrace_initialize): Add arguments to elf_add calls. From-SVN: r267992
* Update copyright years.Jakub Jelinek2019-01-011-1/+1
| | | | From-SVN: r267494
* re PR other/86198 (Libbacktrace does not properly work with ↵Denis Khalikov2018-06-211-1/+1
| | | | | | | | | | | | | | ".note.gnu.build-id" section) libbacktrace/ 2018-06-21 Denis Khalikov <d.khalikov@partner.samsung.com> PR other/86198 * elf.c (elf_add): Increase ".note.gnu.build-id" section size checking up to 36 bytes. From-SVN: r261832
* re PR other/85161 (Test case failures in libbacktrace on powerpc64 BE ↵Jakub Jelinek2018-04-041-1/+8
| | | | | | | | | | | starting with r253456) 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. From-SVN: r259096
* re PR other/82368 (with r253275 several new test cases in libbacktrace fail)Jakub Jelinek2018-02-151-0/+2
| | | | | | | PR other/82368 * elf.c (SHT_PROGBITS): Undefine and define. From-SVN: r257685
* re PR other/82368 (with r253275 several new test cases in libbacktrace fail)Jakub Jelinek2018-02-141-3/+60
| | | | | | | | | | | | 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. From-SVN: r257658
* elf.c (elf_add): Close descriptor if we use a debugfile.Ian Lance Taylor2018-01-311-4/+18
| | | | | | | | * elf.c (elf_add): Close descriptor if we use a debugfile. * btest.c (check_open_files): New static function. (main): Call check_open_files. From-SVN: r257275
* elf.c (elf_open_debugfile_by_debuglink): Don't check CRC if the desired CRC ↵Ian Lance Taylor2018-01-251-7/+14
| | | | | | | | | | is zero. * 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. From-SVN: r257062
* elf.c (codes): Fix size to be 288.Ian Lance Taylor2018-01-171-36/+96
| | | | | | | | | | | | | | | | * 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. From-SVN: r256776
* Update copyright years.Jakub Jelinek2018-01-031-1/+1
| | | | From-SVN: r256169
* elf.c (elf_zlib_fetch): Change pval argument to uint64_t *.Ian Lance Taylor2017-10-051-13/+36
| | | | | | | | | | * elf.c (elf_zlib_fetch): Change pval argument to uint64_t *. Read a four byte integer. (elf_zlib_inflate): Change val to uint64_t. Align pin to a 32-bit boundary before ever calling elf_zlib_fetch. * ztest.c (test_large): Simplify print statements a bit. From-SVN: r253456
* re PR other/67165 (please enable libbacktrace to work with compressed debug ↵Ian Lance Taylor2017-09-291-5/+1624
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sections) PR other/67165 * elf.c (__builtin_prefetch): Define if not __GNUC__. (unlikely): Define. (SHF_UNCOMPRESSED, ELFCOMPRESS_ZLIB): Define. (b_elf_chdr): Define type. (enum debug_section): Add ZDEBUG_xxx values. (debug_section_names): Add names for new sections. (struct debug_section_info): Add compressed field. (elf_zlib_failed, elf_zlib_fetch): New static functions. (HUFFMAN_TABLE_SIZE, HUFFMAN_VALUE_MASK): Define. (HUFFMAN_BITS_SHIFT, HUFFMAN_BITS_MASK): Define. (HUFFMAN_SECONDARY_SHIFT): Define. (ZDEBUG_TABLE_SIZE): Define. (ZDEBUG_TABLE_CODELEN_OFFSET, ZDEBUG_TABLE_WORK_OFFSET): Define. (final_next_secondary): New static variable if BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE. (elf_zlib_inflate_table): New static function. (BACKTRACE_GENERATE_FIXED_HUFFMAN_TABLE): If define, define main function to produce fixed Huffman table. (elf_zlib_default_table): New static variable. (elf_zlib_inflate): New static function. (elf_zlib_verify_checksum): Likewise. (elf_zlib_inflate_and_verify): Likewise. (elf_uncompress_zdebug): Likewise. (elf_uncompress_chdr): Likewise. (backtrace_uncompress_zdebug): New extern function. (elf_add): Look for .zdebug sections and SHF_COMPRESSED debug sections, and uncompress them. * internal.h (backtrace_compress_zdebug): Declare. * ztest.c: New file. * configure.ac: Check for -lz and check whether the linker supports --compress-debug-sections. * Makefile.am (ztest_SOURCES): New variable. (ztest_CFLAGS, ztest_LDADD): New variables. (check_PROGRAMS): Add ztest. (ctestg_SOURCES): New variable. (ctestg_CFLAGS, ctestg_LDFLAGS, ctestg_LDADD): New variables. (ctesta_SOURCES): New variable. (ctesta_CFLAGS, ctesta_LDFLAGS, ctesta_LDADD): New variables. (check_PROGRAMS): Add ctestg and ctesta. * configure, config.h.in, Makefile.in: Rebuild. From-SVN: r253275
* re PR sanitizer/77631 (no symbols in backtrace shown by ASan when debug info ↵Ian Lance Taylor2017-09-221-0/+29
| | | | | | | | | | | | is split) PR sanitizer/77631 * configure.ac: Check for lstat and readlink. * elf.c (lstat, readlink): Provide dummy versions if real versions are not available. * configure, config.h.in: Rebuild. From-SVN: r253095
* re PR go/82284 (go -version segfaults on big endian architectures)Ian Lance Taylor2017-09-211-0/+1
| | | | | | | PR go/82284 * elf.c (backtrace_initialize): Set pd.exe_filename. From-SVN: r253078
* re PR sanitizer/77631 (no symbols in backtrace shown by ASan when debug info ↵Ian Lance Taylor2017-09-201-10/+558
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is split) PR sanitizer/77631 Support for external debug info. * elf.c: Include <errno.h>, <sys/stat.h>, <unistd.h>. (S_ISLNK): Define if not defined. (xstrnlen): Define if strnlen is not available. (b_elf_note): Define type. (NT_GNU_BUILD_ID): Define macro. (elf_crc32, elf_crc32_file): New static functions. (elf_is_symlink, elf_readlink): New static functions. (elf_open_debugfile_by_buildid): New static function. (elf_try_debugfile): New static function. (elf_find_debugfile_by_debuglink): New static function. (elf_open_debugfile_by_debuglink): New static function. (elf_add): Add filename and debuginfo parameters. Adjust all callers. Look for external debug info notes, and try to fetch debug info from external file. (struct phdr_data): Add exe_filename field. (phdr_callback): Pass filename to elf_add. (backtrace_initialize): Add filename parameter. * internal.h (backtrace_initialize): Add filename parameter. * fileline.c (fileline_initialize): Pass filename to backtrace_initialize. * pecoff.c (fileline_initialize): Add unused filename parameter. * unknown.c (fileline_initialize): Likewise. * xcoff.c (fileline_initialize): Likewise. * configure.ac: Check for objcopy --add-gnu-debuglink. * Makefile.am (dtest): New test target. * configure, Makefile.in: Rebuild. Co-Authored-By: Denis Khalikov <d.khalikov@partner.samsung.com> From-SVN: r253032
* configure.ac: Check for XCOFF32/XCOFF64.Tony Reix2017-07-261-1/+1
| | | | | | | | | * configure.ac: Check for XCOFF32/XCOFF64. Check for loadquery. * filetype.awk: Separate AIX XCOFF32 and XCOFF64. * xcoff.c: Add support for AIX XCOFF32 and XCOFF64 formats. * configure, config.h.in: Regenerate. From-SVN: r250590
* elf.c (backtrace_initialize): Always set *fileline_fn.Ian Lance Taylor2017-06-121-10/+4
| | | | | | | | | | | | | | | | | | * elf.c (backtrace_initialize): Always set *fileline_fn. * ttest.c: New file. * btest.c: Move support functions into testlib.c. Change calls to check to pass file name. * testlib.c: New file, copied from (part of) btest.c. * testlib.h: New file, declarations for testlib.c. * edtest.c: Use testlib.h and testlib.c. * configure.ac: Test for -pthread, set HAVE_PTHREAD conditional. * Makefile.am (btest_SOURCES): Add testlib.c. (edtest_SOURCES): Likewise. (CHECK_PROGRAMS): Add ttest if HAVE_PTHREAD. (ttest_SOURCES, ttest_CFLAGS, ttest_LDADD): Define. * configure, Makefile.in: Rebuild. From-SVN: r249111
* Update copyright years.Jakub Jelinek2017-01-011-1/+1
| | | | From-SVN: r243994
* * all: Remove meaningless trailing whitespace.Carlos Liam2016-09-111-3/+3
| | | | From-SVN: r240084
* re PR target/71161 (Lots of ASAN and libgo runtime FAILs after r236090)Uros Bizjak2016-05-181-0/+3
| | | | | | | | PR target/71161 * elf.c (phdr_callback) [__i386__]: Add __attribute__((__force_align_arg_pointer__)). From-SVN: r236397
* elf.c (backtrace_initialize): Properly initialize elf_fileline_fn to avoid ↵Max Ostapenko2016-03-021-2/+1
| | | | | | | | | | | | | | | possible crash. libbacktrace/ 2016-03-02 Maxim Ostapenko <m.ostapenko@partner.samsung.com> * elf.c (backtrace_initialize): Properly initialize elf_fileline_fn to avoid possible crash. (elf_add): Don't set *fileline_fn to elf_nodebug value in case of missing debug info anymore. From-SVN: r233911
* Update copyright years.Jakub Jelinek2016-01-041-1/+1
| | | | From-SVN: r232055
* PR 68115/libfortranJohn David Anglin2015-12-101-1/+2
| | | | | | | | | | PR 68115/libfortran * configure.ac: Set libbacktrace_cv_sys_sync to no on hppa*-*-hpux*. * configure: Regenerate. * elf.c (backtrace_initialize): Cast __sync_bool_compare_and_swap call to void. From-SVN: r231485
* Update copyright years.Jakub Jelinek2015-01-051-1/+1
| | | | From-SVN: r219188