[quake3] Mac OS X Universal Binary (2nd try)

Tony J. White tjw at webteam.net
Thu Jun 8 12:00:53 EDT 2006


On Thu, Jun 08, 2006 at 05:32:38PM +0200, Ludwig Nussel wrote:
> On Thursday 08 June 2006 17:00, Tony J. White wrote:
> > 4 is "illegal instruction" which I assumed was from trying to execute the
> > vm code that had been been placed into memory which was reserved with
> > malloc() (see vm_x86.c).  
> 
> I'd expect SIGILL if the code generator produces garbage. On Linux you'd get a
> segfault if you try to execute memory that is not supposed to be executed.

Hmm, maybe the problem is related more to the cross compilation of all that
x86 assembler?  I suppose the best way to test this is to get Daniel or
someone else with an intel mac to attempt to build the univeral binary
on their system. 

> > 10 is "bad memory access".  In the latest build it comes from trying to use
> > the same mmap() mprotect() calls that the linux version uses to get around
> > NX.
> 
> The purpose of mmap is to actually support NX rather than to get around it. 

OK, bad wording on my part.  It's not so much NX I was suggesting be
bypassed so much as the crashing :)

> The
> writeable flag must be removed when the memory is marked executable. Changing
> protection flags affects the whole page so you cannot use memory returned by
> malloc().
> 
> > Specifically it crashes when we Com_Memcpy() the vm code into the memory
> > reserved with:
> > 
> >   mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
> > 
> > I'm not sure why this is yet, or even if I'm on the write track with the
> > reason for catching signal 4.
> 
> VM_X86_MMAP is only defined if __linux__ is. Did you change that?

Yes, that's what I tried in this last build.  OS X has the mmap() and
mprotect() functions so I thought it was worth a shot.

-Tony



More information about the quake3 mailing list