As a concrete example, on GAS 2.24, moving the address:
mov $s, %eax
s:
After:
as --64 -o a.o a.S
objdump -Sr a.o
Uses zero extension:
0000000000000000 <s-0x5>:
0: b8 00 00 00 00 mov $0x0,%eax
1: R_X86_64_32 .text+0x5
But memory access:
mov s, %eax
s:
Compiles to sign extension:
0000000000000000 <s-0x7>:
0: 8b 04 25 00 00 00 00 mov 0x0,%eax
3: R_X86_64_32S .text+0x7
Is there a rationale to using either in this specific case, or in general? I don't understand how the assembler could to any better supposition about either case.
NASM 2.10.09 just uses R_X86_64_32
for both of the above. Update: an edge nasm commit 6377180 after 2.11 produces the same output of Gas, which seemed like a bug as Ross mentioned.
I have explained what I think I understand about R_X86_64_32S
at: https://stackoverflow.com/a/33289761/895245