aboutsummaryrefslogtreecommitdiff
path: root/gold/gdb-index.cc
AgeCommit message (Collapse)AuthorFilesLines
2014-01-28Add .gdb_index version 7 support.Cary Coutant1-9/+23
This patch adds support for .gdb_index version 7, which adds several flag bits to the symbol index. It also fixes a problem where it did not handle compressed debug sections correctly. Tested with a google/gcc-4_8 branch compiler, which supports the -ggnu-pubnames option to generate .debug_gnu_pubnames/pubtypes tables. (We will submit that patch to GCC when stage 1 reopens.) 2014-01-28 Cary Coutant <ccoutant@google.com> * gold/dwarf_reader.cc: include <utility> (for make_pair). (Dwarf_abbrev_table::do_read_abbrevs): Check for compressed debug sections. (Dwarf_ranges_table::read_ranges_table): Likewise. (Dwarf_pubnames_table::read_section): Check for GNU-style sections, and for compressed debug sections. (Dwarf_pubnames_table::read_header): Compute end address of table. (Dwarf_pubnames_table::next_name): Return flag_byte. Check for end of list by offset, not by offset == 0. (Dwarf_info_reader::do_read_string_table): Check for compressed debug sections. * gold/dwarf_reader.h (Dwarf_pubnames_table::Dwarf_pubnames_table): Initialize new data members. (Dwarf_pubnames_table::next_name): return flag_byte. (Dwarf_pubnames_table::end_of_table_): New data member. (Dwarf_pubnames_table::is_gnu_style_): New data member. * gold/gdb-index.cc (gdb_index_version): Update to version 7. (Gdb_index_info_reader::read_pubtable): Read flag_byte. (Gdb_index_info_reader::read_pubnames_and_pubtypes): Don't read skeleton type unit DIEs. (Gdb_index::add_symbol): Add flag_byte; adjust all callers. (Gdb_index::do_write): Write flag_byte. * gold/gdb-index.h (Gdb_index::add_symbol): Add flags parameter. (Gdb_index::Cu_vector): Store flags along with cu indexes. * gold/testsuite/gdb_index_test_3.sh: Allow versions 4-7. * gold/testsuite/gdb_index_test_comm.sh: Likewise.
2013-10-31Restore support for dwp v2 DWARF package file format.Cary Coutant1-4/+5
gold/ * dwarf_reader.cc (Dwarf_info_reader::visit_type_unit): Add tu_length parameter. Adjust all callers. * dwarf_reader.h (Dwarf_info_reader::visit_type_unit): Likewise. * dwp.cc: Include dwarf.h. (Section_bounds): New struct type. (Unit_set): New struct type. (Dwo_file::Dwo_file): Initialize new data member. (Dwo_file::read_compunit_index, Dwo_file::read_typeunit_index): Combine and rename to... (Dwo_file::read_unit_index): ...this. (Dwo_file::sized_read_compunit_index) (Dwo_file::sized_read_typeunit_index): Combine and rename to... (Dwo_file::sized_read_unit_index): ...this. (Dwo_file::copy_section): Remove section_name, is_str_offsets parameters; add section_id parameter. (Dwo_file::add_cu_set, Dwo_file::add_tu_set): Combine and rename to... (Dwo_file::add_unit_set): ...this. (Dwo_file::shndx_map_): Remove. (Dwo_file::sect_offsets_): New data member. (Dwp_output_file::Dwp_output_file): Initialize new data members. (Dwp_output_file::add_section): Rename to... (Dwp_output_file::add_contribution): ...this. (Dwp_output_file::add_cu_set): Combine parameters into a struct. (Dwp_output_file::add_tu_set): Likewise. (Dwp_output_file::Contribution): New type. (Dwp_output_file::Section::contributions): New data member. (Dwp_output_file::Cu_or_tu_set): Remove. (Dwp_output_file::Section::Section): New ctor. (Dwp_output_file::Dwp_index::Shndx_pool): Remove. (Dwp_output_file::Dwp_index::Section_table): New type. (Dwp_output_file::Dwp_index::Dwp_index): Initialize new data members. (Dwp_output_file::Dwp_index::enter_set): Change type of "set" parameter. (Dwp_output_file::Dwp_index::shndx_pool): Remove. (Dwp_output_file::Dwp_index::shndx_pool_end): Remove. (Dwp_output_file::Dwp_index::section_table): New member function. (Dwp_output_file::Dwp_index::section_table_end): New member function. (Dwp_output_file::Dwp_index::shndx_pool_size): Remove. (Dwp_output_file::Dwp_index::section_table_rows): New member function. (Dwp_output_file::Dwp_index::section_table_cols): New member function. (Dwp_output_file::Dwp_index::shndx_pool_): Remove. (Dwp_output_file::Dwp_index::section_table_): New data member. (Dwp_output_file::Dwp_index::section_mask_): New data member. (Dwp_output_file::add_output_section): New member function. (Dwp_output_file::write_new_section): New member function. (Dwp_output_file::write_contributions): New member function. (Dwp_output_file::section_id_map_): New data member. (class Dwo_id_info_reader): Remove. (class Unit_reader): New class. (get_dwarf_section_name): New function. (Dwo_file::read_executable): Adjust initializations of class data. (Dwo_file::read): Add support for v2 package file format. (Dwo_file::read_unit_index): Likewise. (Dwo_file::sized_read_unit_index): Likewise. (Dwo_file::copy_section): Likewise. (Dwo_file::add_unit_set): Likewise. (Dwp_output_file::add_output_section): Likewise. (Dwp_output_file::add_contribution): Likewise. (Dwp_output_file::Dwp_index::find_or_add): Use row index to check for empty slot. (Dwp_output_file::Dwp_index::enter_set): Add support for v2 package file format. (Dwp_output_file::Dwp_index::grow): Use row index to check for empty slot. (Dwp_output_file::initialize): Remove unused function. (Dwp_output_file::finalize): Add support for v2 package file format. (Dwp_output_file::write_index): Likewise. * gdb-index.cc (Gdb_index_info_reader::visit_type_unit): Adjust function prototype.
2013-08-07gold/Cary Coutant1-5/+4
Revert support for v2 DWP files: 2013-03-01 Cary Coutant <ccoutant@google.com> Add dwp support for v2 DWARF package file format. * dwarf_reader.cc (Dwarf_info_reader::visit_type_unit): Add tu_length parameter. Adjust all callers. * dwarf_reader.h (Dwarf_info_reader::visit_type_unit): Likewise. * dwp.cc: Include dwarf.h. (Section_bounds): New struct type. (Unit_set): New struct type. (Dwo_file::Dwo_file): Initialize new data member. (Dwo_file::read_compunit_index, Dwo_file::read_typeunit_index): Combine and rename to... (Dwo_file::read_unit_index): ...this. (Dwo_file::sized_read_compunit_index) (Dwo_file::sized_read_typeunit_index): Combine and rename to... (Dwo_file::sized_read_unit_index): ...this. (Dwo_file::copy_section): Remove section_name, is_str_offsets parameters; add section_id parameter. (Dwo_file::add_cu_set, Dwo_file::add_tu_set): Combine and rename to... (Dwo_file::add_unit_set): ...this. (Dwo_file::shndx_map_): Remove. (Dwo_file::sect_offsets_): New data member. (Dwp_output_file::Dwp_output_file): Initialize new data members. (Dwp_output_file::add_section): Rename to... (Dwp_output_file::add_contribution): ...this. (Dwp_output_file::add_cu_set): Combine parameters into a struct. (Dwp_output_file::add_tu_set): Likewise. (Dwp_output_file::Contribution): New type. (Dwp_output_file::Section::contributions): New data member. (Dwp_output_file::Cu_or_tu_set): Remove. (Dwp_output_file::Section::Section): New ctor. (Dwp_output_file::Dwp_index::Shndx_pool): Remove. (Dwp_output_file::Dwp_index::Section_table): New type. (Dwp_output_file::Dwp_index::Dwp_index): Initialize new data members. (Dwp_output_file::Dwp_index::enter_set): Change type of "set" parameter. (Dwp_output_file::Dwp_index::shndx_pool): Remove. (Dwp_output_file::Dwp_index::shndx_pool_end): Remove. (Dwp_output_file::Dwp_index::section_table): New member function. (Dwp_output_file::Dwp_index::section_table_end): New member function. (Dwp_output_file::Dwp_index::shndx_pool_size): Remove. (Dwp_output_file::Dwp_index::section_table_rows): New member function. (Dwp_output_file::Dwp_index::section_table_cols): New member function. (Dwp_output_file::Dwp_index::shndx_pool_): Remove. (Dwp_output_file::Dwp_index::section_table_): New data member. (Dwp_output_file::Dwp_index::section_mask_): New data member. (Dwp_output_file::add_output_section): New member function. (Dwp_output_file::write_new_section): New member function. (Dwp_output_file::write_contributions): New member function. (Dwp_output_file::section_id_map_): New data member. (class Dwo_id_info_reader): Remove. (class Unit_reader): New class. (get_dwarf_section_name): New function. (Dwo_file::read_executable): Adjust initializations of class data. (Dwo_file::read): Add support for v2 package file format. (Dwo_file::read_unit_index): Likewise. (Dwo_file::sized_read_unit_index): Likewise. (Dwo_file::copy_section): Likewise. (Dwo_file::add_unit_set): Likewise. (Dwp_output_file::add_output_section): Likewise. (Dwp_output_file::add_contribution): Likewise. (Dwp_output_file::Dwp_index::find_or_add): Use row index to check for empty slot. (Dwp_output_file::Dwp_index::enter_set): Add support for v2 package file format. (Dwp_output_file::Dwp_index::grow): Use row index to check for empty slot. (Dwp_output_file::initialize): Remove unused function. (Dwp_output_file::finalize): Add support for v2 package file format. (Dwp_output_file::write_index): Likewise. * gdb-index.cc (Gdb_index_info_reader::visit_type_unit): Adjust function prototype.
2013-07-292013-07-22 Sterling Augustine <saugustine@google.com>Sterling Augustine1-78/+177
* dwarf_reader.cc (Dwarf_pubnames_table::read_section): Convert parameter shndx to local variable. Add parameters symtab and symtab_size. Scan over section names. Find relocation section corresponding to current section. Create and initialize reloc_mapper_ and reloc_type_. (Dwarf_pubnames_table::read_header): Add assertion. Change unit_length to off_t. Initialize member unit_length_. Fill in field cu_offset_. * dwarf_reader.h (Dwarf_pubnames_table::Dwarf_pubnames_table): Initialize new fields unit_length_ and cu_offset_. (Dwarf_pubnames_table::read_section): Update prototype. (Dwarf_pubnames_table::cu_offset): New member function. (Dwarf_pubnames_table::subsection_size): Likewise. (Dwarf_pubnames_table::cu_offset_, Dwarf_pubnames_table::unit_length): New fields. (Dwarf_info_reader::symtab, Dwarf_info_reader::symtab_size): Make member functions public. * gdb_index.cc (Gdb_index_info_reader::read_pubnames_and_pubtypes): Update comment. Rework logic. Move repeated parts to... (Gdb_index_info_reader::read_pubtable): ...here. New function. (Gdb_index::Gdb_index): Initialize new fields, pubnames_table_, pubtypes_table_, and stmt_list_offset. (Gdb_index::map_pubtable_to_dies, Gdb_index::find_pubname_offset, Gdb_index::find_pubtype_offset, Gdb_index::map_pubnames_and_types_to_dies): Define new functions. (Gdb_index::pubnames_read): Update prototype and rework logic. * gdb_index.h (Gdb_index_info_reader, Dwarf_pubnames_table): Forward declare. (Gdb_index::map_pubtable_to_dies, Gdb_index::find_pubname_offset, Gdb_index::find_pubtype_offset, Gdb_index::pubnames_table) Gdb_index::pubtypes_table, Gdb_index::map_pubnames_and_types_to_dies, Gdb_index::map_pubtable_to_dies): Declare functions. (Gdb_index::pubnames_read): Update declaration. (Gdb_index::Pubname_offset_map): New type. (Gdb_index::cu_pubname_map_, Gdb_index::cu_pubtype_map_, Gdb_index::pubnames_table_, Gdb_index::pubtypes_table_, Gdb_index::stmt_list_offset): Declare. (Gdb_index::pubnames_shndx_, Gdb_index::pubnames_offet_, Gdb_index::pubtypes_object_, Gdb_index::pubtypes_shndx_) Gdb_index::pubtypes_offset_): Remove.
2013-03-01Add dwp support for v2 DWARF package file format.Cary Coutant1-4/+5
gold/ * dwarf_reader.cc (Dwarf_info_reader::visit_type_unit): Add tu_length parameter. Adjust all callers. * dwarf_reader.h (Dwarf_info_reader::visit_type_unit): Likewise. * dwp.cc: Include dwarf.h. (Section_bounds): New struct type. (Unit_set): New struct type. (Dwo_file::Dwo_file): Initialize new data member. (Dwo_file::read_compunit_index, Dwo_file::read_typeunit_index): Combine and rename to... (Dwo_file::read_unit_index): ...this. (Dwo_file::sized_read_compunit_index) (Dwo_file::sized_read_typeunit_index): Combine and rename to... (Dwo_file::sized_read_unit_index): ...this. (Dwo_file::copy_section): Remove section_name, is_str_offsets parameters; add section_id parameter. (Dwo_file::add_cu_set, Dwo_file::add_tu_set): Combine and rename to... (Dwo_file::add_unit_set): ...this. (Dwo_file::shndx_map_): Remove. (Dwo_file::sect_offsets_): New data member. (Dwp_output_file::Dwp_output_file): Initialize new data members. (Dwp_output_file::add_section): Rename to... (Dwp_output_file::add_contribution): ...this. (Dwp_output_file::add_cu_set): Combine parameters into a struct. (Dwp_output_file::add_tu_set): Likewise. (Dwp_output_file::Contribution): New type. (Dwp_output_file::Section::contributions): New data member. (Dwp_output_file::Cu_or_tu_set): Remove. (Dwp_output_file::Section::Section): New ctor. (Dwp_output_file::Dwp_index::Shndx_pool): Remove. (Dwp_output_file::Dwp_index::Section_table): New type. (Dwp_output_file::Dwp_index::Dwp_index): Initialize new data members. (Dwp_output_file::Dwp_index::enter_set): Change type of "set" parameter. (Dwp_output_file::Dwp_index::shndx_pool): Remove. (Dwp_output_file::Dwp_index::shndx_pool_end): Remove. (Dwp_output_file::Dwp_index::section_table): New member function. (Dwp_output_file::Dwp_index::section_table_end): New member function. (Dwp_output_file::Dwp_index::shndx_pool_size): Remove. (Dwp_output_file::Dwp_index::section_table_rows): New member function. (Dwp_output_file::Dwp_index::section_table_cols): New member function. (Dwp_output_file::Dwp_index::shndx_pool_): Remove. (Dwp_output_file::Dwp_index::section_table_): New data member. (Dwp_output_file::Dwp_index::section_mask_): New data member. (Dwp_output_file::add_output_section): New member function. (Dwp_output_file::write_new_section): New member function. (Dwp_output_file::write_contributions): New member function. (Dwp_output_file::section_id_map_): New data member. (class Dwo_id_info_reader): Remove. (class Unit_reader): New class. (get_dwarf_section_name): New function. (Dwo_file::read_executable): Adjust initializations of class data. (Dwo_file::read): Add support for v2 package file format. (Dwo_file::read_unit_index): Likewise. (Dwo_file::sized_read_unit_index): Likewise. (Dwo_file::copy_section): Likewise. (Dwo_file::add_unit_set): Likewise. (Dwp_output_file::add_output_section): Likewise. (Dwp_output_file::add_contribution): Likewise. (Dwp_output_file::Dwp_index::find_or_add): Use row index to check for empty slot. (Dwp_output_file::Dwp_index::enter_set): Add support for v2 package file format. (Dwp_output_file::Dwp_index::grow): Use row index to check for empty slot. (Dwp_output_file::initialize): Remove unused function. (Dwp_output_file::finalize): Add support for v2 package file format. (Dwp_output_file::write_index): Likewise. * gdb-index.cc (Gdb_index_info_reader::visit_type_unit): Adjust function prototype.
2012-10-23gold/Cary Coutant1-2/+2
* dwarf_reader.cc (Dwarf_ranges_table::read_range_list): Call Dwarf_info_reader::read_from_pointer. (Dwarf_pubnames_table::read_header): Likewise. (Dwarf_pubnames_table::next_name): Likewise. (Dwarf_die::read_attributes): Likewise. (Dwarf_die::skip_attributes): Likewise. (Dwarf_info_reader::read_from_pointer): New function template. * dwarf_reader.h (Dwarf_ranges_table): Add dwinfo_. (Dwarf_pubnames_table): Likewise. (Dwarf_info_reader::read_from_pointer): New function template. * gdb-index.cc (Gdb_index_info_reader): Adjust call to Dwarf_pubnames_table ctor.
2012-09-102012-09-10 Sterling Augustine <saugustine@google.com>Sterling Augustine1-6/+14
* gdb-index.cc (Gdb_index::pubnames_read): New parameter. (Gdb_index::pubtypes_read): New parameter. (Gdb_index_info_reader::read_pubnames_and_pubtypes): Add parameters to calls. * gdb-index.h (Gdb_index): New fields pubnames_object_ and pubtypes_object_.
2012-05-01gold: Handle DW_AT_high_pc as offset from DW_AT_low_pc in gdb-index.cc.Mark Wielaard1-3/+9
* dwarf_reader.cc (Dwarf_die::address_attribute): New function. * dwarf_reader.h (Dwarf_die::address_attribute): Likewise. * gdb-index.cc (Gdb_index_info_reader::record_cu_ranges): Handle DW_AT_high_pc as offset from DW_AT_low_pc. * testsuite/Makefile.am (gdb_index_test_3.sh): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test_3.c: New test source file. * testsuite/gdb_index_test_3.sh: New test source file.
2012-04-23elfcpp/Cary Coutant1-2/+3
* elfcpp_swap.h (struct Swap_aligned32): New template. gold/ * gdb-index.cc (Gdb_index::do_write): Use Swap_aligned32 for writing CU range table of gdb index.
2012-04-17gold: Fix 64-bit sparc GOLD crash in gdb-index code.David S. Miller1-2/+2
gold/ * gdb-index.cc (Gdb_index::do_write): Use Swap_unaligned when writing out 64-bit part of ranges.
2012-04-09 * gdb-index.cc (Gdb_index_info_reader::record_cu_ranges): AllowCary Coutant1-1/+1
low_pc == 0.
2012-03-212012-03-21 Cary Coutant <ccoutant@google.com>Cary Coutant1-0/+1229
* Makefile.am: Add gdb-index.cc, gdb-index.h. * Makefile.in: Regenerate. * dwarf_reader.cc (Sized_elf_reloc_mapper::do_initialize): New function. (Sized_elf_reloc_mapper::symbol_section): New function. (Sized_elf_reloc_mapper::do_get_reloc_target): New function. (make_elf_reloc_mapper): New function. (Dwarf_abbrev_table::clear_abbrev_codes): New function. (Dwarf_abbrev_table::do_read_abbrevs): New function. (Dwarf_abbrev_table::do_get_abbrev): New function. (Dwarf_ranges_table::read_ranges_table): New function. (Dwarf_ranges_table::read_range_list): New function. (Dwarf_pubnames_table::read_section): New function. (Dwarf_pubnames_table::read_header): New function. (Dwarf_pubnames_table::next_name): New function. (Dwarf_die::Dwarf_die): New function. (Dwarf_die::read_attributes): New function. (Dwarf_die::skip_attributes): New function. (Dwarf_die::set_name): New function. (Dwarf_die::set_linkage_name): New function. (Dwarf_die::attribute): New function. (Dwarf_die::string_attribute): New function. (Dwarf_die::int_attribute): New function. (Dwarf_die::uint_attribute): New function. (Dwarf_die::ref_attribute): New function. (Dwarf_die::child_offset): New function. (Dwarf_die::sibling_offset): New function. (Dwarf_info_reader::check_buffer): New function. (Dwarf_info_reader::parse): New function. (Dwarf_info_reader::do_parse): New function. (Dwarf_info_reader::do_read_string_table): New function. (Dwarf_info_reader::lookup_reloc): New function. (Dwarf_info_reader::get_string): New function. (Dwarf_info_reader::visit_compilation_unit): New function. (Dwarf_info_reader::visit_type_unit): New function. (Sized_dwarf_line_info::Sized_dwarf_line_info): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::symbol_section): Remove function. (Sized_dwarf_line_info::read_relocs): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter, adjust callers. (Sized_dwarf_line_info::format_file_lineno): Fix type of cast. * dwarf_reader.h: Include <sys/types.h>. (class Track_relocs): Remove forward declaration. (class Elf_reloc_mapper): New class. (class Sized_elf_reloc_mapper): New class. (class Dwarf_abbrev_table): New class. (class Dwarf_range_list): New class. (class Dwarf_ranges_table): New class. (class Dwarf_pubnames_table): New class. (class Dwarf_die): New class. (class Dwarf_info_reader): New class. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter. (Sized_dwarf_line_info::symbol_section): Remove member function. * dynobj.h (Sized_dynobj::do_section_contents): Refactor code from base class. * gdb-index.cc: New source file. * gdb-index.h: New source file. * incremental.cc (Sized_relobj_incr::do_layout): Track .debug_info and .debug_types sections, call Layout::add_to_gdb_index. (Sized_relobj_incr::do_section_name): Implement. (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type; Implement. (Sized_incr_dynobj::do_section_contents): Adjust parameter list and return type. * incremental.h (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type. (Sized_incr_dynobj::do_section_contents): Likewise. * layout.cc: Include gdb-index.h. (Layout::Layout): Initialize gdb_index_data_. (Layout::init_fixed_output_section): Check for .gdb_index section. (Layout::add_to_gdb_index): New function. Instantiate. * layout.h: Add forward declaration for class Gdb_index. (Layout::add_to_gdb_index): New member function. (Layout::gdb_index_data_): New data member. * main.cc: Include gdb-index.h. (main): Print statistics for gdb index. * object.cc (Object::section_contents): Move code into do_section_contents. (need_decompressed_section): Check for sections needed when building gdb index. (build_compressed_section_map): Likewise. (Sized_relobj_file::do_read_symbols): Need local symbols when building gdb index. (Sized_relobj_file::do_layout): Track .debug_info and .debug_types sections; call Layout::add_to_gdb_index. (Sized_relobj_file::do_decompressed_section_contents): Call do_section_contents directly. * object.h (Object::do_section_contents): Adjust parameter list and return type. (Object::do_decompressed_section_contents): Call do_section_contents directly. (Sized_relobj_file::do_section_contents): Adjust parameter list and return type. * options.h (class General_options): Add --gdb-index option. * plugin.cc (Sized_pluginobj::do_section_contents): Adjust parameter list and return type. * plugin.h (Sized_pluginobj::do_section_contents): Likewise. * reloc.h (Track_relocs::checkpoint): New function. (Track_relocs::reset): New function. * testsuite/Makefile.am (gdb_index_test_1.sh, gdb_index_test_2.sh): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test.cc: New test source file. * testsuite/gdb_index_test_1.sh: New test source file. * testsuite/gdb_index_test_2.sh: New test source file.