Author Topic: syscalls with macho target on Leopard  (Read 3622 times)

nobody

  • Guest
syscalls with macho target on Leopard
« on: January 11, 2008, 11:30:56 AM »
I've noticed, that the preferred syscall method
_syscall:
int 0x80
ret
somewhereinyourcode:
push dword 0 ;exit code 0
mov eax,1 ;SYS_exit
call _syscall

doesn't work, beacuse Leopard uses 64 offsets, so an extra dword will be placed on top of the stack, therefore you'll get "Bad system call" error. The correct way:
push dword 0 ; exit code 0
mov eax,1 ;SYS_exit
push dword 0 ; push 32 bit into the stack, not 64 as a call do
int 0x80

You may use a macro instead of a call to be portable.

Bests,
Turdus

nobody

  • Guest
Re: syscalls with macho target on Leopard
« Reply #1 on: October 15, 2008, 05:19:34 PM »
Apple does not support syscalls in OS X: http://lists.apple.com/archives/darwin-kernel/2008/Apr/msg00125.html
You have to actually call the C standard library.

nobody

  • Guest
Re: syscalls with macho target on Leopard
« Reply #2 on: October 15, 2008, 05:43:25 PM »
Examples of making OS X syscalls can be found here:

http://sourceforge.net/projects/hla-stdlib/