Adriaan van Os wrote:
It crashes with a bus error KERN_PROTECTION FAILURE (0x0002) at call *%eax. The eax register points to the stack, so I fear the stack is marked non-executable. Whether this is a problem in the kernel, gcc or the linker, I have to find out. There is a Darwin linker option -allow_stack_execute, but it causes a linker error (undefined symbols: _main), which is another thing to find out why ...
Wow, I think we have a workaround !
[Darwin:~/gpc/testgpc/tramp] adriaan% gp tramp.pas --no-pic -Wl,-stack_addr,c0000000 -Wl,-stack_size,4000000
This instructs the Darwin linker to create a segment __UNIXSTACK and apparently the stack segment has the correct priviliges set, because "tramp" no longer crashes !
Correct way is to define ENABLE_EXECUTE_STACK in gcc-3.4.x/gcc/config/i386/darwin.h. The definition should be similar to definitions in gcc-3.4.x/gcc/config/sol2.h and gcc-3.4.x/gcc/config/netbsd.h