[PATCH] [gold] Do not attempt to merge sections with an entsize of 0.

Cary Coutant ccoutant@google.com
Sun Feb 22 20:03:00 GMT 2015


> It seems to be invalid for a section to have the SHF_MERGE flag set and an
> entsize of 0, but we should cope with this gracefully instead of crashing.
>
> 2015-02-04  Peter Collingbourne  <pcc@google.com>
>
>         * merge.cc (Output_merge_data::do_add_input_section): Do not attempt to
>         merge sections with an entsize of 0.

In output.cc, Output_section::add_merge_input_section, we already
check the entsize for merge string sections. I think that would be the
right place to reject sections with entsize == 0, and would avoid some
unnecessary allocations. Just put:

    if (entsize == 0)
      return false;

at the top of that function. With that change, you could simply call
gold_assert(entsize != 0) just before the divide.

Thanks!

-cary



More information about the Binutils mailing list