eh-frame: CIE initial_instructions overflow

Christophe Lyon christophe.lyon@linaro.org
Thu Dec 19 15:46:00 GMT 2013


On 19 December 2013 12:31, nick clifton <nickc@redhat.com> wrote:
> Hi Christophe,
>
>
>> Currently, in bfd/elf-eh-frame.c we have a definition of struct cie
>> which ends with:
>>    unsigned char initial_instructions[50];
>
>
> This is a bug...
>
>
>> In _bfd_elf_parse_eh_frame(), we have:
>>        initial_insn_length = end - buf;
>>        if (initial_insn_length <= sizeof (cie->initial_instructions))
>>          {
>>            cie->initial_insn_length = initial_insn_length;
>>            memcpy (cie->initial_instructions, buf, initial_insn_length);
>>          }
>
>
> IMHO - there should be no fixed size for the initial_instructions buffer.
> Instead the code at this point should allocate and copy the buffer that has
> just been created.
>
That's my feeling too, but I asked because this is going to be a
rather intrusive change: the surrounding code allocates an array of
CIE after having counted them.
Having a dynamic size here means we have to parse all the CIEs once to
get the biggest size, then allocate local_cies accordingly, then
reparse the section contents.

Not sure how costly it is to parse CIEs in general? Is there a risk to
increase link times significantly ?

Christophe.



More information about the Binutils mailing list