OSX now requires your executable to have a writable data segment with content, so it can dynamically move and link your code. I don’t know why, perhaps for security reasons, perhaps because of the new RIP register. If you place the .data segment there (with some dummy content), you will avoid the "no write" error. IMO this is ld error.
64- syscall, . GCC-, _syscall PROCEDURE libSystem.dylib raw. Raw syscall, int 0x80. "int 0x80" 64- .
" GCC" , syscall , 32- , sys/syscall.h. , , syscall , ORing . . , ! ( NASM, )
; assemble with
; nasm -f macho64 -o syscall64.o syscall64.asm && ld -lc -ldylib1.o -e start -o syscall64 syscall64.o
extern _syscall
global start
[section .text align=16]
start:
; do it gcc-style
mov rdi, 0x4 ; sys_write
mov rsi, 1 ; file descriptor
mov rdx, hello
mov rcx, size
call _syscall ; we're calling a procedure, not trapping.
;now let do it raw
mov rax, 0x2000001 ; SYS_exit = 1 and is type 2 (bsd call)
mov rdi, 0 ; Exit success = 0
syscall ; faster than int 0x80, and legal!
[section .data align=16]
hello: db "hello 64-bit syscall!", 0x0a
size: equ $-hello
http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/mach/i386/syscall_sw.h , .