Mac Intel

Mikael Pettersson mikpe@REDACTED
Sun Aug 6 23:11:50 CEST 2006


On Fri, 4 Aug 2006 02:41:47 +0100, Joel Reymont wrote:
>On Aug 4, 2006, at 2:33 AM, Mikael Pettersson wrote:
>
>> The issue is not x86 but the operating system and C library.
>> To support HiPE on x86 or amd64 we need to be able to enforce
>> sigaltstack semantics on all signal handlers. We can do this
>> with Linux/glibc on x86/amd64 and Solaris/x86 (not yet ported
>> to Solaris/amd64 due to lack of availability), but we have no
>> idea how to do this on MacTel.
>
>Well... The semantics of sigaltstack should be the same across Mac  
>OSX PPC and Mac OSX Intel, at least I think so. HiPE is supposed in  
>Mac OSX PPC from what I remember. I'm very much trivializing things  
>but I wonder if there's a straightforward way to keep the Mac OSX PPC  
>semantics while plugging in the Intel code generation.
>
>If you would be kind enough to guide me I could look into adding HiPE  
>functionality to Mac Intel as I have time to spare.

The key is to "enforce sigaltstack semantics on ALL signal handlers".
This includes not only the sigaction() calls we write ourselves in
the erts source code, but also any direct or indirect sigaction()s
in libraries linked with erts, including the C library itself.
For instance, alarms, asynchronous I/O, and profiling (gcc -pg) can
all cause new signal handlers to be installed and invoked.

The solution I use in HiPE/x86 is to redirect sigaction() and the
C library's internal sigaction() function to our own version which
adds the SA_ONSTACK flag to enforce sigaltstack semantics, and
then invokes the low-level sigaction() system call.
The code for this is quite messy and highly dependent on C library
internals; see erts/emulator/hipe/hipe_x86_signal.c for details.

Unless you have the source code for the OSX C library, you basically
have to run 'nm' on the library files to find all versions of sigaction(),
and then experiment with defining sigaction() as a wrapper around those
C-library internal sigaction() functions until you find a combination
that works. Disassembling parts of the library may also be necessary.



More information about the erlang-questions mailing list