aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
AgeCommit message (Collapse)AuthorFilesLines
2016-04-04Ignore DWARF debug information with a version of 0 - assume that it is padding.Nick Clifton1-13/+21
PR 19872 bfd * dwarf2.c (parse_comp_unit): Skip warning about unrecognised version number if the version is zero. bin * dwarf.c (display_debug_aranges): Skip warning about unrecognised version number if the version is zero.
2016-03-22Attribute with DW_FORM_flag_presentAlan Modra1-1/+1
PR 19850 * dwarf2.c (read_attribute_value): Skip info_ptr check for DW_FORM_flag_present.
2016-01-28Set BFD_DECOMPRESS to decompress debug sectionsH.J. Lu1-1/+3
We should set BFD_DECOMPRESS to decompress debug sections when reading in DWARF debug sections. bfd/ PR binutils/19523 * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Set BFD_DECOMPRESS to decompress debug sections. binutils/ PR binutils/19523 * Makefile.am (check-DEJAGNU): Pass CC and CC_FOR_BUILD to runtest. * Makefile.in: Regenerated. * testsuite/binutils-all/compress.exp (test_gnu_debuglink): New proc. Run test_gnu_debuglink for native ELF build.
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-12-02addr2line vs. inlined C functions called from C++Alan Modra1-13/+22
In this case the inlined function doesn't have DW_AT_linkage_name in .debug_info, but the language is C++ so find_nearest_line goes looking in the symbol table. Since the function is inlined the enclosing non-inline function symbol is returned from _bfd_elf_find_function, which is wrong. This patch only uses a symbol if its address matches. PR binutils/19315 * dwarf2.c (_bfd_elf_find_function): Return symbol matched. (_bfd_dwarf2_find_nearest_line): Check symbol returned above against dwarf range. * elf-bfd.h (_bfd_elf_find_function): Update prototype.
2015-11-09bfd: Fix left shift of negative value.Dominik Vogt1-2/+2
This patch fixes all occurences of left-shifting negative constants in C code which is undefined by the C standard. bfd/ChangeLog: * elf64-ppc.c (ppc64_elf_size_stubs, ppc64_elf_build_stubs): Fix left shift of negative value. * libbfd.c (safe_read_leb128): Likewise. * dwarf2.c (place_sections): Likewise. * bfd-in.h (align_power): Likewise. * bfd-in2.h (align_power): Likewise.
2015-03-05Allows the binutils to cope with PE binaries where the section addresses ↵Nick Clifton1-0/+51
have been changed, but the DWARF debug info has not been altered. PR binutils/18025 * coffgen.c (coff_find_nearest_line_with_names): If the dwarf2 lookup fails, check for an address bias in the dwarf info, and if one exists, retry the lookup with the biased value. * dwarf2.c (_bfd_dwarf2_find_symbol_bias): New function. Determines if a bias exists bewteen the addresses of functions based on DWARF information vs symbol table information. * libbfd-in.h (_bfd_dwarf2_find_symbol_bias): Prototype. * libbfd.h: Regenerate.
2015-02-15fix dbb3fbbb dwarf2.c breakageAlan Modra1-12/+12
m68hc11-elf +FAIL: 68HC12 indexed addressing mode with 5, 9 and 16-bit offsets (indexed12) m68hc12-elf +FAIL: 68HC12 indexed addressing mode with 5, 9 and 16-bit offsets (indexed12) * dwarf2.c (read_rangelist): Correct buffer overflow check Whitespace throughout file.
2015-02-12Fix memory access violations triggered by running addr2line on fuzzed binaries.Nick Clifton1-130/+278
PR binutils/17512 * dwarf.c (read_1_byte, read_1_signed_byte, read_2_bytes) (read_4_bytes, read_8_bytes, read_n_bytes, read_string) (read_indirect_string, read_alt_indirect_string) (read_alt_indirect_ref, read_address, read_abbrevs) (read_attribute_value, read_attribute, decode_line_info) (find_abstract_instance_name, read_rangelist) (scan_unit_for_symbols, parse_comp_unit) (_bfd_dwarf2_find_nearest_line): Harden DWARF reading code. Pass end pointers to reading functions and check for offsets taking pointers out of range. Replace calls to read_*_leb128 with calls to safe_read_leb128. (* elf64-ppc.c (opd_entry_value): Add a check for an overlarge offset. * syms.c (_bfd_stab_section_find_nearest_line): Add checks for computed file_name address being before the start of the string table.
2015-01-27Fixes for memory access violations triggered by running addr2line on fuzzed ↵Nick Clifton1-1/+16
binaries. PR binutils/17512 * addr2line.c (slurp_symtab): If the symcount is zero, free the symbol table pointer. * dwarf2.c (concat_filename): Check for an empty directory table. (scan_unit_for_symbols): Check for reading off the end of the unit. (parse_comp_unit): Check for a DW_AT_comp_dir attribute with a non-string form. * elf64-ppc.c (opd_entry_value): Fail if there are no relocs available.
2015-01-02ChangeLog rotatation and copyright year updateAlan Modra1-1/+1
2014-12-10Don't return DW_AT_name for function name in C++Alan Modra1-32/+196
DW_AT_name for functions typically just contains the base function name, so lacks namespace, class and parameter information. It would be possible to extract all these from the DWARF, but at a considerable complication of the parser in dwarf2.c, and then you'd need to mangle it all together. Much simpler is to look up the actual symbol. This patch does that, avoiding the extra symbol lookup when the language doesn't do name mangling. PR 17541 * dwarf2.c (struct comp_unit): Add "lang". (non_mangled): New function. (struct funcinfo): Add "is_linkage". Reorder for better packing. Make "name" a const char*. (lookup_address_in_function_table): Delete functionname_ptr param. (find_abstract_instance_name): Add is_linkage param. Set if we have DW_AT_linkage_name or non_mangled DW_AT_name. (scan_unit_for_symbols): Similarly set func->is_linkage. (parse_comp_unit): Stash DW_AT_language. (comp_unit_find_nearest_line): Replace functionname_ptr param with function_ptr param. (_bfd_dwarf2_find_nearest_line): Adjust above calls. Set functionname_ptr from function->name. Call _bfd_elf_find_function to retrieve symbol for function if not linkage name. (_bfd_elf_find_function): Add bfd_target_elf_flavour test, moved from.. * elf.c (elf_find_function): ..here. (_bfd_elf_find_nearest_line): Adjust calls. * elf-bfd.h (_bfd_elf_find_function): Declare.
2014-12-10Don't access elf tdata in dwarf.c without first checking for an ELF bfdAlan Modra1-2/+5
_bfd_dwarf2_find_nearest_line may be called on a COFF bfd. * dwarf2.c (read_address): Check bfd_target_elf_flavour before calling get_elf_backend_data. (_bfd_dwarf2_find_nearest_line): Fix parens.
2014-10-15Merge bfd_find_nearest_line variantsAlan Modra1-62/+20
When bfd_find_nearest_line_discriminator was added, not enough care was taken to ensure all targets had a proper definition of the function. This patch cures that by merging bfd_find_nearest_line_discriminator and bfd_find_nearest_line target implementations. PR 17481 * aoutx.h (NAME (aout, find_nearest_line)): Add "discriminator_ptr" param, group "section" and "offset" params. Zero discriminator. * bfd.c (bfd_find_nearest_line): Implement with new _bfd_find_nearest_line. (bfd_find_nearest_line_discriminator): Likewise. * coff-i386.c (_bfd_generic_find_nearest_line_discriminator): Don't define. * coff-rs6000.c (xcoff_find_nearest_line, xcoff_find_nearest_line_discriminator): Delete. (_bfd_xcoff_find_nearest_line): Don't define. (_bfd_xcoff_find_nearest_line): Define as coff_find_nearest_line. * coff-x86_64.c (_bfd_generic_find_nearest_line_discriminator): Don't define. * coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Adjust. * coffgen.c (coff_find_nearest_line_with_names): Reorder params, adjust _bfd_dwarf2_find_nearest_line call. (coff_find_nearest_line): Add "discriminator_ptr" param, reorder others. Set discriminator. Adjust call. (coff_find_nearest_line_discriminator): Delete. * dwarf1.c (_bfd_dwarf1_find_nearest_line): Reorder params. * dwarf2.c (find_line): Rename to.. (_bfd_dwarf2_find_nearest_line): ..this, reordering params. Simplify setting of do_line. Delete old function. (_bfd_dwarf2_find_line): Delete. * ecoff.c (_bfd_ecoff_find_nearest_line): Reorder params, add discriminator_ptr and set it. * elf-bfd.h (_bfd_elf_find_nearest_line): Update prototype. (_bfd_elf_find_nearest_line_discriminator): Delete. (_bfd_elf_find_line_discriminator): Delete. (_bfd_generic_find_nearest_line_discriminator): Don't define. * elf.c (elf_find_function): Reorder params. (_bfd_elf_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. (_bfd_elf_find_nearest_line_discriminator): Delete. (_bfd_elf_find_line): Adjust call. * elf32-arm.c (arm_elf_find_function): Reorder params. (elf32_arm_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. * elf64-alpha.c (elf64_alpha_find_nearest_line): Similarly. * elfnn-aarch64.c (aarch64_elf_find_function): Reorder params. (elfNN_aarch64_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly. * elfxx-mips.h (_bfd_mips_elf_find_nearest_line): Update prototype. * libaout.h (NAME (aout, find_nearest_line)): Update prototype. * libbfd-in.h (_bfd_nosymbols_find_nearest_line): Update. (_bfd_dwarf1_find_nearest_line): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_find_line): Delete. (_bfd_generic_find_nearest_line_discriminator): Delete. * libbfd.c (_bfd_generic_find_nearest_line_discriminator): Delete. * libcoff-in.h (coff_find_nearest_line): Update prototype. (coff_find_nearest_line_discriminator): Delete. (coff_find_nearest_line_with_names): Update prototype. * libecoff.h (_bfd_ecoff_find_nearest_line): Update prototype. * mach-o.c (bfd_mach_o_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. * mach-o.h (bfd_mach_o_find_nearest_line): Update prototype. * pdp11.c (NAME (aout, find_nearest_line)): Reorder params, add discriminator_ptr and set. * som.c (som_find_nearest_line): Similarly. * targets.c (BFD_JUMP_TABLE_SYMBOLS): Delete entry for _bfd_find_nearest_line_discriminator. (struct bfd_target <_bfd_find_nearest_line>): Adjust prototype. (struct bfd_target <_bfd_find_nearest_line_discriminator>): Delete. * vms-alpha.c (_bfd_vms_find_nearest_dst_line): Rename to.. (_bfd_vms_find_nearest_line): ..this. Reorder params, add "discriminator" and set. (_bfd_vms_find_nearest_line_discriminator): Delete. (_bfd_generic_find_nearest_line_discriminator): Don't define. (alpha_vms_find_nearest_line): Update define. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate.
2014-09-15This fixes a typo in a previous commit.Chen Gang1-1/+1
(find_abstract_instance_name): Use 'form' instead of 'name' for the typo issue, which related with commit 60d77146a249ae9b51d7ce98930cdbedb2cfa352.
2014-06-26Fixes a problem displaying the contents of a binary containing corrupt debugNick Clifton1-4/+18
information, specifically a DW_AT_MIPS_linkage_name attribute that has a numeric value rather than a string value. PR binutils/16949 * dwarf2.c (is_str_attr): New function. (find_abstract_instance_name): Use it to determine when an attribute has a string value.
2014-05-28addr2line: fix missing inlined frames.Tristan Gingold1-9/+18
2014-05-28 Tristan Gingold <gingold@adacore.com> * dwarf2.c (lookup_address_in_function_table): Add best_fit_len to keep the length of the best fit range. (lookup_symbol_in_function_table, info_hash_lookup_funcinfo): Likewise.
2014-04-24PR16867, linking object with separate debug fileAlan Modra1-135/+171
This teaches the DWARF2 find_line functions how to deal with separate debug relocatable object files. Also fixes a major bug: When _bfd_dwarf2_slurp_debug_info was split out, place_sections ran after .debug_info was relocated. This defeated the whole purpose of place_sections. See the comment I added before place_sections. Fixes some minor bugs too: - place_sections didn't set VMA for alloc but non-load sections (bss). - zero size sections can have symbols, so they need their VMA set too. - last_vma was incorrectly adjusted. - my last change to place_sections left VMA unchanged for .debug_info when the linker has mapped input to output sections, but this is wrong since bfd_simple_get_relocated_section_contents unmaps debug sections. PR 16867 * dwarf2.c: Formatting. (struct dwarf2_debug): Make adjusted_section_count signed. (unset_sections): Make i signed. (set_debug_vma): New function. (place_sections): Handle separate debug object file. Set VMA on debug sections, even if they have an output section. Also set VMA on zero size sections, and non-load but alloc sections. Set adjusted_section_count to -1 when no section adjustment. Malloc adjusted_sections. Don't double last_vma. Transfer alloc section VMAs to separate debug file. (_bfd_dwarf2_cleanup_debug_info): Free adjusted_sections. (_bfd_dwarf2_slurp_debug_info): Add do_place parameter. Drop test on symbols being the same before using old stash. Read and use separate debug file symbols. Call place_sections. (find_line): Don't call place_sections here. * libbfd-in.h (_bfd_dwarf2_slurp_debug_info): Update proto. * libbfd.h: Regenerate. * mach-o.c (bfd_mach_o_find_nearest_line): Adjust _bfd_dwarf2_slurp_debug_info call. * simple.c (simple_save_output_info): Clarify comment.
2014-04-23PR ld/16787, stale dwarf2 stashAlan Modra1-7/+78
Throw away the dwarf2 stash if it becomes invalid due to section VMAs changing. It would be nice to reclaim all the bfd_alloc memory here when we throw away the stash, perhaps by putting everything we alloc on a private dwarf2 objalloc, but I haven't done that with this patch. I've also fixed a problem with bfd_perform_relocation losing reloc addends, which meant a second or subsequent look at debug info sections did not properly relocate the sections. I can't see why bfd_perform_relocation should need to change addends except for ld -r, and the history (985fca12, e98e6ec1) doesn't help much. Finally, the patch tweaks place_sections to avoid unnecessary work. If we've mapped input to output sections, then input section VMA isn't used so there's not much point in adjusting it. Incidentally, this also means place_sections isn't effective in all cases. PR ld/16787 * dwarf2.c (struct dwarf2_debug): Add sec_vma field. (place_sections): Do not modify VMA of sections when called from linker after sections have been placed in output sections. Short circuit single section case. (save_section_vma, section_vma_same): New functions. (_bfd_dwarf2_slurp_debug_info): Throw away stash if section VMAs change. * reloc.c (bfd_perform_relocation): Do not modify reloc addend when non-relocatable.
2014-03-05Update copyright yearsAlan Modra1-1/+1
2014-01-28When parsing a DW_FORM_ref_addr attribute the CU containing theNick Clifton1-0/+24
abbreviation may not be the current CU. Thus we need to make sure that when we read the abbreviation we use the correct CU. * dwarf2.c (find_abstract_instance_name): For DW_FORM_ref_addr attributes select the CU containing the abbreviation, which may not be the current CU.
2013-10-25 PR binutils/15994Nick Clifton1-1/+1
* dwarf2.c (lookup_address_in_line_info_table): Change return type to be the range of addresses covered by the table. (comp_unit_find_nearest_line): Likewise. (find_line): Search all CUs. Select the one that matches and covers the smallest address range.
2013-10-25 PR binutils/15994Nick Clifton1-28/+67
* dwarf2.c (lookup_address_in_line_info_table): Change return type to be the range of addresses covered by the table. (comp_unit_find_nearest_line): Likewise. (find_line): Search all CUs. Select the one that matches and covers the smallest address range.
2013-05-29 * dwarf2.c (struct dwarf2_debug): Add fields for handlingNick Clifton1-6/+142
alternate debug info source. (dwarf_debug_sections): Add entries for alternate .debug_str and .debug_info sections. (dwarf_debug_section_enum): Likewise. (read_alt_indirect_string): New function. Handles a DW_FORM_GNU_strp_alt attribute. (read_alt_indirect_ref): New function. Handles a DW_FORM_GNU_ref_alt attribute. (read_attribute_value): Process DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt. (find_abstract_instance_name): Handle DW_FORM_GNU_ref_alt attributes. (_bfd_dwarf2_cleanup_debug_info): Free alternate debug info sources. * opncls.c (GNU_DEBUGALTLINK): Define. (bfd_get_alt_debug_link_info): New function. (separate_alt_debug_file_exists): New function. (find_separate_debug_file): Add parameters for fetch and check functions. (bfd_follow_gnu_debugaltlink): New function. * bfd-in2.h: Regenerate.
2013-01-10Remove trailing white spaces in bfdH.J. Lu1-3/+3
* aout0.c: Remove trailing white spaces. * archive.c: Likewise. * archures.c: Likewise. * bfd-in.h: Likewise. * bfd-in2.h: Likewise. * coff-alpha.c: Likewise. * coff-i860.c: Likewise. * coff-mips.c: Likewise. * coff-ppc.c: Likewise. * coff-tic80.c: Likewise. * coff-x86_64.c: Likewise. * coff-z80.c: Likewise. * coffcode.h: Likewise. * coffgen.c: Likewise. * cofflink.c: Likewise. * compress.c: Likewise. * corefile.c: Likewise. * cpu-arm.c: Likewise. * cpu-avr.c: Likewise. * cpu-bfin.c: Likewise. * cpu-cr16.c: Likewise. * cpu-cr16c.c: Likewise. * cpu-crx.c: Likewise. * cpu-h8300.c: Likewise. * cpu-i386.c: Likewise. * cpu-lm32.c: Likewise. * cpu-m68k.c: Likewise. * cpu-moxie.c: Likewise. * cpu-msp430.c: Likewise. * cpu-sh.c: Likewise. * cpu-xc16x.c: Likewise. * dwarf2.c: Likewise. * ecofflink.c: Likewise. * ecoffswap.h: Likewise. * elf-ifunc.c: Likewise. * elf-m10300.c: Likewise. * elf-vxworks.c: Likewise. * elf32-avr.c: Likewise. * elf32-avr.h: Likewise. * elf32-cr16.c: Likewise. * elf32-cr16c.c: Likewise. * elf32-cris.c: Likewise. * elf32-crx.c: Likewise. * elf32-frv.c: Likewise. * elf32-hppa.c: Likewise. * elf32-i860.c: Likewise. * elf32-ip2k.c: Likewise. * elf32-iq2000.c: Likewise. * elf32-m32c.c: Likewise. * elf32-m68hc1x.c: Likewise. * elf32-msp430.c: Likewise. * elf32-mt.c: Likewise. * elf32-ppc.c: Likewise. * elf32-rl78.c: Likewise. * elf32-s390.c: Likewise. * elf32-score.h: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Likewise. * elf32-spu.c: Likewise. * elf32-tic6x.c: Likewise. * elf32-v850.c: Likewise. * elf32-xc16x.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise. * elfcore.h: Likewise. * elflink.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * elfxx-tilegx.c: Likewise. * ieee.c: Likewise. * libcoff.h: Likewise. * libpei.h: Likewise. * libxcoff.h: Likewise. * linker.c: Likewise. * mach-o-i386.c: Likewise. * mach-o-target.c: Likewise. * mach-o.c: Likewise. * mach-o.h: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pdp11.c: Likewise. * pe-x86_64.c: Likewise. * peXXigen.c: Likewise. * pef-traceback.h: Likewise. * pei-x86_64.c: Likewise. * peicode.h: Likewise. * plugin.c: Likewise. * reloc.c: Likewise. * riscix.c: Likewise. * section.c: Likewise. * som.c: Likewise. * syms.c: Likewise. * tekhex.c: Likewise. * ticoff.h: Likewise. * vaxbsd.c: Likewise. * xcofflink.c: Likewise. * xtensa-isa.c: Likewise.
2012-11-09Remove trailing redundant `;'H.J. Lu1-1/+1
bfd/ * aout-tic30.c (MY_final_link_callback): Remove trailing redundant `;'. * coff-h8500.c (extra_case): Likewise. (bfd_coff_reloc16_get_value): Likewise. * dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Likewise. * elf.c (_bfd_elf_slurp_version_tables): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-v850.c (v850_elf_perform_relocation): Likewise. * opncls.c (bfd_calc_gnu_debuglink_crc32): Likewise. * plugin.c (add_symbols): Likewise. * reloc.c (bfd_check_overflow): Likewise. * vms-lib.c (_bfd_vms_lib_archive_p): Likewise. binutils/ * coffgrok.c (coff_grok): Remove trailing redundant `;'. * resrc.c (open_input_stream): Likewise. gas/ * config/atof-ieee.c (gen_to_words): Remove trailing redundant `;'. * config/atof-vax.c (flonum_gen2vax): Likewise. * config/tc-d10v.c (write_2_short): Likewise. * config/tc-i386-intel.c (i386_intel_simplify): Likewise. * config/tc-s390.c (tc_s390_force_relocation): Likewise. * config/tc-v850.c (md_parse_option): Likewise. * config/tc-xtensa.c (find_address_of_next_align_frag): Likewise. * dwarf2dbg.c (out_header): Likewise. * symbols.c (dollar_label_name): Likewise. (fb_label_name): Likewise. ld/ * testplug.c (record_add_file): Remove trailing redundant `;'. opcodes/ * aarch64-opc.h (gen_mask): Remove trailing redundant `;'. * ia64-gen.c (fetch_insn_class): Likewise.
2012-08-01 * dwarf2.c (struct dwarf2_debug): Add close_on_cleanup.Alan Modra1-3/+8
(_bfd_dwarf2_slurp_debug_info): Set close_on_cleanup if we open gnu_debuglink bfd. (_bfd_dwarf2_cleanup_debug_info): Act on close_on_cleanup.
2012-07-262012-07-26 Teresa Johnson <tejohnson@google.com>Cary Coutant1-0/+2
* bfd/dwarf2.c (find_line): Initialize discriminator_ptr if it is non-NULL.
2012-07-242012-07-24 Teresa Johnson <tejohnson@google.com>Cary Coutant1-10/+29
bfd/ * bfd.c (bfd_find_nearest_line_discriminator): New macro. * coff-rs6000.c: Init _bfd_find_nearest_line_discriminator. * coff64-rs6000.c: Likewise. * dwarf2.c (struct line_info): Add discriminator field. (add_line_info): Fill in new discriminator field. (decode_line_info): Record discriminator information instead of ignoring it. (lookup_address_in_line_info_table): Return discriminator field if requested. (comp_unit_find_nearest_line): Add discriminator argument. (find_line): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_find_line): Likewise. * elf-bfd.h (_bfd_elf_find_nearest_line_discriminator): New. (_bfd_elf_find_line_discriminator): Likewise. (_bfd_generic_find_nearest_line_discriminator): Likewise. Defined. * elf.c (_bfd_elf_find_nearest_line): Change to a wrapper that invokes _bfd_elf_find_nearest_line_discriminator with correct arguments. (_bfd_elf_find_nearest_line_discriminator): New. (_bfd_elf_find_line): Change to a wrapper that invokes _bfd_elf_find_line_discriminator with correct arguments. (_bfd_elf_find_line_discriminator): New. * coffgen.c (coff_find_nearest_line_with_names): Handle new discriminator argument. * elf32-arm.c (elf32_arm_find_nearest_line): Likewise. * elf64-alpha.c (elf64_alpha_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-in.h (_bfd_dwarf2_find_nearest_line): Add discriminator argument. (_bfd_dwarf2_find_line): Likewise. (_bfd_generic_find_nearest_line_discriminator): New. * libbfd.c (_bfd_generic_find_nearest_line_discriminator): New. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. * targets.c (BFD_JUMP_TABLE_SYMBOLS): Initialize _bfd_find_nearest_line_discriminator with _bfd_generic_find_nearest_line_discriminator. (bfd_target): Add _bfd_find_nearest_line_discriminator. binutils/ * addr2line.c (find_address_in_section): Invoke bfd_find_nearest_line_discriminator to get the discriminator. (find_offset_in_section): Likewise. (translate_addresses): Print discriminator if it is non-zero. * objdump.c (show_line): Invoke bfd_find_nearest_line_discriminator to get the discriminator, and keep track of prev_discriminator. Print discriminator if it is non-zero. (disassemble_data): Initialize prev_discriminator. (dump_reloc_set): Invoke bfd_find_nearest_line_discriminator to get the discriminator, and keep track of last_discriminator. Print discriminator if it is non-zero.
2012-05-16 * dwarf2.c: Formatting.Alan Modra1-73/+115
(arange_add): Pass in unit rather than bfd. Update callers. Ignore empty ranges. Don't ask for cleared memory. (parse_comp_unit): Only set unit->base_address if processing DW_TAG_compile_unit. (find_debug_info): Optimise section lookup. (place_sections): Use bfd_alloc for stash->adjusted_sections. (find_line): Match previously parsed comp unit addresses as we do for newly parsed comp units.
2012-05-032012-05-03 Tristan Gingold <gingold@adacore.com>Tristan Gingold1-2/+6
* dwarf2.c (decode_line_info): Ignore DW_LNE_HP_source_file_correlation.
2012-04-27 * dwarf2.c (scan_unit_for_symbols): Account for DW_AT_high_pcMark Wielaard1-0/+9
possibly being relative to DW_AT_low_pc. (parse_comp_unit): Likewise.
2012-01-042012-01-04 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>Tristan Gingold1-109/+125
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Factor out the part which reads DWARF2 and stores in stash from find_line. (find_line) Call _bfd_dwarf2_slurp_debug_info. * libbfd-in.h (_bfd_dwarf2_slurp_debug_info): Add declaration. * libbfd.h (_bfd_dwarf2_slurp_debug_info): Regenerate. * mach-o.c (dsym_subdir): The name of subdir where debug information may be stored. (bfd_mach_o_lookup_uuid_command): New. Lookup a load command whose type is UUID. (bfd_mach_o_dsym_for_uuid_p): New. Check if the specified BFD is corresponding to the executable. (bfd_mach_o_find_dsym): New. Find a debug information BFD in the specified binary file. (bfd_mach_o_follow_dsym): New. Find a debug information BFD for the original BFD. (bfd_mach_o_find_nearest_line): Check dSYM files for Mach-O executables, dylibs, and bundles. (bfd_mach_o_close_and_cleanup): Clean up BFDs for the dSYM file. * mach-o.h (dsym_bfd): The BFD of the dSYM file.
2011-12-132011-12-13 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>Tristan Gingold1-8/+3
* dwarf2.c (bfd_dwarf2_cleanup_debug_info): Accept stash as an argument like other functions to support formats other than ELF. * elf-bfd.h (bfd_dwarf2_cleanup_debug_info): Move to bfd-in.h. * elf.c (_bfd_elf_close_and_cleanup): Pass dwarf2_find_line_info in tdata as a parameter. * libbfd-in.h (bfd_dwarf2_cleanup_debug_info): Move from elf-bfd.h. * libbfd.h (bfd_dwarf2_cleanup_debug_info): Regenerate. * mach-o-target.c (bfd_mach_o_close_and_cleanup): Remove the fallback macro. (bfd_mach_o_find_nearest_line): Likewise. * mach-o.c (bfd_mach_o_find_nearest_line): Add the definition which calls _bfd_dwarf2_find_nearest_line. (bfd_mach_o_close_and_cleanup): Likewise. * mach-o.h (mach_o_data_struct): Add dwarf2_find_line_info. (bfd_mach_o_find_nearest_line): Add declaration. (bfd_mach_o_close_and_cleanup): Add declaration.
2011-09-302011-09-30 Tristan Gingold <gingold@adacore.com>Tristan Gingold1-32/+54
* dwarf2.c (struct dwarf2_debug): Add field debug_sections. (read_section): Add sec argument. Adjust the code to get section names from it. (read_indirect_string): Adjust call to read_section. (read_abbrevs): Ditto. (decode_line_info): Ditto. (read_debug_ranges): Ditto. (DWARF2_DEBUG_INFO, DWARF2_COMPRESSED_DEBUG_INFO): Remove. (find_debug_info): Add debug_sections parameter. Use it instead the above macros. (place_sections): Get section names from stash. (find_line): Add debug_sections argument. Initialize debug_sections field of stash from it. Adjust calls to find_debug_info. (_bfd_dwarf2_find_nearest_line): Add debug_sections argument. Adjust call to find_line. (_bfd_dwarf2_find_line): Adjust call to find_line. * libcoff-in.h (struct dwarf_debug_section): New declaration. (coff_find_nearest_line_with_names): Likewise. * libcoff.h: Regenerate. * libbfd-in.h (struct dwarf_debug_section): Move declaration. (dwarf_debug_sections): Likewise. (_bfd_dwarf2_find_nearest_line): Add debug_sections argument. * libbfd.h: Regenerate. * elf.c (_bfd_elf_find_nearest_line): Adjust call to _bfd_dwarf2_find_nearest_line. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Ditto. * elf64-alpha.c (elf64_alpha_find_nearest_line): Ditto. * elf32-arm.c (elf32_arm_find_nearest_line): Ditto. * coffgen.c (coff_find_nearest_line_with_names): New function. (coff_find_nearest_line): Calls coff_find_nearest_line_with_names. * coff-rs6000.c (xcoff_debug_sections): New constant. (xcoff_find_nearest_line): New function. (rs6000coff_vec): Use xcoff_find_nearest_line. (pmac_xcoff_vec): Ditto.
2011-07-26 * dwarf2.c (dwarf_debug_sections): Add .debug_macroJakub Jelinek1-0/+2
and .zdebug_macro entry. (dwarf_debug_section_enum): Add debug_macro. * NEWS: Mention .debug_macro support. * dwarf.c (read_and_display_attr_value): Don't print a tab if attribute is 0. (get_AT_name): Handle DW_AT_GNU_macros. (get_line_filename_and_dirname, display_debug_macro): New functions. (debug_displays): Add an entry for .debug_macro and .zdebug_macro. * readelf.c (process_section_headers): With do_debug_macinfo handle also .debug_macro sections. * dwarf.h (dwarf_section_display_enum): Add macro.
2011-04-28bfd: constify a few arraysMike Frysinger1-1/+1
2011-04-07 * dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification.Cary Coutant1-0/+1
2011-03-032011-03-03 Michael Snyder <msnyder@vmware.com>Michael Snyder1-1/+1
* dwarf2.c (scan_unit_for_symbols): Stop memory leak.
2010-10-29Add compressed debug section support to binutils and ld.H.J. Lu1-92/+82
bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-07-14 PR ld/11817Cary Coutant1-56/+36
* dwarf2.c (read_section): Revert patch for compressed debug sections. (find_line): Likewise. (read_and_uncompress_section): Remove.
2010-07-06Initialize prev_line.H.J. Lu1-0/+1
2010-07-06 H.J. Lu <hongjiu.lu@intel.com> * dwarf2.c (add_line_info): Initialize prev_line.
2010-07-03bfd/ChangeLog:Cary Coutant1-36/+56
* compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED. * dwarf2.c (read_and_uncompress_section): New function. (read_section): Call it. (find_line): Likewise. binutils/ChangeLog: * objdump.c (load_specific_debug_section): Decompress section contents before applying relocations. * readelf.c (load_specific_debug_section): Update section size after decompression. gas/ChangeLog: * Makefile.am: Add compress-debug.c and compress-debug.h. * Makefile.in: Regenerate. * config.in: Add HAVE_ZLIB_H. * configure.in: Check for zlib.h. * configure: Regenerate. * as.c (parse_args): Add --compress-debug-sections and --nocompress-debug-sections. * as.h (flag_compress_debug): New variable. * compress-debug.c: New file. * compress-debug.h: New file. * write.c: Include compress-debug.h. (compress_frag): New function. (compress_debug): New function. (write_object_file): Compress debug sections if requested.
2010-04-20 * dwarf2.c (find_abstract_instance_name, scan_unit_for_symbols): TreatJakub Jelinek1-2/+6
DW_AT_linkage_name the same as DW_AT_MIPS_linkage_name.
2010-04-05include/Jakub Jelinek1-12/+77
* dwarf2.h (DWARF2_Internal_LineInfo): Add li_max_ops_per_insn field. bfd/ * dwarf2.c (struct line_head): Add maximum_ops_per_insn field. (struct line_info): Add op_index field, change end_sequence type to unsigned char. (new_line_sorts_after): For the same address compare op_index. (add_line_info): Add op_index argument, store it into the structure. (decode_line_info): Complain about unknown versions of .debug_line. Initialize maximum_ops_per_insn. Add op_index state register and track it. binutils/ * dwarf.c (struct State_Machine_Registers): Add op_index field, change end_sequence type to unsigned char. (reset_state_machine): Clear op_index. (process_extended_line_op): For DW_LNE_set_address clear op_index. (display_debug_lines_raw): Initialize li_max_ops_per_insn. Track op_index state machine register and print it if li_max_ops_per_insn is != 1. (display_debug_lines_decoded): Likewise.
2010-04-01 * dwarf2.c (read_attribute_value): Handle CU version 4Jakub Jelinek1-3/+16
for DW_FORM_ref_addr, handle DW_FORM_sec_offset, DW_FORM_exprloc and DW_FORM_flag_present. For unknown form value return NULL. (scan_unit_for_symbols): For DW_AT_location handle DW_FORM_exprloc like DW_FORM_block. (parse_comp_unit): Allow CU version 4.
2010-03-04 PR 11302Alan Modra1-60/+119
* dwarf2.c (read_abbrevs): Return NULL on alloc failures. (read_attribute_value, decode_line_info): Likewise. (add_line_info, read_rangelist): Return FALSE on alloc failures. (arange_add, sort_line_sequences): Likewise. (find_abstract_instance_name): Handle failures from called funcs. (scan_unit_for_symbols, parse_comp_unit, decode_line_info): Likewise. (find_line): Realloc to a temp, and handle alloc fail.
2010-01-19 * dwarf2.c (read_attribute_value): Add DW_FORM_ref_sig8.Cary Coutant1-0/+4
2010-01-11update copyright dateAlan Modra1-1/+1
2010-01-11 PR 6832Alan Modra1-1/+5
* dwarf2.c (struct comp_unit): Add sec_info_ptr. (find_abstract_instance_name): Use it. (parse_comp_unit): Set it.