diff options
author | Ian Lance Taylor <iant@google.com> | 2007-11-12 19:56:20 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-11-12 19:56:20 +0000 |
commit | 24badc6562b8153e0181f5bd937b5a84aa8a451e (patch) | |
tree | 900542c0029df703022ffee08197d52e712b86b6 /gold/object.cc | |
parent | 386c048c7aebbff667dbbddd6a4b68299d1920dd (diff) | |
download | gdb-24badc6562b8153e0181f5bd937b5a84aa8a451e.zip gdb-24badc6562b8153e0181f5bd937b5a84aa8a451e.tar.gz gdb-24badc6562b8153e0181f5bd937b5a84aa8a451e.tar.bz2 |
From Craig Silverstein: rework DWARF reader code a bit.
Diffstat (limited to 'gold/object.cc')
-rw-r--r-- | gold/object.cc | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/gold/object.cc b/gold/object.cc index 0f655c6..608226f 100644 --- a/gold/object.cc +++ b/gold/object.cc @@ -1093,57 +1093,9 @@ Relocate_info<size, big_endian>::location(size_t, off_t offset) const std::string filename; std::string file_and_lineno; // Better than filename-only, if available. - // The line-number information is in the ".debug_line" section. - unsigned int debug_shndx; - off_t debuglines_size; - const unsigned char* debuglines = NULL; - for (debug_shndx = 0; debug_shndx < this->object->shnum(); ++debug_shndx) - if (this->object->section_name(debug_shndx) == ".debug_line") - { - debuglines = this->object->section_contents( - debug_shndx, &debuglines_size, false); - break; - } - - // Find the relocation section for ".debug_line". - Track_relocs<size, big_endian> track_relocs; - bool got_relocs = false; - for (unsigned int reloc_shndx = 0; - reloc_shndx < this->object->shnum(); - ++reloc_shndx) - { - unsigned int reloc_sh_type = this->object->section_type(reloc_shndx); - if ((reloc_sh_type == elfcpp::SHT_REL - || reloc_sh_type == elfcpp::SHT_RELA) - && this->object->section_info(reloc_shndx) == debug_shndx) - { - got_relocs = track_relocs.initialize(this->object, reloc_shndx, - reloc_sh_type); - break; - } - } - - // Finally, we need the symtab section to interpret the relocs. - unsigned int symtab_shndx; - off_t symtab_size; - const unsigned char* symtab = NULL; - for (symtab_shndx = 0; symtab_shndx < this->object->shnum(); ++symtab_shndx) - if (this->object->section_type(symtab_shndx) == elfcpp::SHT_SYMTAB) - { - symtab = this->object->section_contents( - symtab_shndx, &symtab_size, false); - break; - } - - // If we got all three sections we need, we can try to read debug info. - if (debuglines != NULL && got_relocs && symtab != NULL) - { - Dwarf_line_info<size, big_endian> line_info(debuglines, debuglines_size, - &track_relocs, - symtab, symtab_size); - line_info.read_line_mappings(); - file_and_lineno = line_info.addr2line(this->data_shndx, offset); - } + Dwarf_line_info<size, big_endian> line_info(this->object); + // This will be "" if we failed to parse the debug info for any reason. + file_and_lineno = line_info.addr2line(this->data_shndx, offset); std::string ret(this->object->name()); ret += ':'; |