syscalls with macho target on Leopard

2008-01-11
2013-06-04
  • Nobody/Anonymous

    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

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks