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]

Re: [GOLD][PATCH PROPOSAL] fix a symbol table output size miscalculation.


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


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