I have a small example program written in NASM(2.11.08) targeting the macho64 architecture. I\'m running OSX 10.10.3:
bits 64
section .data
msg1 db
IDK about the Mach-o ABI, but if it's the same as the SystemV x86-64 ABI GNU/Linux uses, then I think your problem is that you need to clear eax
to tell a varargs function like printf
that there are zero FP.
Also, lea rdi, [rel msg1]
would be a much better choice. As it stands, your code is only position-independent within the low 32bits of virtual address space, because you're truncating the pointers to 32bits.
It appears NASM has a bug. This same problem came up again: NASM 2 lines of db (initialized data) seemingly not working. There, the OP confirmed that the data was present, but labels were wrong, and is hopefully reporting it upstream.