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]

Re: [GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects


I think this part of the patch may have broken -s:

@@ -1937,16 +1938,16 @@ Sized_relobj<size, big_endian>::write_lo
 	  st_shndx = out_sections[st_shndx]->out_shndx();
 	  if (st_shndx >= elfcpp::SHN_LORESERVE)
 	    {
-	      if (lv.needs_output_symtab_entry() && !strip_all)
+	      if (lv.has_output_symtab_entry())
 		symtab_xindex->add(lv.output_symtab_index(), st_shndx);
-	      if (lv.needs_output_dynsym_entry())
+	      if (lv.has_output_dynsym_entry())
 		dynsym_xindex->add(lv.output_dynsym_index(), st_shndx);
 	      st_shndx = elfcpp::SHN_XINDEX;
 	    }
 	}

       // Write the symbol to the output symbol table.
-      if (!strip_all && lv.needs_output_symtab_entry())
+      if (lv.has_output_symtab_entry())
         {
           elfcpp::Sym_write<size, big_endian> osym(ov);

Even with -s, do_finalize_local_symbols() is going to count local
symbols and assign them indexes in the symbol table, and
lv.has_output_symtab_entry() will return true. write_local_symbols
will then try to write out a local symbol table entry, and will fail
an assertion here:

          osym.put_st_name(sympool->get_offset(name));

Interestingly, the assertion at the bottom of the loop will not trigger:

  if (output_size > 0)
    {
      gold_assert(ov - oview == output_size);
      of->write_output_view(symtab_off + this->local_symbol_offset_,
			    output_size, oview);
    }

because output_local_symbol_count and output_size were set to 0 by the
test for the -s option.

This patch fixes the problem. Is this OK, or were you thinking that
do_finalize_local_symbols() shouldn't even assign the symbol index
when -s is set?

-cary

	* object.cc (write_local_symbols): Check for strip_all when writing symbols.

Index: object.cc
===================================================================
RCS file: /cvs/src/src/gold/object.cc,v
retrieving revision 1.138
diff -u -p -r1.138 object.cc
--- object.cc	18 Apr 2011 05:39:43 -0000	1.138
+++ object.cc	10 May 2011 22:26:23 -0000
@@ -2302,7 +2302,7 @@ Sized_relobj<size, big_endian>::write_lo
 	  st_shndx = out_sections[st_shndx]->out_shndx();
 	  if (st_shndx >= elfcpp::SHN_LORESERVE)
 	    {
-	      if (lv.has_output_symtab_entry())
+	      if (lv.has_output_symtab_entry() && !strip_all)
 		symtab_xindex->add(lv.output_symtab_index(), st_shndx);
 	      if (lv.has_output_dynsym_entry())
 		dynsym_xindex->add(lv.output_dynsym_index(), st_shndx);
@@ -2311,7 +2311,7 @@ Sized_relobj<size, big_endian>::write_lo
 	}

       // Write the symbol to the output symbol table.
-      if (lv.has_output_symtab_entry())
+      if (!strip_all && lv.has_output_symtab_entry())
         {
           elfcpp::Sym_write<size, big_endian> osym(ov);


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