Skip to content

Commit

Permalink
Fixing HiPE bus errors on Mac OS X 10.5.3+, removes mach_override.
Browse files Browse the repository at this point in the history
(should be compatible with Mac OS X >= 10.3, not compatible with Mac OS X 10.2 and earlier)
  • Loading branch information
archaelus committed Sep 9, 2008
1 parent cf55be9 commit 8eb2f8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion erts/emulator/Makefile.in
Expand Up @@ -806,7 +806,6 @@ OS_OBJS += $(OBJDIR)/erl_mseg.o \
$(OBJDIR)/erl_$(ERLANG_OSTYPE)_sys_ddll.o \
$(OBJDIR)/erl_mtrace_sys_wrap.o

HIPE_x86_darwin_OBJS=$(OBJDIR)/mach_override.o
HIPE_x86_OS_OBJS=$(HIPE_x86_$(OPSYS)_OBJS)
HIPE_x86_OBJS=$(OBJDIR)/hipe_x86.o $(OBJDIR)/hipe_x86_glue.o $(OBJDIR)/hipe_x86_bifs.o $(OBJDIR)/hipe_x86_signal.o $(OBJDIR)/hipe_x86_stack.o $(HIPE_x86_OS_OBJS)
HIPE_amd64_OBJS=$(OBJDIR)/hipe_amd64.o $(OBJDIR)/hipe_amd64_glue.o $(OBJDIR)/hipe_amd64_bifs.o $(OBJDIR)/hipe_x86_signal.o $(OBJDIR)/hipe_x86_stack.o
Expand Down
30 changes: 18 additions & 12 deletions erts/emulator/hipe/hipe_x86_signal.c
Expand Up @@ -147,24 +147,30 @@ static void do_init(void)

#if defined(__DARWIN__)
/*
* Darwin appears to require code patching in order to catch
* and redirect calls to library functions. That functionality
* is implemented by the mach_override library.
* Assumes Mac OS X >= 10.3 (dlsym operations not available in 10.2 and
* earlier).
*
* The code below assumes that is is part of the main image (earlier
* in the load order than libSystem and certainly before any dylib
* that might use sigaction) -- a standard RTLD_NEXT caveat.
*
* _sigaction lives in /usr/lib/libSystem.B.dylib and can be found
* with the standard dlsym(RTLD_NEXT) call. The proviso on Mac OS X
* being that the symbol for dlsym doesn't include a leading '_'.
*
* The other _sigaction, _sigaction_no_bind I don't understand the purpose
* of and don't modify.
*/
#include "mach_override.h"
static int my_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#include <dlfcn.h>
static int (*__next_sigaction)(int, const struct sigaction*, struct sigaction*);
#define init_done() (__next_sigaction != 0)
#define __SIGACTION _sigaction
static void do_init(void)
{
kern_return_t err;

err = mach_override_ptr((void*)sigaction,
(void*)my_sigaction,
(void**)&__next_sigaction);
if (!err)
__next_sigaction = dlsym(RTLD_NEXT, "sigaction");
if (__next_sigaction != 0)
return;
perror("mach_override");
perror("dlsym_darwin");
abort();
}
#define _NSIG NSIG
Expand Down

0 comments on commit 8eb2f8c

Please sign in to comment.