NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: Olsonist on April 24, 2017, 04:27:51 PM

Title: warning: absolute address can not be RIP-relative
Post by: Olsonist on April 24, 2017, 04:27:51 PM
This is only a warning and disassembling the resulting binary shows correct code.
I'm wondering what the warning is about.

SOLUTION FOUND! If I move foo: before the lea then the warning goes away.
Of course, I don't understand why and I guess I'm still wondering what the warning was about.
But the emitted code is correct and so this works for me.

This is on OSX 10.12.4 with nasm -f macho64 xxx.s -o xxx.o
nasm -v gives NASM version 2.12.02 compiled on Sep 14 2016

default         rel
      ...
      lea      RAX,[foo]
      ...
foo:   blah blah blah
      ...

With this code, I get warning: absolute address can not be RIP-relative.
However, disassembling the resulting binary with objdump:

   objdump -D -macho -x86-asm-syntax=intel -no-symbolic-operands xxx

the relevant instruction is:

   7022:       48 8d 05 10 00 00 00            lea   rax, [rip + 16]

and this indeed looks correct. It's exactly what I want to do. So what's up with the warning?
FWIW, I tried local labels (.foo) and they don't change the warning.
Also, foo is not declared global.

There is a manual section on absolute labels, ABSOLUTE: Defining Absolute Labels,
but nothing on relative labels.