* 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.
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.
* dwarf2.c (concat_filename): Rename dirname with dir_name
to void shadowing the dirname function.
Rename subdirname with subdir_name to stay consistent with
the new dir_name variable name.
(struct line_info_table): Add num_sequences, remove last_line,
add sequences.
(add_line_info): Add new sequences as necessary.
(compare_sequences): New function.
(sort_line_sequences): New function.
(decode_line_info): Initialize new fields in line table.
Call sort_line_sequences.
(lookup_address_in_line_info_table): Binary search for proper
sequence.
(read_n_bytes): Remove unhelpful comment.
(read_indirect_string): Pass symbol table to read_section in case
the .debug_str section needs relocating.
PR 7037
* elf32-cr16.c (cr16_elf_howto_table): Zero the src_mask field of
the reloc descriptions.
* dwarf2.c (struct adjusted_section): Renamed from struct
loadable_section.
(struct dwarf2_debug): Adjust for renaming. Add version field.
(read_attribute_value): Correctly handle DW_FORM_ref_addr for
DWARF3.
(find_abstract_instance_name): Pass a pointer to
attribute instead of offset. For DW_FORM_ref_addr, get the
entry at the offset from the .debug_info section.
(scan_unit_for_symbols): Update.
(parse_comp_unit): Allow DWARF3. Save the version.
(unset_sections): Update for renaming.
(place_sections): Likewise. Set new VMAs for DWARF sections
also.
* dwarf2.c (struct dwarf2_debug): New variable info_ptr_memory.
(find_line): Use info_ptr_memory instead of sec_info_ptr.
(_bfd_dwarf2_cleanup_debug_info): Likewise.
of unsigned long as last parameter.
(struct dwarf2_debug): Define dwarf_abbrev_size, dwarf_line_size,
dwarf_str_size and dwarf_ranges_size as bfd_size_type instead of
unsigned long.
* Makefile.am (BFD32_LIBS): Add compress.lo.
(BFD32_LIBS_CFILES): Add compress.c.
(BFD_H_FILES): Likewise.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* config.in: Add HAVE_ZLIB_H
* configure.in: Add test for libz and zlib.h
* configure: Regenerate.
* dwarf2.c (read_section): New function.
(read_indirect_string): Call new function read_section.
(read_abbrevs): Likewise.
(decode_line_info): Likewise.
(read_debug_ranges): Likewise.
(find_line): Call new function read_section when just one
.zdebug_info section is found, otherwise read and compress
multiple sections.
(_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr.
* elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix.
(special_sections_z): New struct.
(special_sections): Refer to special_sections_z.
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize
sections named .zdebug_*.
(_bfd_mips_elf_fake_sections): Likewise.
* compress.c: New file.
(bfd_uncompress_section_contents): New function.
bfd/doc/
* Makefile.am (BFD_H_DEP): Add ../compress.c.
* Makefile.in: Regenerate.
binutils/
* config.in: Add HAVE_ZLIB_H
* configure.in: Add test for libz and zlib.h
* configure: Regenerate.
* dwarf.c (debug_displays): Add .zdebug_* strings.
* dwarf.h (struct dwarf_section): Add fields uncompressed_namd
and compressed_name.
* objdump.c (load_debug_section): Call
bfd_uncompress_section_contents when loading a compressed
section.
(dump_dwarf_section): Recognize compressed section name.
(mach_o_dwarf_sections): Rename as
mach_o_uncompressed_dwarf_sections.
(mach_o_compressed_dwarf_sections): New variable.
(generic_dwarf_section): Rename as
generic_uncompressed_dwarf_sections.
(generic_compressed_dwarf_sections): New variable.
(check_mach_o_dwarf): Save and restore
mach_o_compressed_dwarf_sections.
* readelf.c: Add #include for config.h and zlib.h
(process_section_headers): Recognize compressed section name.
(uncompress_section_contents): New function.
(load_debug_section): Call uncompress_section_contents when
loading a compressed section.
(display_debug_section): Recognize compressed section name.
binutils/testsuite:
* binutils-all/objdump.exp: Add test for objdump -s on a file
with a compressed debug section. Add test for objdump -W on a
file that contains a compressed debug section.
* binutils-all/readelf.exp: Call readelf_compressed_wa_test.
(readelf_compressed_wa_test): New function.
* binutils-all/dw2-compressed.S: New file.
* binutils-all/objdump.W: New file.
* binutils-all/objdump.s: New file.
* binutils-all/readelf.wa: New file.
* libbfd.c (bfd_realloc_or_free): New function. Performs like
bfd_realloc, but if the (re)allocation fails, the pointer is
freed.
* libbfd-in.h: Prototype.
* libbfd.h: Regenerate.
* bfdio.c (bfd_bwrite): Use the new function.
(bfd_seek): Likewise.
* bfdwin.c:(bfd_get_file_window): Likewise.
* elf-strtab.c (_bfd_elf_strtab_add): Likewise.
* elf32-ppc.c (ppc_elf_relax_section): Likewise.
* elf32-xtensa.c (vsprintf_msg): Likewise.
* mach-o.c (bfd_mach_o_core_fetch_environment): Likewise.
* stabs.c (_bfd_link_seciton_stabs): Likewise.
* vms-misc.c (_bfd_vms_get_record): Likewise.
* vms-tir.c (check_section): Likewise.
* vms.c (vms_new_section_hook): Likewise.
* elf32-arm.c (elf32_arm_section_map_add): Check that the
allocation of sec_data->map succeeded before using it.
* elflink.c (elf_link_output_sym): Do not overwrite finfo->
symshndxbuf until it is known that the reallocation succeeded.
* dwarf2.c (read_abbrevs): Free the abbreviation table if we run
out of memory.
(decode_line_info): Free the line_info_table before returning a
failure result.
(_bfd_dwarf2_cleanup_debug_info): Free the abbreviation table.
Free the line table. Free the function table. Free the variable
table.
(BFD32_LIBS_CFILES): Add arange-set.c.
(SOURCE_HFILES): Add arange-set.h
(dwarf2.lo): Add dependency upon arange-set.h.
(arange-set.lo): New target.
* Makefile.in: Regenerate.
* arange-set.c: New file.
* arange-set.h: New file.
* dwarf2.c: Include arange-set.h.
(struct dwarf2_debug) Add new fields comp_unit_count and comp_unit_arange_set.
(struct comp_unit) Replace field arange with a new field arange_set.
(dwarf2_arange_set_allocate, dwarf2_arange_set_deallocate,
(dwarf2_combine_arange_value, dwarf2_arange_set_new,
(dwarf2_arange_set_with_value_new, dwarf2_comp_unit_arange_add): New
functions to utilize arange set in dwarf2.c.
(arange_add): Formatting change for a line longer than 80 characters.
(decode_line_info): Replace call target arange_add with
(dwarf2_comp_unit_arange_add.
(read_rangelist_insert_arange_list,
(read_rangelist_comp_unit_arange_add): New functions used as callbacks
for read_rangelist.
(read_rangelist): Change interface to accept a callback and data to
allow caller to select the action peformed on a new range list read.
(scan_unit_for_symbols): Use new interface of read_rangelist.
(parse_comp_unit): Create an arange set for each new comp unit. Use new
interface of read_rangelist. Replace call to arange_add with that to
dwarf2_comp_unit_arange_add.
(comp_unit_contains_address): Replace sequential search with a call to
arange_set_lookup_address, which can handles large set efficiently.
(stash_copy_local_aranges, stash_maybe_enable_arange_set,
(stash_find_nearest_line_fast): New functions maintaining and using a
valued global arange set for all compilation units to speed up
bfd_dwarf2_find_nearest_line.
(find_line): Use global arange set. Replace sequential search over all
compilation units with a call to stash_find_nearest_line_fast. Add
book keeping to count number of compilation units. Replace empty
arange list test with a call to arange_set_empty_p.
2007-09-02 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4986
* dwarf2.c (new_line_sorts_after): Undo the last change.
(add_line_info): Only keep the last entry with the same address
and end sequence.
ld/testsuite/
2007-09-02 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4986
* ld-ia64/line.exp: New.
* ld-ia64/undefined.s: Likewise.
* ld-x86-64/line.exp: Don't check CC.
* dwarf2.c (struct dwarf2_debug): Add new fields to support function and variable info hash tables. Add last_comp_unit, info_hash_count, funcinfo_hash_table, varinfo_hash_table, hash_units_head.
(struct comp_unit): Add prev_unit, cached.
(struct info_list_node, struct info_hash_entry, struct info_hash_table): New.
(info_hash_table_newfunc, create_info_hash_table, insert_info_hash_table, lookup_info_hash_table): New functions implementing function and variable info hash tables.
(scan_unit_for_symbols): Add checks to make sure hash tables are consistent with compilation units.
(comp_unit_maybe_decode_line_info): New function.
(comp_unit_find_line): Use comp_unit_maybe_decode_line_info.
(reverse_funcinfo_list, reverse_varinfo_list, comp_unit_hash_info, info_hash_lookup_funcinfo, info_hash_lookup_varinfo, stash_maybe_update_info_hash_table, stash_verify_info_hash_table, stash_maybe_enable_info_hash_tables, stash_find_line_fast): New functions. Make use of info hash tables to speed up bfd_dwarf2_find_line.
(find_line): Use hash table for faster lookup if it is turned on.
Also add code to maintain bi-directional link in comp units.
(struct dwarf2_debug): Add bfd field to record the bfd containing the debug info.
(parse_comp_unit): Remove ABFD parameter. Instead use the bfd field in the dwarf2_debug structure.
(_bfd_dwarf2_find_nearest_line): If a debug info section could not be found in the current bfd call bfd_follow_gnu_debuglink to see if another file contains the debug information. If it does, open it and continue.
(bfd_dwarf2_find_line): Likewise.