GAS supports RIP-relative reference to a linker-generated symbol pointer.
example code from "AMD64 ABI Draft 0.99":
C source Assembly Code
extern int src[655356]; .extern src
extern int dst[65536]; .extern dst
extern int *ptr; .extern ptr
static int lsrc [65536]; .local lsrc
static int ldst [65536]; .comm lsrc, 2621444,4
static int *lptr; .local ldst
.comm ldst, 2621444,4
.local lptr
.comm lptr,8,8
.text
dst[0] = src[0]; movq src@GOTPCREL(%rip), %rax
movl (%rax), %edx
movq dst@GOTPCREL(%rip), %rax
movl %edx, (%rax)
ptr = dst; movq ptr@GOTPCREL(%rip), %rax
movq dst@GOTPCREL(%rip), %rdx
movq %rdx, (%rax)
*ptr = src[0]; movq ptr@GOTPCREL(%rip), %rax
movq (%rax) %rdx
movq src@GOTPCREL(%rip), %rax
movl (%rax), %eax
movl %eax, (%rdx)
ldst[0] = lsrc[0]; movl lsrc(%rip), %eax
movl %eax, ldst(%rip)
lptr = ldst; lea ldst(%rip), %rdx
movq %rdx, lptr(%rip)
*lptr = lsrc[0]; movq lptr(%rip), %rax
movl lsrc(%rip), %edx
movl %edx, (%rax)
Yasm supports RIP-relative addressing as well and "wrt ..gotpcrel" is used for this purpose.
It seems that NASM does not recognize "rip" and does not support the "wrt ..gotpcrel" relocation type, either.
Is there any way to do the RIP-relative addressing like this in NASM 64-bit?