This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold patch] Fix internal error with -s


Incremental patch 8 caused an internal error when using the -s option.
When calling Sized_relobj::write_local_symbols() from do_relocate(),
we want to pass the file offset of the symbol table. With the -s
option, however, we have no symbol table, and the attempt to access
layout->symtab_section() caused an assertion failure. This patch adds
a new function, Layout::symtab_section_offset() that simply returns 0
in this case.

OK?

-cary


2011-04-14 Cary Coutant  <ccoutant@google.com>

	* gold/layout.h (Layout::symtab_section_offset): New function.
	* gold/reloc.cc (Sized_relobj::do_relocate): Call it.


diff --git a/gold/layout.h b/gold/layout.h
index 917856e..4c5fe9f 100644
--- a/gold/layout.h
+++ b/gold/layout.h
@@ -685,6 +685,15 @@ class Layout
     return this->symtab_section_;
   }

+  // Return the file offset of the normal symbol table.
+  off_t
+  symtab_section_offset() const
+  {
+    if (this->symtab_section_ != NULL)
+      return this->symtab_section_->offset();
+    return 0;
+  }
+
   // Return the dynamic symbol table.
   Output_section*
   dynsym_section() const
diff --git a/gold/reloc.cc b/gold/reloc.cc
index 7103572..c58e42b 100644
--- a/gold/reloc.cc
+++ b/gold/reloc.cc
@@ -691,7 +691,7 @@ Sized_relobj<size, big_endian>::do_relocate(const
Symbol_table* symtab,
   // Write out the local symbols.
   this->write_local_symbols(of, layout->sympool(), layout->dynpool(),
 			    layout->symtab_xindex(), layout->dynsym_xindex(),
-			    layout->symtab_section()->offset());
+			    layout->symtab_section_offset());
 }

 // Sort a Read_multiple vector by file offset.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]