I have a one-line reduction of my x86-64 assembly program that gets a relocation truncation error:
movq %rdx,8(%rdi)
If you put that line, alone, in t.s
it will assemble successfully with the command
as -o t.o -g -al=t.lst t.s
Note the -g
option for debugging information.
After this, attempting to link this into an executable with this command:
ld -o t t.o
Results in these TWO error messages:
t.o:t.s:1:(.stab+0x14): relocation truncated to fit: R_X86_64_32 against `.text'
t.o:t.s:1:(.stab+0x20): relocation truncated to fit: R_X86_64_32 against `.text'
The salient lines of t.lst are:
1 0000 48895708 movq %rdx,8(%rdi)
1 90909090
1 90909090
1 90909090
There is no linker error if I leave the -g
option out of the assembler command, so the problem might be in the debugger data rather than the executable portion of the output file.
This instruction was giving me trouble within a larger program, but as you can see, in isolation it is still a problem.
Why did I get a relocation truncation from this particular instruction? Would a linker option make a valid and debuggable program?