2

I'd like to use the instruction lea rax, [rip + 0x1020304] with NASM but it seems like it doesn't allow that use of rip.

GAS (GNU Assembler) does allow this syntax for both numbers and symbols (How do RIP-relative variable references like "[RIP + _a]" in x86-64 GAS Intel-syntax work?). How can I achieve this with NASM?

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
phip1611
  • 4,240
  • 4
  • 24
  • 39
  • 5
    nasm uses the `rel` keyword but apparently you can't apply that to numerical absolute address. Normally it would look like `lea rax, [rel foo]`. If you really must, you can use a workaround along the lines of `lea rax, [rel $+0x1020304+7]` – Jester Jul 21 '21 at 13:15

0 Answers0