aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
AgeCommit message (Collapse)AuthorFilesLines
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.
2017-09-25PR22200, DWARF5 .debug_line sanity checkAlan Modra1-0/+7
The format_count entry can't be zero unless the count is also zero. PR 22200 * dwarf2.c (read_formatted_entries): Error on format_count zero.
2017-09-24PR22191, memory leak in dwarf2.cAlan Modra1-2/+6
table->sequences is a linked list before it is replaced by a bfd_alloc array in sort_line_sequences. PR 22191 * dwarf2.c (decode_line_info): Properly free line sequences on error.
2017-09-24PR22187, infinite loop in find_abstract_instance_nameAlan Modra1-25/+51
This patch prevents the simple case of infinite recursion in find_abstract_instance_name by ensuring that the attributes being processed are not the same as the previous call. The patch also does a little cleanup, and leaves in place some changes to the nested_funcs array that I made when I wrongly thought looping might occur in scan_unit_for_symbols. PR 22187 * dwarf2.c (find_abstract_instance_name): Add orig_info_ptr and pname param. Return status. Make name const. Don't abort, return an error. Formatting. Exit if current info_ptr matches orig_info_ptr. Update callers. (scan_unit_for_symbols): Start at nesting_level of zero. Make nested_funcs an array of structs for extensibility. Formatting.
2017-09-24PR22186, divide-by-zero in decode_line_infoAlan Modra1-0/+2
PR 22186 * dwarf2.c (decode_line_info): Fail on lh.line_range of zero rather than dividing by zero.
2017-09-24PR22169, heap-based buffer overflow in read_1_byteAlan Modra1-3/+4
The .debug_line header length field doesn't include the length field itself, ie. it's the size of the rest of .debug_line. PR 22169 * dwarf2.c (decode_line_info): Correct .debug_line unit_length check.