diff options
author | Sterling Augustine <saugustine@google.com> | 2013-07-29 18:29:12 +0000 |
---|---|---|
committer | Sterling Augustine <saugustine@google.com> | 2013-07-29 18:29:12 +0000 |
commit | 234d4ab880bf72f0a0c678c551d8245e32ce86fc (patch) | |
tree | 1bf01149ded8212bce541fc56894422deccd894e /gold/dwarf_reader.cc | |
parent | c8f30dac8c2799564b9ceff1d299ed876ecda1c9 (diff) | |
download | binutils-gdb-234d4ab880bf72f0a0c678c551d8245e32ce86fc.tar.gz |
2013-07-22 Sterling Augustine <saugustine@google.com>
* 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.
Diffstat (limited to 'gold/dwarf_reader.cc')
-rw-r--r-- | gold/dwarf_reader.cc | 75 |
1 files changed, 54 insertions, 21 deletions
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc index 4233954d178..3aad27f7b3e 100644 --- a/gold/dwarf_reader.cc +++ b/gold/dwarf_reader.cc @@ -478,32 +478,31 @@ Dwarf_ranges_table::lookup_reloc(off_t off, off_t* target_off) // class Dwarf_pubnames_table -// Read the pubnames section SHNDX from the object file. +// Read the pubnames section from the object file. bool -Dwarf_pubnames_table::read_section(Relobj* object, unsigned int shndx) +Dwarf_pubnames_table::read_section(Relobj* object, const unsigned char* symtab, + off_t symtab_size) { section_size_type buffer_size; + unsigned int shndx = 0; - // If we don't have relocations, shndx will be 0, and - // we'll have to hunt for the .debug_pubnames/pubtypes section. - if (shndx == 0) + // Find the .debug_pubnames/pubtypes section. + const char* name = (this->is_pubtypes_ + ? ".debug_pubtypes" + : ".debug_pubnames"); + for (unsigned int i = 1; i < object->shnum(); ++i) { - const char* name = (this->is_pubtypes_ - ? ".debug_pubtypes" - : ".debug_pubnames"); - for (unsigned int i = 1; i < object->shnum(); ++i) - { - if (object->section_name(i) == name) - { - shndx = i; - this->output_section_offset_ = object->output_section_offset(i); - break; - } - } - if (shndx == 0) - return false; + if (object->section_name(i) == name) + { + shndx = i; + this->output_section_offset_ = object->output_section_offset(i); + break; + } } + if (shndx == 0) + return false; + this->buffer_ = object->decompressed_section_contents(shndx, &buffer_size, @@ -511,6 +510,30 @@ Dwarf_pubnames_table::read_section(Relobj* object, unsigned int shndx) if (this->buffer_ == NULL) return false; this->buffer_end_ = this->buffer_ + buffer_size; + + // For incremental objects, we have no relocations. + if (object->is_incremental()) + return true; + + // Find the relocation section + unsigned int reloc_shndx = 0; + unsigned int reloc_type = 0; + for (unsigned int i = 0; i < object->shnum(); ++i) + { + reloc_type = object->section_type(i); + if ((reloc_type == elfcpp::SHT_REL + || reloc_type == elfcpp::SHT_RELA) + && object->section_info(i) == shndx) + { + reloc_shndx = i; + break; + } + } + + this->reloc_mapper_ = make_elf_reloc_mapper(object, symtab, symtab_size); + this->reloc_mapper_->initialize(reloc_shndx, reloc_type); + this->reloc_type_ = reloc_type; + return true; } @@ -519,6 +542,9 @@ Dwarf_pubnames_table::read_section(Relobj* object, unsigned int shndx) bool Dwarf_pubnames_table::read_header(off_t offset) { + // Make sure we have actually read the section. + gold_assert(this->buffer_ != NULL); + // Correct the offset. For incremental update links, we have a // relocated offset that is relative to the output section, but // here we need an offset relative to the input section. @@ -530,16 +556,20 @@ Dwarf_pubnames_table::read_header(off_t offset) const unsigned char* pinfo = this->buffer_ + offset; // Read the unit_length field. - uint32_t unit_length = this->dwinfo_->read_from_pointer<32>(pinfo); + uint64_t unit_length = this->dwinfo_->read_from_pointer<32>(pinfo); pinfo += 4; if (unit_length == 0xffffffff) { unit_length = this->dwinfo_->read_from_pointer<64>(pinfo); + this->unit_length_ = unit_length + 12; pinfo += 8; this->offset_size_ = 8; } else - this->offset_size_ = 4; + { + this->unit_length_ = unit_length + 4; + this->offset_size_ = 4; + } // Check the version. unsigned int version = this->dwinfo_->read_from_pointer<16>(pinfo); @@ -547,6 +577,9 @@ Dwarf_pubnames_table::read_header(off_t offset) if (version != 2) return false; + this->reloc_mapper_->get_reloc_target(pinfo - this->buffer_, + &this->cu_offset_); + // Skip the debug_info_offset and debug_info_size fields. pinfo += 2 * this->offset_size_; |