From 234d4ab880bf72f0a0c678c551d8245e32ce86fc Mon Sep 17 00:00:00 2001 From: Sterling Augustine Date: Mon, 29 Jul 2013 18:29:12 +0000 Subject: 2013-07-22 Sterling Augustine * 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. --- gold/dwarf_reader.h | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'gold/dwarf_reader.h') diff --git a/gold/dwarf_reader.h b/gold/dwarf_reader.h index 9ee483c..9cf22ff 100644 --- a/gold/dwarf_reader.h +++ b/gold/dwarf_reader.h @@ -400,7 +400,7 @@ class Dwarf_pubnames_table 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), - output_section_offset_(0) + output_section_offset_(0), unit_length_(0), cu_offset_(0) { } ~Dwarf_pubnames_table() @@ -409,14 +409,27 @@ class Dwarf_pubnames_table delete[] this->buffer_; } - // Read the pubnames section SHNDX from the object file. + // Read the pubnames section from the object file, using the symbol + // table for relocating it. bool - read_section(Relobj* object, unsigned int shndx); + read_section(Relobj* object, const unsigned char* symbol_table, + off_t symtab_size); // Read the header for the set at OFFSET. bool read_header(off_t offset); + // Return the offset to the cu within the info or types section. + off_t + cu_offset() + { return this->cu_offset_; } + + // Return the size of this subsection of the table. The unit length + // doesn't include the size of its own field. + off_t + subsection_size() + { return this->unit_length_; } + // Read the next name from the set. const char* next_name(); @@ -440,6 +453,15 @@ class Dwarf_pubnames_table // relocated data will be relative to the output section, and need // to be corrected before reading data from the input section. uint64_t output_section_offset_; + // Fields read from the header. + uint64_t unit_length_; + off_t cu_offset_; + + // Track relocations for this table so we can find the CUs that + // correspond to the subsections. + Elf_reloc_mapper* reloc_mapper_; + // Type of the relocation section (SHT_REL or SHT_RELA). + unsigned int reloc_type_; }; // This class represents a DWARF Debug Info Entry (DIE). @@ -747,6 +769,21 @@ class Dwarf_info_reader set_abbrev_shndx(unsigned int abbrev_shndx) { this->abbrev_shndx_ = abbrev_shndx; } + // Return a pointer to the object file's ELF symbol table. + const unsigned char* + symtab() const + { return this->symtab_; } + + // Return the size of the object file's ELF symbol table. + off_t + symtab_size() const + { return this->symtab_size_; } + + // Return the offset of the current compilation unit. + off_t + cu_offset() const + { return this->cu_offset_; } + protected: // Begin parsing the debug info. This calls visit_compilation_unit() // or visit_type_unit() for each compilation or type unit found in the @@ -785,16 +822,6 @@ class Dwarf_info_reader object() const { return this->object_; } - // Return a pointer to the object file's ELF symbol table. - const unsigned char* - symtab() const - { return this->symtab_; } - - // Return the size of the object file's ELF symbol table. - off_t - symtab_size() const - { return this->symtab_size_; } - // Checkpoint the relocation tracker. uint64_t get_reloc_checkpoint() const -- cgit v1.1