projects
/
mate.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
trap: use SIGILL instead of SIGSEGV
[mate.git]
/
Mate
/
X86CodeGen.hs
diff --git
a/Mate/X86CodeGen.hs
b/Mate/X86CodeGen.hs
index 270368ffb78cbe3c9511ee0dbfba4afb1bb8832f..dea2a4b0eb8e2c6c5575e80da79b5be40b28014f 100644
(file)
--- a/
Mate/X86CodeGen.hs
+++ b/
Mate/X86CodeGen.hs
@@
-176,8
+176,9
@@
emitFromBB cls hmap = do
calladdr <- getCodeOffset
let w32_calladdr = w32_ep + (fromIntegral calladdr) :: Word32
newNamedLabel (toString l) >>= defineLabel
calladdr <- getCodeOffset
let w32_calladdr = w32_ep + (fromIntegral calladdr) :: Word32
newNamedLabel (toString l) >>= defineLabel
- -- TODO(bernhard): better try SIGILL instead of SIGSEGV?
- mov (Addr 0) eax
+ -- causes SIGILL. in the signal handler we patch it to the acutal call.
+ -- place a nop at the end, therefore the disasm doesn't screw up
+ emit32 (0xffffffff :: Word32) >> emit8 (0x90 :: Word8)
-- discard arguments (TODO(bernhard): don't hardcode it)
add esp (4 :: Word32)
-- push result on stack (TODO(bernhard): if any)
-- discard arguments (TODO(bernhard): don't hardcode it)
add esp (4 :: Word32)
-- push result on stack (TODO(bernhard): if any)