Fix x86oid OSX signal handling emulation assembly fragments.
authorAlastair Bridgewater <nyef@virtdev-1.lisphacker.com>
Mon, 24 Oct 2011 18:30:32 +0000 (14:30 -0400)
committerAlastair Bridgewater <nyef@virtdev-1.lisphacker.com>
Mon, 24 Oct 2011 18:30:32 +0000 (14:30 -0400)
  * Both x86 and x86-64 signal_emulation_wrapper include a small
assembly fragment to simulate "sigreturn" by means of an invalid
instruction trap.  This fragment has to load two different pointers
into specific registers before the trap, but historically just told
the compiler to load them into registers and then moved them into
the correct registers, leading to the possibility of clobbering one
of the values.  Fixed, by informing the compiler to place them into
the correct registers to begin with.

NEWS
src/runtime/x86-64-darwin-os.c
src/runtime/x86-darwin-os.c

diff --git a/NEWS b/NEWS
index b141253..eaba678 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ changes relative to sbcl-1.0.52:
     of multiple-valued places to be set to NIL, instead of signalling an
     error (per a careful reading of CLHS 5.1.2.3).
   * bug fix: floating-point traps now work on darwin/x86-64.
+  * bug fix: repair crash in x86oid darwin signal handling emulation
+    when built with certain compilers.
 
 changes in sbcl-1.0.52 relative to sbcl-1.0.51:
   * enhancement: ASDF has been updated to version 2.017.
index 86d4687..1050ade 100644 (file)
@@ -249,8 +249,8 @@ void signal_emulation_wrapper(x86_thread_state64_t *thread_state,
     os_invalidate((os_vm_address_t)regs, sizeof(darwin_mcontext));
 
     /* Trap to restore the signal context. */
-    asm volatile ("mov %0, %%rax; mov %1, %%rbx; .quad 0xffffffffffff0b0f"
-                  : : "r" (thread_state), "r" (float_state));
+    asm volatile (".quad 0xffffffffffff0b0f"
+                  : : "a" (thread_state), "b" (float_state));
 }
 
 #if defined DUMP_CONTEXT
index debc8cf..f10d071 100644 (file)
@@ -273,8 +273,8 @@ void signal_emulation_wrapper(x86_thread_state32_t *thread_state,
     os_invalidate((os_vm_address_t)regs, sizeof(mcontext_t));
 
     /* Trap to restore the signal context. */
-    asm volatile ("movl %0, %%eax; movl %1, %%ebx; .long 0xffff0b0f"
-                  : : "r" (thread_state), "r" (float_state));
+    asm volatile (".long 0xffff0b0f"
+                  : : "a" (thread_state), "b" (float_state));
 }
 
 /* Convenience wrapper for the above */