This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects
- From: Cary Coutant <ccoutant at google dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: vkutuzov at accesssoftek dot com, binutils <binutils at sourceware dot org>
- Date: Tue, 10 May 2011 17:30:06 -0700
- Subject: Re: [GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects
- References: <1265843004.2150.342.camel@dp690-dev5v4> <mcraavgcydc.fsf@dhcp-172-17-9-151.mtv.corp.google.com> <1267053412.6817.190.camel@dp690-dev5v4> <mcrlje9jj32.fsf@dhcp-172-17-9-151.mtv.corp.google.com> <BANLkTi=bPWCtfFvrgeRtbu3moYvY3mxE6Q@mail.gmail.com> <mcrvcxiglh4.fsf@coign.corp.google.com>
>> 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?
>
> I was thinking the latter. ?I see that do_count_local_symbols checks
> discard_locals. ?It sounds like it should also test strip_all. ?A patch
> for that is preapproved if it works.
That works. I've committed the following patch.
-cary
* object.cc (Sized_relobj::do_count_local_symbols): Check for
strip_all (-s).
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 11 May 2011 00:25:55 -0000
@@ -1824,6 +1824,7 @@ Sized_relobj<size, big_endian>::do_count
unsigned int dyncount = 0;
// Skip the first, dummy, symbol.
psyms += sym_size;
+ bool strip_all = parameters->options().strip_all();
bool discard_all = parameters->options().discard_all();
bool discard_locals = parameters->options().discard_locals();
for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size)
@@ -1882,7 +1883,8 @@ Sized_relobj<size, big_endian>::do_count
++dyncount;
}
- if (discard_all && lv.may_be_discarded_from_output_symtab())
+ if (strip_all
+ || (discard_all && lv.may_be_discarded_from_output_symtab()))
{
lv.set_no_output_symtab_entry();
continue;