[PATCH][X86_64/MC] Emit personality function and Dwarf EH data for Win64 SEH

Kai Nacke kai.nacke at redstar.de
Sun Sep 15 21:59:09 PDT 2013


Hi Anton!

I had a closer look at the clang source. Yes, I can also add the missing 
functionality to clang. Basically, it is using the right personality 
function (__gcc_personality_seh0 for C, __gnu_objc_personality_seh0 for 
ObjC and __gxx_personality_seh0).

Looking at the libgcc source from gcc 4.8.0, the language handlers 
mentioned above all delegate to _GCC_specific_handler but this function 
does not have the right prototype. (That'a a hidden bug but the code 
path is never executed right now.)

Regards
Kai

On 15.09.2013 21:33, Kai Nacke wrote:
> On 15.09.2013 20:45, Anton Korobeynikov wrote:
>> Kai,
>>
>> Just to make stuff clear: are you going to submit clang patches, so
>> the _GCC_specific_handler is emitted in IR on mingw64, for example?
>
> I am going to submit a patch so that LLVM generates the required
> UNWIND_INFO for Win64 SEH. Clang could use this to generate EH handling
> on mingw64 which uses the way described by me (I currently do not intend
> to extend clang in this way but I also could have a look at it).
> The name of the handler is always part of the landingpad IR. Depending
> on the language, clang emits already different personality function
> names. The list is in clang\lib\CodeGen\CGException.cpp.
>
> In essence, my patch simply emits the name of the personality function
> from the landingpad IR.
>
> To make it really clear I attach the intended next patch. The code has
> still some rough edges but I used it successfully for EH handling with
> the LDC compiler.
>
> Regards
> Kai
>
>>
>> On Sun, Sep 15, 2013 at 10:27 PM, Kai Nacke <kai.nacke at redstar.de> wrote:
>>> Hi!
>>>
>>> Currently, the MC code emits a hard-coded name for the personality
>>> function.
>>> Obviously the function specified by the user should be emitted as
>>> language
>>> handler.
>>> There is no special language data section for SEH. Instead the data is
>>> emitted after the unwind data and the reference to the handler function.
>>> See also the specification for the struct UNWIND_INFO in the msdn:
>>> http://msdn.microsoft.com/en-us/library/ddssxxy8.aspx
>>>
>>> This is the same as gcc 4.8.0 does. In case of SEH the handler
>>> function is
>>> called __gcc_personality_imp and the LSDA is stored in the handler data.
>>>
>>> The attached patch changes the output to be conformant to the
>>> specification.
>>> As of now there is no code path which can trigger this code therefore no
>>> test case is included. My next patch enables proper EH handling on
>>> Win64 and
>>> will include test cases for this change, too.
>>>
>>> Please review.
>>>
>>> Regards
>>> Kai
>>
>>
>>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list