This bug causes certain instances of RIP-relative addressing to be off by one byte. In particular, as demonstrated in the attached file, if an RIP-relative address, [rel thing], contains 0 and we "add qword [rel thing], 5" to it, then it will contain 5*256 = 1280. I think this bug is also responsible for screwing up instructions of the form "cmp qword [rel gc_stack], 0" in one of my programs.
My machine runs Mac OS X 10.6.8. This is with the most recent release as well as the development version of NASM.
Command: $ nasm -f macho64 nasm_bug.asm && ld -macosx_version_min 10.6 -o nasm_bug -lSystem nasm_bug.o && ./nasm_bug
Output: Thing is 1280
Expected output: Thing is 5
I'm guessing this is a bug in NASM, as opposed to the linker or to the operating system.
--John Boyle
test program