From eea2ce8011a360b7b745b1cbd14e8ef8f310c82c Mon Sep 17 00:00:00 2001 From: iant Date: Tue, 11 Dec 2007 18:17:27 +0000 Subject: [PATCH] From Craig Silverstein: Speed up ODR violation reporting. --- gold/dwarf_reader.cc | 27 +++++++++++++++++---------- gold/dwarf_reader.h | 14 ++++++++++---- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc index efded0ed17..1190066fac 100644 --- a/gold/dwarf_reader.cc +++ b/gold/dwarf_reader.cc @@ -118,7 +118,8 @@ ResetLineStateMachine(struct LineStateMachine* lsm, bool default_is_stmt) } template -Sized_dwarf_line_info::Sized_dwarf_line_info(Object* object) +Sized_dwarf_line_info::Sized_dwarf_line_info(Object* object, + off_t read_shndx) : data_valid_(false), buffer_(NULL), symtab_buffer_(NULL), directories_(), files_(), current_header_index_(-1) { @@ -171,7 +172,7 @@ Sized_dwarf_line_info::Sized_dwarf_line_info(Object* object) // Now that we have successfully read all the data, parse the debug // info. this->data_valid_ = true; - this->read_line_mappings(); + this->read_line_mappings(read_shndx); } // Read the DWARF header. @@ -495,7 +496,8 @@ Sized_dwarf_line_info::process_one_opcode( template unsigned const char* -Sized_dwarf_line_info::read_lines(unsigned const char* lineptr) +Sized_dwarf_line_info::read_lines(unsigned const char* lineptr, + off_t shndx) { struct LineStateMachine lsm; @@ -517,7 +519,8 @@ Sized_dwarf_line_info::read_lines(unsigned const char* lineptr { size_t oplength; bool add_line = this->process_one_opcode(lineptr, &lsm, &oplength); - if (add_line) + if (add_line + && (shndx == -1U || lsm.shndx == -1U || shndx == lsm.shndx)) { Offset_to_lineno_entry entry = { lsm.address, this->current_header_index_, @@ -570,7 +573,7 @@ Sized_dwarf_line_info::read_relocs() template void -Sized_dwarf_line_info::read_line_mappings() +Sized_dwarf_line_info::read_line_mappings(off_t shndx) { gold_assert(this->data_valid_ == true); @@ -580,7 +583,7 @@ Sized_dwarf_line_info::read_line_mappings() const unsigned char* lineptr = this->buffer_; lineptr = this->read_header_prolog(lineptr); lineptr = this->read_header_tables(lineptr); - lineptr = this->read_lines(lineptr); + lineptr = this->read_lines(lineptr, shndx); this->buffer_ = lineptr; } @@ -788,25 +791,29 @@ Dwarf_line_info::one_addr2line(Object* object, { if (parameters->get_size() == 32 && !parameters->is_big_endian()) #ifdef HAVE_TARGET_32_LITTLE - return Sized_dwarf_line_info<32, false>(object).addr2line(shndx, offset); + return Sized_dwarf_line_info<32, false>(object, shndx).addr2line(shndx, + offset); #else gold_unreachable(); #endif else if (parameters->get_size() == 32 && parameters->is_big_endian()) #ifdef HAVE_TARGET_32_BIG - return Sized_dwarf_line_info<32, true>(object).addr2line(shndx, offset); + return Sized_dwarf_line_info<32, true>(object, shndx).addr2line(shndx, + offset); #else gold_unreachable(); #endif else if (parameters->get_size() == 64 && !parameters->is_big_endian()) #ifdef HAVE_TARGET_64_LITTLE - return Sized_dwarf_line_info<64, false>(object).addr2line(shndx, offset); + return Sized_dwarf_line_info<64, false>(object, shndx).addr2line(shndx, + offset); #else gold_unreachable(); #endif else if (parameters->get_size() == 64 && parameters->is_big_endian()) #ifdef HAVE_TARGET_64_BIT - return Sized_dwarf_line_info<64, true>(object).addr2line(shndx, offset); + return Sized_dwarf_line_info<64, true>(object, shndx).addr2line(shndx, + offset); #else gold_unreachable(); #endif diff --git a/gold/dwarf_reader.h b/gold/dwarf_reader.h index 48ded84965..f5221047a6 100644 --- a/gold/dwarf_reader.h +++ b/gold/dwarf_reader.h @@ -89,15 +89,19 @@ class Sized_dwarf_line_info : public Dwarf_line_info { public: // Initializes a .debug_line reader for a given object file. - Sized_dwarf_line_info(Object* object); + // If SHNDX is specified and non-negative, only read the debug + // information that pertains to the specified section. + Sized_dwarf_line_info(Object* object, off_t read_shndx = -1U); private: std::string do_addr2line(unsigned int shndx, off_t offset); // Start processing line info, and populates the offset_map_. + // If SHNDX is non-negative, only store debug information that + // pertains to the specified section. void - read_line_mappings(); + read_line_mappings(off_t shndx); // Reads the relocation section associated with .debug_line and // stores relocation information in reloc_map_. @@ -117,9 +121,11 @@ class Sized_dwarf_line_info : public Dwarf_line_info const unsigned char* read_header_tables(const unsigned char* lineptr); - // Reads the DWARF2/3 line information. + // Reads the DWARF2/3 line information. If shndx is non-negative, + // discard all line information that doesn't pertain to the given + // section. const unsigned char* - read_lines(const unsigned char* lineptr); + read_lines(const unsigned char* lineptr, off_t shndx); // Process a single line info opcode at START using the state // machine at LSM. Return true if we should define a line using the -- 2.11.0