[patch gold] Fix link error when building optimized

Cary Coutant ccoutant@google.com
Fri Mar 1 20:18:00 GMT 2013


This patch fixes a link error when building dwp with optimization
turned on. The inline function check_buffer, defined in the
dwarf_reader.cc, is called from an function defined inline in the
class body. I refactored it to keep the error path, which needs
visibility into class Relobj, in dwarf_reader.cc, with the fast path
still inlined.

Tested on x86_64 with optimization turned on. OK to commit?

-cary


gold/
        * dwarf_reader.cc (Dwarf_info_reader::check_buffer): Move
        function into class definition in header file.
        (Dwarf_info_reader::warn_corrupt_debug_section): New function.
        * dwarf_reader.h (Dwarf_info_reader::warn_corrupt_debug_section):
        New function.
        (Dwarf_info_reader::check_buffer): Move here from .cc file.
-------------- next part --------------
gold/
	* dwarf_reader.cc (Dwarf_info_reader::check_buffer): Move
	function into class definition in header file.
	(Dwarf_info_reader::warn_corrupt_debug_section): New function.
	* dwarf_reader.h (Dwarf_info_reader::warn_corrupt_debug_section):
	New function.
	(Dwarf_info_reader::check_buffer): Move here from .cc file.


diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index f3f3141..6b01b7f 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -1141,21 +1141,6 @@ Dwarf_die::sibling_offset()
 
 // class Dwarf_info_reader
 
-// Check that the pointer P is within the current compilation unit.
-
-inline bool
-Dwarf_info_reader::check_buffer(const unsigned char* p) const
-{
-  if (p > this->buffer_ + this->cu_offset_ + this->cu_length_)
-    {
-      gold_warning(_("%s: corrupt debug info in %s"),
-		   this->object_->name().c_str(),
-		   this->object_->section_name(this->shndx_).c_str());
-      return false;
-    }
-  return true;
-}
-
 // Begin parsing the debug info.  This calls visit_compilation_unit()
 // or visit_type_unit() for each compilation or type unit found in the
 // section, and visit_die() for each top-level DIE.
@@ -1448,6 +1433,16 @@ Dwarf_info_reader::visit_type_unit(off_t, off_t, off_t, uint64_t, Dwarf_die*)
 {
 }
 
+// Print a warning about a corrupt debug section.
+
+void
+Dwarf_info_reader::warn_corrupt_debug_section() const
+{
+  gold_warning(_("%s: corrupt debug info in %s"),
+	       this->object_->name().c_str(),
+	       this->object_->section_name(this->shndx_).c_str());
+}
+
 // class Sized_dwarf_line_info
 
 struct LineStateMachine
diff --git a/gold/dwarf_reader.h b/gold/dwarf_reader.h
index c2fb245..13d278a 100644
--- a/gold/dwarf_reader.h
+++ b/gold/dwarf_reader.h
@@ -799,9 +799,21 @@ class Dwarf_info_reader
   { this->reloc_mapper_->reset(checkpoint); }
 
  private:
+  // Print a warning about a corrupt debug section.
+  void
+  warn_corrupt_debug_section() const;
+
   // Check that P is within the bounds of the current section.
   bool
-  check_buffer(const unsigned char* p) const;
+  check_buffer(const unsigned char* p) const
+  {
+    if (p > this->buffer_ + this->cu_offset_ + this->cu_length_)
+      {
+	this->warn_corrupt_debug_section();
+	return false;
+      }
+    return true;
+  }
 
   // Read the DWARF string table.
   bool


More information about the Binutils mailing list