Skip to content
  • Ian Lynagh's avatar
    When generating C, don't pretend functions are data · 497302c4
    Ian Lynagh authored
    We used to generated things like:
        extern StgWordArray (newCAF) __attribute__((aligned (8)));
        ((void (*)(void *))(W_)&newCAF)((void *)R1.w);
    (which is to say, pretend that newCAF is some data, then cast it to a
    function and call it).
    This goes wrong on at least IA64, where:
        A function pointer on the ia64 does not point to the first byte of
        code. Intsead, it points to a structure that describes the function.
        The first quadword in the structure is the address of the first byte
        of code
    so we end up dereferencing function pointers one time too many, and
    segfaulting.
    497302c4