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 PROPOSAL] prevent discarding of needed local symbols for the relocatable objects


Hi Ian,

I'm trying to cross build llvm and llvm-gcc on Linux for ARM by using
GOLD as the linker. This has exposed some problems we have in GOLD. 

One of them related to the assert in the relocate_for_relocatable()
method (target-reloc.h, line 557):

  new_symndx = object->symtab_index(r_sym);
  gold_assert(new_symndx != -1U);

This assert gets triggered when the build links glibc with the -r -X
flags (remove local symbols).

This happens because with the given -X option GOLD removes all local
symbols, including those which still needed to resolve static relocs
later.

LD keeps that kind of local symbols in the symbol table even if -X
requested. I guess GOLD should do the same.

Please find attached the patch that fixes this issue.

Thank you,
Viktor.

Index: object.cc
===================================================================
RCS file: /cvs/src/src/gold/object.cc,v
retrieving revision 1.118
diff -u -p -r1.118 object.cc
--- object.cc	15 Jan 2010 01:44:22 -0000	1.118
+++ object.cc	10 Feb 2010 19:26:16 -0000
@@ -1609,9 +1609,13 @@ Sized_relobj<size, big_endian>::do_count
       //   - the symbol has a name.
       //
       // We do not discard a symbol if it needs a dynamic symbol entry.
+      // Also, if we are generating a relocatable output file, then 
+      // some of the local symbols may be required by relocs; we output them
+      // below if they are needed.
       if (discard_locals
 	  && sym.get_st_type() != elfcpp::STT_FILE
 	  && !lv.needs_output_dynsym_entry()
+	  && !lv.needs_output_symtab_entry()
 	  && parameters->target().is_local_label_name(name))
 	{
 	  lv.set_no_output_symtab_entry();

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