simonmar:
> On 01 July 2005 08:18, Donald Bruce Stewart wrote:
>
> > simonmar:
> >> Looking back through the mail archives, these errors started
> >> occurring on 11 March:
> >>
> >> http://www.haskell.org//pipermail/cvs-ghc/2005-March/023893.html
> >>
> >> And the most likely breaking commit is this one:
> >>
> >> http://www.haskell.org//pipermail/cvs-ghc/2005-March/023883.html
> >>
> >> What's strange is that this commit has been merged into STABLE, but
> >> you're not seeing any breakage on STABLE.
> >
> > Looks like it was the change pushing the obscure_ccall code into
> > inline assembly. Reverting this for OpenBSD only (so its allocated
> > RWX once at startup) fixes the problems. This also explains why stable
> > didn't break -- the inline asm change isn't in stable.
> > I'll do some more testing, though.
>
> The asm version is a bit dodgy. It might be safer to put the inline asm
> inside a function definition - could you try the patch below?
The way=ghci tests still crash.
With the wrapper over obscure_ccall_ret_code gcc 3.3.2 generates (run though
ghc):
.type obscure_ccall_wrapper, @function
obscure_ccall_wrapper:
#APP
.globl obscure_ccall_ret_code
obscure_ccall_ret_code:
addl $0x4, %esp
ret
#NO_APP
ret
.size obscure_ccall_wrapper, .-obscure_ccall_wrapper
And without, we just get the inner asm.
#APP
.globl obscure_ccall_ret_code
obscure_ccall_ret_code:
addl $0x4, %esp
ret
#NO_APP
So the asm itself doesn't seem to be the problem.
I suspect one of the security features of OpenBSD is kicking in. Either the
memory protection over the text segment, or something else. mprotecting the
bytes after obscure_ccall_ret_code didn't work though. I don't
understand either why it is only way=ghci that fails.
The following does work. It uses the inline asm to fill 4 mallocBytesRWX
bytes, as well as using your wrappper patch. At least this avoids code
duplication of the asm fragment.
--- Adjustor.c.orig Sat Jul 2 14:00:00 2005
+++ Adjustor.c Sat Jul 2 15:35:01 2005
@@ -122,22 +122,33 @@
returning in some static piece of memory and arrange
to return to it before tail jumping from the adjustor thunk.
*/
-__asm__ (
- ".globl " UNDERSCORE "obscure_ccall_ret_code\n"
- UNDERSCORE "obscure_ccall_ret_code:\n\t"
- "addl $0x4, %esp\n\t"
- "ret"
- );
+static void GNUC3_ATTRIBUTE(used) obscure_ccall_wrapper(void)
+{
+ __asm__ (
+ ".globl " UNDERSCORE "obscure_ccall_ret_code\n"
+ UNDERSCORE "obscure_ccall_ret_code:\n\t"
+ "addl $0x4, %esp\n\t"
+ "ret"
+ );
+}
extern void obscure_ccall_ret_code(void);
+
+#if defined(openbsd_HOST_OS)
+static unsigned char *obscure_ccall_ret_code_dyn;
#endif
+#endif
+
#if defined(x86_64_HOST_ARCH)
-__asm__ (
+static void GNUC3_ATTRIBUTE(used) obscure_ccall_wrapper(void)
+{
+ __asm__ (
".globl " UNDERSCORE "obscure_ccall_ret_code\n"
UNDERSCORE "obscure_ccall_ret_code:\n\t"
"addq $0x8, %rsp\n\t"
"ret"
);
+}
extern void obscure_ccall_ret_code(void);
#endif
@@ -317,7 +328,12 @@
*((StgFunPtr*)(adj_code + 0x06)) = (StgFunPtr)wptr;
adj_code[0x0a] = (unsigned char)0x68; /* pushl obscure_ccall_ret_code
*/
- *((StgFunPtr*)(adj_code + 0x0b)) = (StgFunPtr)obscure_ccall_ret_code;
+ *((StgFunPtr*)(adj_code + 0x0b)) =
+#if !defined(openbsd_HOST_OS)
+ (StgFunPtr)obscure_ccall_ret_code;
+#else
+ (StgFunPtr)obscure_ccall_ret_code_dyn;
+#endif
adj_code[0x0f] = (unsigned char)0xff; /* jmp *%eax */
adj_code[0x10] = (unsigned char)0xe0;
@@ -1063,4 +1079,11 @@
void
initAdjustor(void)
{
+#if defined(i386_HOST_ARCH) && defined(openbsd_HOST_OS)
+ obscure_ccall_ret_code_dyn = mallocBytesRWX(4);
+ obscure_ccall_ret_code_dyn[0] = ((unsigned char
*)obscure_ccall_ret_code)[0];
+ obscure_ccall_ret_code_dyn[1] = ((unsigned char
*)obscure_ccall_ret_code)[1];
+ obscure_ccall_ret_code_dyn[2] = ((unsigned char
*)obscure_ccall_ret_code)[2];
+ obscure_ccall_ret_code_dyn[3] = ((unsigned char
*)obscure_ccall_ret_code)[3];
+#endif
}
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc