aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
AgeCommit message (Collapse)AuthorFilesLines
2020-04-16PR25827, Null pointer dereferencing in scan_unit_for_symbolsAlan Modra1-5/+7
PR 25827 * dwarf2.c (scan_unit_for_symbols): Wrap overlong lines. Don't strdup(0).
2020-03-19Fix discrepancies in nm's --line-number output by adding support for the ↵Nick Clifton1-18/+68
DW_AT_specification DWARF Attttribute. PR 25676 bfd * dwarf2.c (struct varinfo): Add unit_offset field to record the location of the varinfo in the unit's debug info data. Change the type of the stack field to a boolean. (lookup_var_by_offset): New function. Returns the varinfo structure for the variable described at the given offset in the unit's debug info. (scan_unit_for_symbols): Add support for variables which have the DW_AT_specification attribute. binutils* testsuite/binutils-all/dw4.s: New test source file. * testsuite/binutils-all/nm.exp: Run the new test.
2020-02-26Indent labelsAlan Modra1-1/+1
Labels don't go in the first column according to standard emacs C indent rules, and I got annoyed enough at seeing diff -p show a label rather than the function name to fix this. bfd/ * aoutx.h: Indent labels correctly. Format error strings. * archive.c: Likewise. * archive64.c: Likewise. * coff-arm.c: Likewise. * coff-rs6000.c: Likewise. * coff-stgo32.c: Likewise. * cpu-arm.c: Likewise. * dwarf2.c: Likewise. * elf-ifunc.c: Likewise. * elf-properties.c: Likewise. * elf-s390-common.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-bfin.c: Likewise. * elf32-cr16.c: Likewise. * elf32-csky.c: Likewise. * elf32-i386.c: Likewise. * elf32-m68k.c: Likewise. * elf32-msp430.c: Likewise. * elf32-nds32.c: Likewise. * elf32-nios2.c: Likewise. * elf32-pru.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-ia64-vms.c: Likewise. * elf64-x86-64.c: Likewise. * elfcode.h: Likewise. * elfcore.h: Likewise. * elflink.c: Likewise. * elfnn-aarch64.c: Likewise. * elfnn-ia64.c: Likewise. * elfnn-riscv.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * elfxx-x86.c: Likewise. * i386lynx.c: Likewise. * merge.c: Likewise. * pdp11.c: Likewise. * plugin.c: Likewise. * reloc.c: Likewise. binutils/ * elfedit.c: Indent labels correctly. * readelf.c: Likewise. * resres.c: Likewise. gas/ * config/obj-elf.c: Indent labels correctly. * config/obj-macho.c: Likewise. * config/tc-aarch64.c: Likewise. * config/tc-alpha.c: Likewise. * config/tc-arm.c: Likewise. * config/tc-cr16.c: Likewise. * config/tc-crx.c: Likewise. * config/tc-frv.c: Likewise. * config/tc-i386-intel.c: Likewise. * config/tc-i386.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-mn10200.c: Likewise. * config/tc-mn10300.c: Likewise. * config/tc-nds32.c: Likewise. * config/tc-riscv.c: Likewise. * config/tc-s12z.c: Likewise. * config/tc-xtensa.c: Likewise. * config/tc-z80.c: Likewise. * read.c: Likewise. * symbols.c: Likewise. * write.c: Likewise. ld/ * emultempl/cskyelf.em: Indent labels correctly. * ldfile.c: Likewise. * ldlang.c: Likewise. * plugin.c: Likewise. opcodes/ * aarch64-asm.c: Indent labels correctly. * aarch64-dis.c: Likewise. * aarch64-gen.c: Likewise. * aarch64-opc.c: Likewise. * alpha-dis.c: Likewise. * i386-dis.c: Likewise. * nds32-asm.c: Likewise. * nfp-dis.c: Likewise. * visium-dis.c: Likewise.
2020-02-19bfd_size_type to size_tAlan Modra1-22/+22
bfd_size_type was invented a long time ago in the K&R days. Many places in binutils ought to be using size_t instead (and there are lots of places that use long or unsigned long that really ought to use size_t too). Note that you can't change everything over to size_t: A 32-bit host needs a larger type than size_t to support reading and processing of 64-bit ELF object files. This patch just tidies some of the more obvious uses of bfd_size_type that could be size_t. There no doubt are more lurking in the source. Incidentally, practically all functions used for output of object files can use size_t and don't need to worry about overflow of size expressions. If you have something like symcount * sizeof (void *) when symcount is counting symbols already in memory then you know that this expression can't overflow since the size of a symbol in memory is larger by far than that of a pointer. * aix386-core.c (aix386_core_file_p): Use size_t for "amt". * aout-target.h (object_p): Likewise. * aout-tic30.c (tic30_aout_object_p): Likewise. * aoutx.h (some_aout_object_p, mkobject, make_empty_symbol), (emit_stringtab, write_syms, link_hash_table_create), (aout_link_write_other_symbol): Likewise. * archive.c (_bfd_generic_mkarchive, bfd_generic_archive_p), (bfd_ar_hdr_from_filesystem, _bfd_write_archive_contents), (_bfd_compute_and_write_armap): Likewise. * archures.c (bfd_arch_list): Likewise. * bfd.c (bfd_record_phdr): Likewise. * binary.c (binary_canonicalize_symtab): Likewise. * cisco-core.c (cisco_core_file_validate): Likewise. * coff-arm.c (coff_arm_link_hash_table_create, find_thumb_glue), (find_arm_glue, record_arm_to_thumb_glue), (record_thumb_to_arm_glue): Likewise. * coff-ppc.c (ppc_coff_link_hash_table_create, record_toc), (ppc_allocate_toc_section): Likewise. * coff-rs6000.c (_bfd_xcoff_mkobject, _bfd_xcoff_archive_p): Likewise. * coff-sh.c (sh_relax_section): Likewise. * coff64-rs6000.c (xcoff64_archive_p): Likewise. * coffcode.h (handle_COMDAT, coff_new_section_hook), (coff_set_alignment_hook, coff_mkobject), (coff_compute_section_file_positions): Likewise. * coffgen.c (coff_make_empty_symbol, coff_bfd_make_debug_symbol), (coff_find_nearest_line_with_names), ( bfd_coff_set_symbol_class): Likewise. * cofflink.c (_bfd_coff_link_hash_table_create), (_bfd_coff_link_input_bfd): Likewise. * dwarf1.c (alloc_dwarf1_unit, alloc_dwarf1_func): Likewise. * dwarf2.c (read_abbrevs, read_attribute_value, add_line_info), (build_line_info_table, sort_line_sequences), (line_info_add_include_dir, line_info_add_file_name), (decode_line_info, scan_unit_for_symbols, parse_comp_unit), (place_sections, _bfd_dwarf2_slurp_debug_info): Likewise. * ecoff.c (_bfd_ecoff_mkobject, _bfd_ecoff_make_empty_symbol), (_bfd_ecoff_find_nearest_line), (_bfd_ecoff_bfd_link_hash_table_create): Likewise. * ecofflink.c (bfd_ecoff_debug_init): Likewise. * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Likewise. * elf-m10300.c (mn10300_elf_relax_section), (elf32_mn10300_link_hash_table_create): Likewise. * elf-strtab.c (_bfd_elf_strtab_init): Likewise. * elf.c (make_mapping, copy_elf_program_header): Likewise. * elf32-arm.c (elf32_arm_link_hash_table_create), (elf32_arm_setup_section_lists, elf32_arm_check_relocs), (elf32_arm_new_section_hook): Likewise. * elf32-avr.c (elf_avr_new_section_hook), (elf32_avr_link_hash_table_create, get_local_syms), (elf32_avr_setup_section_lists): Likewise. * elf32-bfin.c (bfinfdpic_elf_link_hash_table_create), (bfin_link_hash_table_create): Likewise. * elf32-cr16.c (elf32_cr16_link_hash_table_create): Likewise. * elf32-cris.c (elf_cris_link_hash_table_create): Likewise. * elf32-csky.c (csky_elf_link_hash_table_create), (csky_elf_check_relocs, elf32_csky_setup_section_lists): Likewise. * elf32-frv.c (frvfdpic_elf_link_hash_table_create): Likewise. * elf32-hppa.c (elf32_hppa_link_hash_table_create), (elf32_hppa_setup_section_lists, get_local_syms): Likewise. * elf32-i386.c (elf_i386_check_relocs): Likewise. * elf32-lm32.c (lm32_elf_link_hash_table_create): Likewise. * elf32-m32r.c (m32r_elf_link_hash_table_create), (m32r_elf_check_relocs): Likewise. * elf32-m68hc1x.c (m68hc11_elf_hash_table_create), (elf32_m68hc11_setup_section_lists), (elf32_m68hc11_size_stubs): Likewise. * elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise. * elf32-metag.c (elf_metag_link_hash_table_create), (elf_metag_setup_section_lists): Likewise. * elf32-microblaze.c (microblaze_elf_link_hash_table_create), (microblaze_elf_check_relocs): Likewise. * elf32-nds32.c (nds32_elf_link_hash_table_create), (nds32_elf_check_relocs): Likewise. * elf32-nios2.c (nios2_elf32_setup_section_lists), (get_local_syms, nios2_elf32_check_relocs), (nios2_elf32_link_hash_table_create): Likewise. * elf32-or1k.c (or1k_elf_link_hash_table_create), (or1k_elf_check_relocs): Likewise. * elf32-ppc.c (ppc_elf_modify_segment_map, update_plt_info): Likewise. * elf32-pru.c (pru_elf32_link_hash_table_create): Likewise. * elf32-s390.c (elf_s390_link_hash_table_create), (elf_s390_check_relocs): Likewise. * elf32-score.c (score_elf_create_got_section), (s3_elf32_score_new_section_hook), (elf32_score_link_hash_table_create): Likewise. * elf32-score7.c (score_elf_create_got_section), (s7_elf32_score_new_section_hook): Likewise. * elf32-sh.c (sh_elf_link_hash_table_create), (sh_elf_check_relocs): Likewise. * elf32-tic6x.c (elf32_tic6x_link_hash_table_create), (elf32_tic6x_new_section_hook, elf32_tic6x_check_relocs): Likewise. * elf32-tilepro.c (tilepro_elf_link_hash_table_create), (tilepro_elf_check_relocs): Likewise. * elf32-v850.c (remember_hi16s_reloc): Likewise. * elf32-vax.c (elf_vax_link_hash_table_create): Likewise. * elf32-xtensa.c (elf_xtensa_link_hash_table_create), (elf_xtensa_new_section_hook): Likewise. * elf64-alpha.c (elf64_alpha_bfd_link_hash_table_create), (get_got_entry, elf64_alpha_check_relocs): Likewise. * elf64-hppa.c (elf64_hppa_hash_table_create): Likewise. * elf64-ia64-vms.c (elf64_ia64_object_p): Likewise. * elf64-mmix.c (mmix_elf_new_section_hook): Likewise. * elf64-ppc.c (ppc64_elf_new_section_hook), (ppc64_elf_link_hash_table_create, update_local_sym_info), (update_plt_info, ppc64_elf_check_relocs): Likewise. * elf64-s390.c (elf_s390_link_hash_table_create), (elf_s390_check_relocs): Likewise. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. * elflink.c (bfd_elf_link_record_local_dynamic_symbol), (_bfd_elf_link_find_version_dependencies, elf_link_add_object_symbols), (elf_link_add_archive_symbols, compute_bucket_count), (bfd_elf_size_dynsym_hash_dynstr, _bfd_elf_link_hash_table_create), (bfd_elf_get_bfd_needed_list, elf_link_swap_symbols_out), (bfd_elf_final_link): Likewise. * elfnn-aarch64.c (elfNN_aarch64_link_hash_table_create), (elfNN_aarch64_setup_section_lists, elfNN_aarch64_check_relocs), (elfNN_aarch64_new_section_hook): Likewise. * elfnn-ia64.c (elfNN_ia64_object_p): Likewise. * elfnn-riscv.c (riscv_elf_link_hash_table_create), (riscv_elf_check_relocs): Likewise. * elfxx-mips.c (_bfd_mips_elf_new_section_hook), (_bfd_mips_elf_add_symbol_hook, _bfd_mips_elf_check_relocs), (_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_set_section_contents), (_bfd_mips_elf_link_hash_table_create): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_link_hash_table_create), (_bfd_sparc_elf_check_relocs), (_bfd_sparc_elf_new_section_hook): Likewise. * elfxx-tilegx.c (tilegx_elf_link_hash_table_create), (tilegx_elf_check_relocs): Likewise. * elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Likewise. * format.c (bfd_check_format_matches): Likewise. * hash.c (_bfd_stringtab_init): Likewise. * ihex.c (ihex_scan): Likewise. * irix-core.c (irix_core_core_file_p): Likewise. * linker.c (bfd_wrapped_link_hash_lookup), (_bfd_generic_link_hash_table_create), (_bfd_generic_reloc_link_order): Likewise. * lynx-core.c (lynx_core_file_p): Likewise. * netbsd-core.c (netbsd_core_file_p): Likewise. * osf-core.c (osf_core_core_file_p): Likewise. * pdp11.c (some_aout_object_p, mkobject, make_empty_symbol), (link_hash_table_create, aout_link_write_other_symbol): Likewise. * peXXigen.c (_bfd_XX_bfd_copy_private_section_data): Likewise. * peicode.h (pe_mkobject): Likewise. * ppcboot.c (ppcboot_mkobject, ppcboot_canonicalize_symtab): Likewise. * ptrace-core.c (ptrace_unix_core_file_p): Likewise. * sco5-core.c (read_uarea): Likewise. * som.c (hppa_som_gen_reloc_type, som_object_p, som_prep_headers), (som_write_fixups, som_write_space_strings, som_write_symbol_strings), (som_finish_writing, som_canonicalize_symtab, som_new_section_hook), (som_bfd_copy_private_section_data, bfd_som_set_section_attributes), (bfd_som_attach_aux_hdr, som_write_armap): Likewise. * srec.c (srec_scan): Likewise. * syms.c (_bfd_generic_make_empty_symbol): Likewise. * targets.c (bfd_target_list): Likewise. * tekhex.c (first_phase, tekhex_sizeof_headers): Likewise. * trad-core.c (trad_unix_core_file_p): Likewise. * vms-alpha.c (vms_initialize, alpha_vms_bfd_link_hash_table_create), (vms_new_section_hook): Likewise. * wasm-module.c (wasm_make_empty_symbol): Likewise. * xcofflink.c (xcoff_get_section_contents), (_bfd_xcoff_bfd_link_hash_table_create, xcoff_set_import_path), (xcoff_find_function, bfd_xcoff_link_record_set, xcoff_build_ldsym), (bfd_xcoff_size_dynamic_sections, xcoff_link_input_bfd): Likewise.
2020-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2019-12-03PR25230, addr2line fails on dwz outputAlan Modra1-60/+156
This patch remedies the following DW_FORM_GNU_ref_alt related problem: /* FIXME: Do we need to locate the correct CU, in a similar fashion to the code in the DW_FORM_ref_addr case above ? */ Without the correct CU the wrong abbrevs are used, resulting in errors and/or wrong file names. There is scope for further work here. Parsing of CUs should be a two step process, with the first stage just finding the bounds of the CU. This would allow find_abstract_instance to quickly find the CU referenced by DW_FORM_ref_addr or DW_FORM_GNU_ref_alt, then take the second stage of CU parsing where abbrevs, ranges and suchlike consume time and memory. As it is, we just process CUs from the start of .debug_info until we find the one of interest. The testcase in the PR takes 98G of virtual memory. PR 25230 * dwarf2.c (struct dwarf2_debug_file): Add line_table and abbrev_offsets. (struct abbrev_offset_entry): New. (hash_abbrev, eq_abbrev, del_abbrev): New functions. (read_abbrevs): Check whether we have already read abbrevs at given offset, and add new offset/abbrev to hash table. (decode_line_info): Keep line table at offset zero in file struct. Return this for a cu reusing the same dir/file list. (find_abstract_instance): Find cu for DW_FORM_GNU_ref_alt. (_bfd_dwarf2_slurp_debug_info): Create offset/abbrev hash tables. (_bfd_dwarf2_cleanup_debug_info): Adjust deletion of lines and abbrevs.
2019-12-03PR25230, dwarf2.c per file stashAlan Modra1-246/+235
This is just moving things around, in preparation for parsing alt file debug_info. PR 25230 * dwarf2.c (struct dwarf2_debug_file): New struct. (struct dwarf2_debug): Delete fields now in dwarf2_debug_file. Add f, alt fields. (struct comp_unit): Add file field. (read_indirect_string, read_indirect_line_string): Adjust to suit. (read_alt_indirect_string, read_alt_indirect_ref): Likewise. (read_debug_ranges, find_abstract_instance, read_rangelist): Likewise. (_bfd_dwarf2_stash_syms, place_sections): Likewise. (stash_maybe_update_info_hash_tablse): Likewise. (stash_verify_info_hash_table): Likewise. (_bfd_dwarf2_slurp_debug_info): Likewise. (_bfd_dwarf2_find_symbol_bias): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_cleanup_debug_info): Likewise. (read_abbrevs): Add file param and adjust. Update calls. (stash_comp_unit): Likewise. (decode_line_info): Delete stash param and adjust. Update calls. (comp_unit_find_nearest_line): Likewise. (comp_unit_maybe_decode_line_info): Likewise. (comp_unit_find_line): Likewise. (parse_comp_unit): Add file and info_ptr param and adjust. Update calls.
2019-12-03dwarf2.c: read_abbrevs fail cleanup, and offset checkingAlan Modra1-29/+22
read_section does offset checking, reporting an error on out of bounds. There's no need to duplicate the check in functions calling read_section. Also, I spotted a place where a pointer difference expression was being cast to unsigned int, possibly truncating relevant bits on a 64-bit host. * dwarf2.c (read_indirect_string): Don't duplicate offset check done in read_section. (read_indirect_line_string): Likewise. (read_alt_indirect_string): Likewise. (read_alt_indirect_ref): Likewise. (read_abbrevs): Likewise. Free memory on all failure paths. Use correct unsigned type for pointer difference comparison.
2019-12-03dwarf2.c stash->sec_info_ptr and stash->secAlan Modra1-20/+4
These are unused. Remove them. Also fix the wrong sort of 0 being returned from read_alt_indirect_ref. * dwarf2.c (struct dwarf2_debug): Update comments. Remove sec and sec_info_ptr. (_bfd_dwarf2_slurp_debug_info): Don't set sec or sec_info_ptr. (stash_comp_unit): Likewise. (read_alt_indirect_ref): Return NULL not FALSE.
2019-12-03_bfd_dwarf2_find_nearest_line comment fixAlan Modra1-3/+1
These lines should have been removed along with the addr_size parameter. * dwarf2.c (_bfd_dwarf2_find_nearest_line): Correct function comment.
2019-11-27PR23652, Use symbols from debug bfd for _bfd_elf_find_function properlyAlan Modra1-6/+13
There were a number of problems with the previous patch. Firstly, _bfd_dwarf2_stash_syms didn't do anything when the original file had dynamic symbols, and secondly, info found by the symbol search didn't make it out of _bfd_elf_find_nearest_line except in the case of DWARF functions without external linkage. PR 23652 * dwarf2.c (_bfd_dwarf2_stash_syms): Break out of loop on finding matching section. (_bfd_dwarf2_find_nearest_line): Return an int, with value 2 when returning info from the symbol table. Do the _bfd_elf_find_function search also when !found. Call _bfd_dwarf2_stash_syms regardless of symbols. * elf64-alpha.c (elf64_alpha_find_nearest_line): Accept dwarf2 result of 1 only. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise. * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype. * libbfd.h: Regenerate.
2019-11-27PR23652, Use symbols from debug bfd for _bfd_elf_find_functionAlan Modra1-7/+51
Sometimes DWARF info for a function is incomplete, and the function can be retrieved by examining symbols. However, when separate debug files are used it may be that the original file is completely stripped of symbols. This patch teaches BFD to look at symbols from the debug file in that case. The patch also removes arm_elf_find_function, instead implementing elf_backend_maybe_function_sym. arm_elf_find_function was written before the generic _bfd_elf_find_function called maybe_function_sym. aarch64 copied arm, so that file gets the same treatment. There is some chance this will speed up arm and aarch64 lookup of function/line. PR 23652 * dwarf2.c (_bfd_dwarf2_stash_syms): New function. (_bfd_dwarf2_find_nearest_line): Use it here, passing syms to _bfd_elf_find_function. Call _bfd_elf_find_function in cases where _bfd_elf_find_nearest_line would do so. * elf.c (_bfd_elf_find_nearest_line): Omit _bfd_elf_find_function for dwarf2. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly. Tidy. * elf32-arm.c (elf32_arm_maybe_function_sym): New function. (elf_backend_maybe_function_sym): Define. (arm_elf_find_function, elf32_arm_find_nearest_line): Delete. (bfd_elf32_find_nearest_line): Don't define. * elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): New function. (elf_backend_maybe_function_sym): Define. (aarch64_elf_find_function, elfNN_aarch64_find_nearest_line): Delete. (bfd_elfNN_find_nearest_line): Don't define.
2019-10-14qsort: dwarf2.cAlan Modra1-5/+15
This patch ensures qsort stability in line and function sorting done in dwarf2.c. For the line sequences we make use of an existing field that isn't used until later, as a monotonic counter for the qsort. * dwarf2.c (struct lookup_funcinfo): Add idx field. (compare_lookup_funcinfos): Perform final sort on idx. (build_lookup_funcinfo_table): Set idx. (compare_sequences): Perform final sort on num_lines. (build_line_info_table): Set num_lines and line_info_lookup earlier. (sort_line_sequences): Set num_lines for sort.
2019-10-11bfd/dwarf2.c: fix assertion failure in comp_unit_hash_infoMax Filippov1-2/+2
stash_maybe_enable_info_hash_tables sets stash->info_hash_status = STASH_INFO_HASH_ON; regardless of the result of stash_maybe_update_info_hash_tables call. In case it fails this results in repeated invocation of comp_unit_hash_info for the same comp unit and assertion failure in this function. Only set stash->info_hash_status = STASH_INFO_HASH_ON; when stash_maybe_update_info_hash_tables is successful. bfd/ 2019-10-11 Max Filippov <jcmvbkbc@gmail.com> * dwarf2.c (stash_maybe_enable_info_hash_tables): Only set stash->info_hash_status = STASH_INFO_HASH_ON when stash_maybe_update_info_hash_tables succeeds.
2019-10-09PR25070, SEGV in function _bfd_dwarf2_find_nearest_lineAlan Modra1-1/+10
Evil testcase with two debug info sections, with sizes of 2aaaabac4ec1 and ffffd5555453b140 result in a total size of 1. Reading the first section of course overflows the buffer and tramples on other memory. PR 25070 * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Catch overflow of total_size calculation.
2019-10-09PR25078, stack overflow in function find_abstract_instanceAlan Modra1-18/+17
PR 25078 * dwarf2.c (find_abstract_instance): Delete orig_info_ptr, add recur_count. Error on recur_count reaching 100 rather than info_ptr matching orig_info_ptr. Adjust calls.
2019-09-18bfd_asymbol_* macrosAlan Modra1-5/+5
The main point of this patch is to give bfd_get_section a better name, bfd_asymbol_section. bfd/ * bfd-in.h (bfd_asymbol_section): Rename from bfd_get_section. (bfd_get_output_section): Delete. (bfd_asymbol_base): Delete. (bfd_asymbol_section, bfd_asymbol_value, bfd_asymbol_name), (bfd_asymbol_bfd, bfd_asymbol_flavour): Tidy. (bfd_set_asymbol_name): New macro. * bfd-in2.h: Regenerate. * aout-cris.c: Update throughout to use bfd_asymbol_section. * aoutx.h: Likewise. * cofflink.c: Likewise. * dwarf2.c: Likewise. * ecoff.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-mips.c: Likewise. * elf32-score.c: Likewise. * elf32-score7.c: Likewise. * elfn32-mips.c: Likewise. * elfnn-aarch64.c: Likewise. * elfxx-mips.c: Likewise. * linker.c: Likewise. * pdp11.c: Likewise. * elf64-mmix.c (mmix_elf_reloc): Expand bfd_get_output_section. binutils/ * nm.c: Update bfd_get_section to bfd_asymbol_section throughout. * objcopy.c: Likewise. * objdump.c: Likewise. * rdcoff.c: Likewise. * objcopy.c (create_new_symbol): Use bfd_set_asymbol_name. (filter_symbols): Likewise. gas/ * symbols.c (S_IS_LOCAL): Update bfd_get_section to bfd_asymbol_section. gdb/ * arm-tdep.c (arm_record_special_symbol): Update bfd_get_section to bfd_asymbol_section. ld/ * ldcref.c (check_reloc_refs): Update bfd_get_section to bfd_asymbol_section.
2019-09-02Re: Memory leak in dwarf2.cAlan Modra1-18/+20
PR 11983 * dwarf2.c (read_alt_indirect_string): Free debug_filename on success. Tidy. (read_alt_indirect_ref): Likewise.
2019-09-02Memory leak in dwarf2.cAlan Modra1-7/+9
This fixes a small leak of debug_filename. bfd_openr copies the file name since git commit 1be5090bca. PR 11983 * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Free debug_filename on success. Tidy.
2019-08-19Fix N^2 behavior in _bfd_dwarf2_find_symbol_biasTom Tromey1-10/+46
A customer reported a case where addr2line was very slow. We tracked this down to some N^2 behavior in _bfd_dwarf2_find_symbol_bias in the unusual case where no function can be found. This patch fixes the bug, and reduces the runtime for a particular request from 127 seconds to 1 second. bfd/ChangeLog 2019-08-19 Tom Tromey <tromey@adacore.com> * dwarf2.c (_bfd_dwarf2_find_symbol_bias): Create hash table holding symbols.
2019-08-15Fix CU overrun in scan_unit_for_symbolsTom Tromey1-1/+1
A customer program had a DWARF CU that consisted of just a CU DIE, without any children. In this situation, scan_unit_for_symbols will try to read past the end of the current CU, and will take use the first bytes of the next CU as an abbrev, printing an error message. This patch fixes the bug by changing scan_unit_for_symbols to stop at the end of the CU rather than the end of the .debug_info section. bfd/ChangeLog 2019-08-15 Tom Tromey <tromey@adacore.com> * dwarf2.c (scan_unit_for_symbols): Check for end of CU, not end of section.
2019-08-14PR24623, DWARF errorsAlan Modra1-110/+131
PR 24623 * dwarf2.c (stash_comp_unit): New function, extracted from.. (_bfd_dwarf2_find_nearest_line): ..here. (find_abstract_instance): Parse comp units and decode line info as needed.
2019-08-14Use comp_unit_maybe_decode_line_info in more placesAlan Modra1-32/+5
* dwarf2.c (comp_unit_maybe_decode_line_info): Declare. (comp_unit_find_nearest_line): Use it here.. (_bfd_dwarf2_find_symbol_bias): ..and here.
2019-08-14Remove _bfd_dwarf2_find_nearest_line addr_size parameterAlan Modra1-13/+2
This parameter might appear to be used to set up offset_size, but since git commit 024b2372f5 offset_size is either set from the debug_info data or is set to 4. * dwarf2.c (_bfd_dwarf2_find_nearest_line): Remove addr_size parameter. * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype. * coffgen.c (coff_find_nearest_line_with_names): Adjust _bfd_dwarf2_find_nearest_line calls. * elf.c (_bfd_elf_find_nearest_line, _bfd_elf_find_line): Likewise. * elf32-arm.c (elf32_arm_find_nearest_line): Likewise. * elf64-alpha.c (elf64_alpha_find_nearest_line): Likewise. * elfnn-aarch64.c (elfNN_aarch64_find_nearest_line): Likewise. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise. * mach-o.c (bfd_mach_o_find_nearest_line): Likewise. * libbfd.h: Regenerate.
2019-05-28XCOFF linker segmentation faultAlan Modra1-2/+6
The XCOFF linker temporarily trims the output bfd section list, without adjusting section_count to suit. This is a little rude, but the dwarf line number code can easily cope with this situation. So check for a NULL end of list as well as limiting the saved section VMAs to the first section_count list entries. Also fixes -FAIL: Weak test 3 (main, static) (32-bit) -FAIL: Weak test 3 (main, static) (64-bit) PR 24596 * dwarf2.c (save_section_vma, section_vma_same): Check for NULL end of section list as well as section_count. * xcofflink.c (xcoff_link_add_symbols): Fix temporarily changed section list before returning error.
2019-04-03BFD whitespace fixesAlan Modra1-1/+1
* coff-i386.c, * coff-x86_64.c, * coffgen.c, * dwarf2.c, * elf-m10200.c, * elf.c, * elf32-arm.c, * elf32-bfin.c, * elf32-csky.c, * elf32-m32r.c, * elf32-microblaze.c, * elf32-pru.c, * elf32-rx.c, * elf32-xgate.c, * elf64-sparc.c, * elfnn-ia64.c, * elfxx-riscv.c, * elfxx-sparc.c, * linker.c, * mach-o.c, * pe-x86_64.c, * pei-x86_64.c, * plugin.c: Whitespace fixes.
2019-03-14Fix a buffer overrun error when attempting to parse corrupt DWARF information.Nick Clifton1-0/+9
PR 24334 * dwarf2.c (struct dwarf2_debug): Add sec_vma_count field. (save_section_vma): Initialise field to the number of entries in the sec_vma table. (section_vma_same): Check that the number of entries in the sec_vma table matches the number of sections in the bfd.
2019-03-06Fix a segmentation fault triggered by disassembling an EFi file with source ↵Nick Clifton1-1/+1
included. * dwarf2.c (_bfd_dwarf2_find_symbol_bias): Check for a NULL symbol table pointer. * coffgen.c (coff_find_nearest_line_with_names): Do not call _bfd_dwarf2_find_symbol_bias if there is no symbol table available. https://bugzilla.redhat.com/show_bug.cgi?id=1685727
2019-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2018-10-03Fix the handling of inlined frames in DWARF debug info.Millan Wolff1-1/+1
PR 23715 * dwarf2.c (find_abstract_instance): Allow recursive invocations of find_abstract_instance to override the name variable.
2018-09-20Bug 23686, two segment faults in nmAlan Modra1-1/+8
Fixes the bugs exposed by the testcases in the PR, plus two more bugs I noticed when looking at _bfd_stab_section_find_nearest_line. PR 23686 * dwarf2.c (read_section): Error when attempting to malloc "(bfd_size_type) -1". * syms.c (_bfd_stab_section_find_nearest_line): Bounds check function_name. Bounds check reloc address. Formatting. Ensure .stabstr zero terminated.
2018-09-14PR23425, unresolved symbol diagnosticAlan Modra1-1/+3
dwarf2.c code reasonably assumes that debug info is local to a file, an assumption now violated by gcc, resulting in "DWARF error: invalid abstract instance DIE ref" or wrong details when attempting to print linker error messages with file, function and line reported. This is because find_abstract_instance is only prepared to handle DW_FORM_ref_addr when the .debug_info section referenced is in the current file. When that isn't the case, relocations to access another file's .debug_info will typically be against a symbol defined at the start of that .debug_info section, plus an addend. Since the dwarf2.c code only considers the current file's debug info, that symbol will be undefined, resolving to zero. In effect the ref_addr will wrongly resolve to the current file's .debug_info. This patch avoids the problem by treating relocations in debug sections against undefined symbols in a similar manner to the way relocations against symbols defined in discarded sections are resolved. They result in a zero value (except in .debug_ranges) regardless of the addend. PR 23425 * reloc.c (bfd_generic_get_relocated_section_contents): Zero reloc fields in debug sections when reloc is against an undefined symbol and called from bfd_simple_get_relocated_section_contents or similar. * dwarf2.c (find_abstract_instance): Return true for zero offset DW_FORM_ref_addr without returning values.
2018-07-24PR23430, Indices misspelledAlan Modra1-1/+1
PR 23430 include/ * elf/common.h (SHT_SYMTAB_SHNDX): Fix comment typo. bfd/ * dwarf2.c (dwarf_debug_section_enum): Fix comment typo. * elf.c (bfd_section_from_shdr, elf_sort_sections): Likewise. binutils/ * elfcomm.h (struct archive_info): Rename uses_64bit_indicies to uses_64bit_indices. * elfcomm.c (setup_archive): Update uses of above. * readelf.c (process_archive): Likewise. (get_section_type_name): Rename indicies to indices. (get_32bit_elf_symbols, get_64bit_elf_symbols): Likewise. (process_section_groups): Likewise. cpu/ * or1kcommon.cpu (spr-reg-indices): Fix description typo. opcodes/ * or1k-desc.h: Regenerate.
2018-04-17Add a check for a NULL table pointer before attempting to compute a DWARF ↵Nick Clifton1-1/+1
filename. PR 23065 * dwarf2.c (concat_filename): Check for a NULL table pointer.
2018-02-28Catch integer overflows/underflows when parsing corrupt DWARF FORM blocks.Nick Clifton1-15/+21
PR 22895 PR 22893 * dwarf2.c (read_n_bytes): Replace size parameter with dwarf_block pointer. Drop unused abfd parameter. Check the size of the block before initialising the data field. Return the end pointer if the size is invalid. (read_attribute_value): Adjust invocations of read_n_bytes.
2018-02-26ELF linker messagesAlan Modra1-31/+31
This fixes a number of cases where we capitalized error messages or printed a full-stop, and corrects "Dwarf" to "DWARF". bfd/ * dwarf2.c, * elf-attrs.c, * elf-eh-frame.c, * elf.c, * elf32-gen.c, * elflink.c: Standardize error/warning messages. Replace use of linker callback einfo with _bfd_error_handler when possible. ld/ * testsuite/ld-elf/indirect.exp, * testsuite/ld-elf/pr22649-2ab-mips.msg, * testsuite/ld-elf/pr22649-2cd-mips.msg, * testsuite/ld-elf/pr22649.msg, * testsuite/ld-elf/tls_common.exp, * testsuite/ld-elfcomm/elfcomm.exp, * testsuite/ld-arm/attr-merge-incompatible.d, * testsuite/ld-tic6x/attr-compatibility-gnu-other.d, * testsuite/ld-tic6x/attr-compatibility-other-gnu.d, * testsuite/ld-tic6x/attr-compatibility-other-other.d, * testsuite/ld-i386/warn1.d: Update expected error/warning messages.
2018-02-19Don't use %llAlan Modra1-4/+4
* dwarf2.c (read_section): Don't use 'll' format modifier. (find_abstract_instance): Likewise. * elfcore.h (elf_core_file_p): Likewise.
2018-02-19%L conversionsAlan Modra1-10/+12
* bfd-in.h: Include inttypes.h or if not available define PRId64, PRIu64 and PRIx64. * bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Remove support for L modifier to print bfd_vma. * coff-arm.c, * coff-mcore.c, * coff-ppc.c, * coff-rs6000.c, * coff-sh.c, * coff-tic80.c, * coffcode.h, * coffgen.c, * cofflink.c, * compress.c, * dwarf2.c, * elf-m10300.c, * elf.c, * elf32-arc.c, * elf32-arm.c, * elf32-bfin.c, * elf32-cris.c, * elf32-hppa.c, * elf32-i386.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32r.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nds32.c, * elf32-nios2.c, * elf32-ppc.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-score7.c, * elf32-sh.c, * elf32-sh64.c, * elf32-spu.c, * elf32-tic6x.c, * elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c, * elf64-s390.c, * elf64-sh64.c, * elf64-x86-64.c, * elfcode.h, * elfcore.h, * elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c, * elfxx-sparc.c, * elfxx-tilegx.c, * ieee.c, * ihex.c, * mach-o.c, * merge.c, * mmo.c, * peXXigen.c, * xcofflink.c: Replace use of Lx modifier with PRIx64, and cast input to uint64_t, and similarly for Ld and Lu. * bfd-in2.h: Regenerate.
2018-02-06Allow the find_abstract_instance_name() function in the BFD library to also ↵Paul Carroll1-10/+22
return file and line number information. The nm utility supports -l for using debug information to obtain file and line information for each symbol, if available. We have a tool that consumes this information and displays it. This identified a problem with the 'nm' utility. When a source is compiled with -O2, functions can be inlined. The compiler also produces an uninlined copy of the function, normally for linking to other object files. In the case of DWARF2 debug information, the compiler generates debug information to describe a function. If that function is inlined, the compiler then references that debug information from the inlined and uninlined copies of the routine through the use of the DW_AT_abstract_origin reference. When nm is used on such a file, it is not able to find file and line information because that information is present in the common debug information and not at each actual implementation of the function. The 'nm' utility only retrieves the name of the function from the abstract origin debug information and no more. What I am proposing is to modify the find_abstract_instance_name() function (which I renamed to find_abstract_instance() ) to return the name of the function as well as any file and line information. The routine is already parsing all of the debug information in the abstract instance, so it is easy to pick up the file and line information at that time. If, for some reason, the file and line information is not present, the routine behaves as before. For example, if I have a simple test case: int foo(int j) { if (j < 15) j += j << 2; else j += j << 6; return j; } int main (int argc,char **argv) { int i = argc; i += foo(i); return i; } If that test case is compiled with -O2 and then 'nm -l' reads that executable, it currently produces this symbol output (ignoring a lot of library symbols): 8048400 T foo 080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12 If I modify 'nm' to return file and line information for abstract instances, it produces the following output: 08048400 T foo /scratch/pcarroll/its254/test/mytest.c:1 080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12 -------------------------------------------------------------------------- bfd * bfd/dwarf2.c (find_abstract_name): Modified to return file and line information in addition to name, if they can be found.
2018-01-03Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2017-12-06BFD whitespace fixesAlan Modra1-73/+73
Binutils is supposed to use tabs. In my git config I have whitespace = indent-with-non-tab,space-before-tab,trailing-space and I got annoyed enough seeing red in "git diff" output to fix the problems. * doc/header.sed: Trim trailing space when splitting lines. * aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-cris.c, * aout-ns32k.c, * aout-target.h, * aout-tic30.c, * aoutf1.h, * aoutx.h, * arc-got.h, * arc-plt.def, * arc-plt.h, * archive.c, * archive64.c, * archures.c, * armnetbsd.c, * bfd-in.h, * bfd.c, * bfdio.c, * binary.c, * bout.c, * cache.c, * cisco-core.c, * coff-alpha.c, * coff-apollo.c, * coff-arm.c, * coff-h8300.c, * coff-i386.c, * coff-i860.c, * coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mcore.c, * coff-mips.c, * coff-ppc.c, * coff-rs6000.c, * coff-sh.c, * coff-stgo32.c, * coff-tic4x.c, * coff-tic54x.c, * coff-tic80.c, * coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c, * coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c, * coffswap.h, * compress.c, * corefile.c, * cpu-alpha.c, * cpu-arm.c, * cpu-avr.c, * cpu-bfin.c, * cpu-cr16.c, * cpu-cr16c.c, * cpu-crx.c, * cpu-d10v.c, * cpu-frv.c, * cpu-ft32.c, * cpu-i370.c, * cpu-i960.c, * cpu-ia64-opc.c, * cpu-ip2k.c, * cpu-lm32.c, * cpu-m32r.c, * cpu-mcore.c, * cpu-microblaze.c, * cpu-mips.c, * cpu-moxie.c, * cpu-mt.c, * cpu-nios2.c, * cpu-ns32k.c, * cpu-or1k.c, * cpu-powerpc.c, * cpu-pru.c, * cpu-sh.c, * cpu-spu.c, * cpu-v850.c, * cpu-v850_rh850.c, * cpu-xgate.c, * cpu-z80.c, * dwarf1.c, * dwarf2.c, * ecoff.c, * ecofflink.c, * ecoffswap.h, * elf-bfd.h, * elf-eh-frame.c, * elf-hppa.h, * elf-m10200.c, * elf-m10300.c, * elf-s390-common.c, * elf-strtab.c, * elf-vxworks.c, * elf.c, * elf32-am33lin.c, * elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-avr.h, * elf32-bfin.c, * elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c, * elf32-i860.c, * elf32-i960.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68hc1x.c, * elf32-m68hc1x.h, * elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c, * elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nds32.h, * elf32-nios2.c, * elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-ppc.h, * elf32-pru.c, * elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-score.h, * elf32-score7.c, * elf32-sh-symbian.c, * elf32-sh.c, * elf32-sh64.c, * elf32-sparc.c, * elf32-spu.c, * elf32-tic6x.c, * elf32-tilegx.c, * elf32-tilegx.h, * elf32-tilepro.c, * elf32-tilepro.h, * elf32-v850.c, * elf32-vax.c, * elf32-wasm32.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xgate.h, * elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-ppc.c, * elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c, * elf64-tilegx.c, * elf64-tilegx.h, * elf64-x86-64.c, * elfcore.h, * elflink.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-aarch64.c, * elfxx-aarch64.h, * elfxx-ia64.c, * elfxx-ia64.h, * elfxx-mips.c, * elfxx-riscv.c, * elfxx-sparc.c, * elfxx-tilegx.c, * elfxx-x86.c, * elfxx-x86.h, * freebsd.h, * hash.c, * host-aout.c, * hp300hpux.c, * hppabsd-core.c, * hpux-core.c, * i386aout.c, * i386linux.c, * i386lynx.c, * i386mach3.c, * i386msdos.c, * i386netbsd.c, * ieee.c, * ihex.c, * irix-core.c, * libaout.h, * libbfd-in.h, * libbfd.c, * libcoff-in.h, * libnlm.h, * libpei.h, * libxcoff.h, * linker.c, * lynx-core.c, * m68k4knetbsd.c, * m68klinux.c, * m68knetbsd.c, * m88kmach3.c, * mach-o-aarch64.c, * mach-o-arm.c, * mach-o-i386.c, * mach-o-target.c, * mach-o-x86-64.c, * mach-o.c, * mach-o.h, * merge.c, * mipsbsd.c, * mmo.c, * netbsd.h, * netbsd-core.c, * newsos3.c, * nlm-target.h, * nlm32-ppc.c, * nlm32-sparc.c, * nlmcode.h, * ns32k.h, * ns32knetbsd.c, * oasys.c, * opncls.c, * pc532-mach.c, * pdp11.c, * pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-mips.c, * pe-x86_64.c, * peXXigen.c, * pef.c, * pef.h, * pei-arm.c, * pei-i386.c, * pei-mcore.c, * pei-x86_64.c, * peicode.h, * plugin.c, * ppcboot.c, * ptrace-core.c, * reloc.c, * riscix.c, * rs6000-core.c, * section.c, * som.c, * som.h, * sparclinux.c, * sparcnetbsd.c, * srec.c, * stabs.c, * sunos.c, * syms.c, * targets.c, * tekhex.c, * trad-core.c, * vax1knetbsd.c, * vaxnetbsd.c, * verilog.c, * versados.c, * vms-alpha.c, * vms-lib.c, * vms-misc.c, * wasm-module.c, * wasm-module.h, * xcofflink.c, * xsym.c, * xsym.h: Whitespace fixes. * bfd-in2.h, * libbfd.h, * libcoff.h: Regenerate.
2017-10-09PR22212, memory leak in nmAlan Modra1-0/+4
PR 22212 * dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Free funcinfo_hash_table and varinfo_hash_table.
2017-10-01PR21957, addr2line incorrectly handles non-increasing sequences in line tableAlan Modra1-4/+3
PR 21957 * dwarf2.c (new_line_sorts_after): Remove end_sequence comparison. (add_line_info): Always put end_sequence last.
2017-10-01PR22047, Heap out of bounds read in parse_comp_unitAlan Modra1-38/+15
Like the PR22230 fix, we can allocate a buffer with an extra byte rather than letting bfd_simple_get_relocated_section_contents malloc and return a buffer. Much better than allocating another buffer afterwards. PR 22047 * dwarf2.c (read_section): Allocate buffer with extra byte for bfd_simple_get_relocated_section_contents rather than copying afterwards.
2017-09-26Tidy reading data in read_formatted_entriesAlan Modra1-30/+7
Using read_attribute_value accomplishes two things: It checks for unexpected formats, and ensures the buffer pointer always increments. PR 22210 * dwarf2.c (read_formatted_entries): Use read_attribute_value to read data.
2017-09-26Avoid needless resource usage when processing a corrupt DWARF directory or ↵Nick Clifton1-0/+10
file name table. PR 22210 * dwarf2.c (read_formatted_entries): Fail early if we know that the loop parsing data entries will overflow the end of the section.
2017-09-26PR22209, invalid memory read in find_abstract_instance_nameAlan Modra1-15/+43
This patch adds bounds checking for DW_FORM_ref_addr die refs, and calculates them relative to the first .debug_info section. See the big comment for why calculating relative to the current .debug_info section was wrong for relocatable object files. PR 22209 * dwarf2.c (struct comp_unit): Delete sec_info_ptr field. (find_abstract_instance_name): Calculate DW_FORM_ref_addr relative to stash->info_ptr_memory, and check die_ref is within that memory. Set info_ptr_end correctly when another CU is refd. Check die_ref for DW_FORM_ref4 etc. is within CU.
2017-09-26PR22205, .debug_line file table NULL filenameAlan Modra1-22/+13
The PR22200 fuzzer testcase found one way to put NULLs into .debug_line file tables. PR22205 finds another. This patch gives up on trying to prevent NULL files in the file table and instead just copes with them. Arguably, this is better than giving up and showing no info from .debug_line. I've also fixed a case where the fairly recent DWARF5 support in handling broken DWARG could result in uninitialized memory reads, and made a small tidy. PR 22205 * dwarf2.c (concat_filename): Return "<unknown>" on NULL filename. (read_formatted_entries): Init "fe". (decode_line_info <DW_LNE_define_file>): Use line_info_add_file_name.
2017-09-26PR22204, Lack of DW_LNE_end_sequence causes "infinite" loopAlan Modra1-1/+1
PR 22204 * dwarf2.c (decode_line_info): Ensure line_ptr stays within bounds in inner loop.
2017-09-25PR22201, DW_AT_name with out of bounds referenceAlan Modra1-2/+4
DW_AT_name ought to always have a string value. PR 22201 * dwarf2.c (scan_unit_for_symbols): Ignore DW_AT_name unless it has string form. (parse_comp_unit): Likewise.