diff options
| author | Ian Lynagh <igloo@earth.li> | 2009-02-06 14:02:49 +0000 |
|---|---|---|
| committer | Ian Lynagh <igloo@earth.li> | 2009-02-06 14:02:49 +0000 |
| commit | 497302c44ad08c6c27d0e15d94a787f332c0cfec (patch) | |
| tree | a78fd252a39c2d49b5a5219a2c968004c5a1c029 /compiler/ghci | |
| parent | 1353826e5159c9a5a81e75e0b7459271f27c08ea (diff) | |
| download | haskell-497302c44ad08c6c27d0e15d94a787f332c0cfec.tar.gz | |
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.
Diffstat (limited to 'compiler/ghci')
| -rw-r--r-- | compiler/ghci/ByteCodeAsm.lhs | 4 | ||||
| -rw-r--r-- | compiler/ghci/ByteCodeGen.lhs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/ghci/ByteCodeAsm.lhs b/compiler/ghci/ByteCodeAsm.lhs index c6c7a0d0f9..24fda15ce9 100644 --- a/compiler/ghci/ByteCodeAsm.lhs +++ b/compiler/ghci/ByteCodeAsm.lhs @@ -377,12 +377,12 @@ mkBits findLabel st proto_insns return (sizeSS st_l0, (st_i0,st_l1,st_p0)) #ifdef mingw32_TARGET_OS - literal st (MachLabel fs (Just sz)) + literal st (MachLabel fs (Just sz) _) = litlabel st (appendFS fs (mkFastString ('@':show sz))) -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo@8. testcase: ffi012(ghci) #endif - literal st (MachLabel fs _) = litlabel st fs + literal st (MachLabel fs _ _) = litlabel st fs literal st (MachWord w) = int st (fromIntegral w) literal st (MachInt j) = int st (fromIntegral j) literal st MachNullAddr = int st (fromIntegral 0) diff --git a/compiler/ghci/ByteCodeGen.lhs b/compiler/ghci/ByteCodeGen.lhs index a9e3c07524..95aae77671 100644 --- a/compiler/ghci/ByteCodeGen.lhs +++ b/compiler/ghci/ByteCodeGen.lhs @@ -1205,7 +1205,7 @@ pushAtom d p (AnnVar v) pushAtom _ _ (AnnLit lit) = case lit of - MachLabel _ _ -> code NonPtrArg + MachLabel _ _ _ -> code NonPtrArg MachWord _ -> code NonPtrArg MachInt _ -> code PtrArg MachFloat _ -> code FloatArg |
