[LLVMdev] LLVM creates unterminated ELF .eh_frame sections

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Apr 30 11:53:23 PDT 2013


> The problem with this is that __register_frame function (in libgcc_s.so),
> registering .eh_frame with an exception handler, only takes the pointer to
> .eh_frame, and not the size of data, and should be able to detect the end of
> data by scanning it and hitting zero DWORD (size). There is no trailing
> zero, and it runs into the next section and tries to interpret it as an
> exception data too.
>
> There has to be DWORD zero placed right after the current .eh_frame,
> otherwise such ELF is invalid as it is.
>
> I am particularly looking at an old rev.134967, but I don't think this has
> been fixed in the current trunk.
>
> Somebody familiar with an ELF writer should add the proper trailing zero.

Are you trying MCJIT? :-)

The problem is here is that  crtendS.o (which is normally added when
the .o files are linked into the final executable) contains the 4 zero
bytes that is missing.

I first tried to compensate for that in MCJIT by adding those 4 bytes.
That works for Linux, but not for OS X where __register_frame takes a
single FDE at a time. I have an incomplete wip patch if you are
interested.


> Yuri

Cheers,
Rafael



More information about the llvm-dev mailing list