This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [GOLD][PATCH PROPOSAL] fix a symbol table output size miscalculation.
- From: Ian Lance Taylor <iant at google dot com>
- To: vkutuzov at accesssoftek dot com
- Cc: binutils <binutils at sourceware dot org>
- Date: Wed, 10 Feb 2010 18:17:56 -0800
- Subject: Re: [GOLD][PATCH PROPOSAL] fix a symbol table output size miscalculation.
- References: <1265844722.2150.374.camel@dp690-dev5v4>
Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:
> There is another one in the Sized_relobj::write_local_symbols method
> (object.cc). The symbol table output size gets miscalculated if any
> symbol has discarded output section.
>
> Both
>
> object.cc, ln 1905: off_t output_size = this->output_local_symbol_count_
> * sym_size;
>
> and
>
> object.cc, ln 1910: off_t dyn_output_size =
> this->output_local_dynsym_count_ * sym_size;
>
> contains an extra sym_size for each symbol with discarded output
> section. Then asserts get triggered at the end:
>
> object.cc, ln1987: gold_assert(ov - oview == output_size);
>
> and
>
> object.cc, ln1993: gold_assert(dyn_ov - dyn_oview ==
> dyn_output_size);
>
> Please find attached the patch that fixes this issue.
> However, I don't like nested loops there, so if anyone will propose a
> more elegant solution that will be great.
Thanks but this patch is to the wrong place. At this point we have
already allocated space in the output file to hold local symbols.
Your patch will in effect leave part of the local symbol table as
zeroes, which is undesirable.
This needs to be fixed in Sized_relobj::do_count_local_symbols.
A small test case for these patches would be a good idea as well.
Ian