From ec673e648cf7b2fa6a03342b0bca3ed3855f002f Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 28 Jan 2014 15:35:47 -0800 Subject: Add .gdb_index version 7 support. 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 * gold/dwarf_reader.cc: include (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. --- gold/dwarf_reader.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'gold/dwarf_reader.h') diff --git a/gold/dwarf_reader.h b/gold/dwarf_reader.h index bbd9667..3afc6e2 100644 --- a/gold/dwarf_reader.h +++ b/gold/dwarf_reader.h @@ -400,7 +400,8 @@ class Dwarf_pubnames_table public: Dwarf_pubnames_table(Dwarf_info_reader* dwinfo, bool is_pubtypes) : dwinfo_(dwinfo), buffer_(NULL), buffer_end_(NULL), owns_buffer_(false), - offset_size_(0), pinfo_(NULL), is_pubtypes_(is_pubtypes), + offset_size_(0), pinfo_(NULL), end_of_table_(NULL), + is_pubtypes_(is_pubtypes), is_gnu_style_(false), output_section_offset_(0), unit_length_(0), cu_offset_(0) { } @@ -431,9 +432,10 @@ class Dwarf_pubnames_table subsection_size() { return this->unit_length_; } - // Read the next name from the set. + // Read the next name from the set. If the pubname table is gnu-style, + // FLAG_BYTE is set to the high-byte of a gdb_index version 7 cu_index. const char* - next_name(); + next_name(uint8_t* flag_byte); private: // The Dwarf_info_reader, for reading data. @@ -447,8 +449,13 @@ class Dwarf_pubnames_table unsigned int offset_size_; // The current position within the buffer. const unsigned char* pinfo_; + // The end of the current pubnames table. + const unsigned char* end_of_table_; // TRUE if this is a .debug_pubtypes section. bool is_pubtypes_; + // Gnu-style pubnames table. This style has an extra flag byte between the + // offset and the name, and is used for generating version 7 of gdb-index. + bool is_gnu_style_; // For incremental update links, this will hold the offset of the // input section within the output section. Offsets read from // relocated data will be relative to the output section, and need -- cgit v1.1