When generating C, don't pretend functions are data
authorIan Lynagh <igloo@earth.li>
Fri, 6 Feb 2009 14:02:49 +0000 (14:02 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 6 Feb 2009 14:02:49 +0000 (14:02 +0000)
commit497302c44ad08c6c27d0e15d94a787f332c0cfec
treea78fd252a39c2d49b5a5219a2c968004c5a1c029
parent1353826e5159c9a5a81e75e0b7459271f27c08ea
When generating C, don't pretend functions are data
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.
21 files changed:
compiler/basicTypes/BasicTypes.lhs
compiler/basicTypes/Literal.lhs
compiler/cmm/CLabel.hs
compiler/cmm/CmmParse.y
compiler/cmm/PprC.hs
compiler/cmm/PprCmm.hs
compiler/cmm/ZipCfgCmmRep.hs
compiler/codeGen/CgForeignCall.hs
compiler/codeGen/CgHpc.hs
compiler/codeGen/CgUtils.hs
compiler/codeGen/StgCmmForeign.hs
compiler/codeGen/StgCmmHpc.hs
compiler/codeGen/StgCmmUtils.hs
compiler/coreSyn/CoreUtils.lhs
compiler/coreSyn/MkExternalCore.lhs
compiler/deSugar/DsForeign.lhs
compiler/ghci/ByteCodeAsm.lhs
compiler/ghci/ByteCodeGen.lhs
compiler/nativeGen/MachCodeGen.hs
compiler/nativeGen/PositionIndependentCode.hs
compiler/utils/Binary.hs