public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* {GOLD][PATCH PROPOSAL]  prevent discarding of needed local symbols  for the relocatable objects
@ 2010-02-10 23:03 Viktor Kutuzov
  2010-02-11  2:14 ` Ian Lance Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Viktor Kutuzov @ 2010-02-10 23:03 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

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.


[-- Attachment #2: binutils-gold-prevent_discard_needed_local_symbols.patch --]
[-- Type: text/x-patch, Size: 881 bytes --]

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();

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-05-11  0:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 23:03 {GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects Viktor Kutuzov
2010-02-11  2:14 ` Ian Lance Taylor
2010-02-25  0:02   ` [GOLD][PATCH " Viktor Kutuzov
2010-03-03 19:34     ` Ian Lance Taylor
2011-05-10 22:30       ` Cary Coutant
2011-05-10 23:56         ` Ian Lance Taylor
2011-05-11  0:30           ` Cary Coutant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).