For ELF the following is ok:
global start
start:
mov rax, 1
mov rax, [rax+label]
However, for macho-64 you need to write
start:
...
mov rax,1
mov rax,[rel rax+label]
ELF binaries reside in the lower 2GB of the address space, so you can give an address as a 32-bit value.
However, for mach-64, the address space used is much higher than 2GB, so you can NOT use such 32-bit values. This is the reason you are getting the error message.
What you need to do is to use RIP (Relative to Instruction Pointer) addressing mode, in which a reference to date is, like a reference to a program label, expressed as an offset from
the Instruction Pointer, which contains the address of the next instruction to be executed.
The 'rel' prefix directs NASM to change the "absolute" addresses to addresses relative to the IP.
You can also use the 'default rel' instruction to request this be done everywhere.
I've been trying to sort out this issue in a porting effort I'm doing right now trying to move some code to Apple's OSX.
There is *very* little about this topic to be found on the net, which suggests that the number of folks writing assembly language for OSX is much
smaller than the small number who write such code for x86-64.
thanks,dave