mov rbx, [Node.BaseCost]
Node.o64:Node.asm:(.text+0x4): relocation truncated to fit: R_X86_64_32 against `.data'
mov rbx, Node.BaseCost
mov rbx, [rbx]
mov rbx, [rel Node.BaseCost]
Node.asm:57: warning: absolute address can not be RIP-relative
nasm64 -Wall -g -F cv8 -f win64 Node.asm -o Node.o64 -l Node.lst
ld -e main Node.o64 -Map=Node.map -o NodeTest.exe
[BITS 64]
[GLOBAL main]
[SECTION .text]
main:
mov rbx, [Node.BaseCost]
.end
jmp .end
[BITS 64]
[SECTION .data]
[DEFAULT REL]
align 8
Node:
.BaseCost: dq 1
nasm64 -Wall -g -F cv8 -f win64 Node.asm -o Node.o64 -l Node.lst
ld -e main Node.o64 -Map=Node.map -o NodeTest.exe
bits 64
default rel
section .text
test: lea rax, [table]
section .rdata
table: DD 0x00000000
nasm.exe test.asm -o test.obj -g -Ox -s -DWIN_ABI -f win64
I get the warningtest.asm:5: warning: absolute address can not be RIP-relative
bits 64
default rel
section .rdata
table: DD 0x00000000
section .text
test: lea rax, [table]
the warning disappears even from NASM 2.12.02.bits 64
section .text
test: lea rax, [table]
section .rdata
default rel
table: DD 0x00000000
section .data
default rel
other_table: DD 0x00000000
section .rdata default rel table: DD 0x00000000 ; nasm -f elf64 file.asm |
Addressing mode refers to how the instruction is encoded so seems logical to put in .text section. Lots of existing code does it this way. What if you wanted to address the same data in two different ways?
Nasm manual sec 6.2 just says that "default rel/abs" turns on and off but the following with "default rel" in both .text and data also emits warnings:
bits 64
section .text
default rel
test: lea rax,
section .rdata
default rel
table: DD 0x00000000
; nasm -f elf64 file.asm