public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: vkutuzov@accesssoftek.com
Cc: binutils <binutils@sourceware.org>
Subject: Re: {GOLD][PATCH PROPOSAL]  prevent discarding of needed local symbols for the relocatable objects
Date: Thu, 11 Feb 2010 02:14:00 -0000	[thread overview]
Message-ID: <mcraavgcydc.fsf@dhcp-172-17-9-151.mtv.corp.google.com> (raw)
In-Reply-To: <1265843004.2150.342.camel@dp690-dev5v4> (Viktor Kutuzov's message of "Wed\, 10 Feb 2010 15\:03\:24 -0800")

Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:

> 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.

Thanks, but this patch doesn't work.  It fails the testsuite.  The
problem is that at the time your patch checks
needs_output_symtab_entry, it will always return true.
needs_output_symtab_entry will only return false if
set_no_output_symtab_entry has been called, and that only happens at
the end of the loop you patched.

I think what we need to do here is mark the local symbol as
appropriate in scan_relocatable_relocs.  The use of the
output_symtab_index_ field right now is a bit complicated.  It is
initialized to 0.  In Sized_relobj::do_count_local_symbols we set the
field to -1 if the symbol is not needed.  In
Sized_relobj::do_finalize_local_symbols, if the field is still 0, we
set it to the index in the output file.  Perhaps we should change that
0 == uninitialized, -1 == no index, -2 == needs index.  Then
do_finalize_local_symbols should never see 0.

Ian

  reply	other threads:[~2010-02-11  2:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-10 23:03 Viktor Kutuzov
2010-02-11  2:14 ` Ian Lance Taylor [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mcraavgcydc.fsf@dhcp-172-17-9-151.mtv.corp.google.com \
    --to=iant@google.com \
    --cc=binutils@sourceware.org \
    --cc=vkutuzov@accesssoftek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).