mach-o objfmt, amd64 relocation issues
Peter Johnson
peter at tortall.net
Fri Jan 5 14:11:10 PST 2007
On Fri, 5 Jan 2007, Henryk Richter wrote:
> Am 05.01.2007 um 18:32 schrieb Peter Johnson:
>> Great work so far! Looking at reloc.h, it appears that the equivalent of
>> R_X86_64_32 is X86_64_RELOC_SIGNED, which the header file claims is "for
>> signed 32-bit displacement".
>
> That was my first thought as well. Unfortunately, the current linker insists
> on X86_64_RELOC_SIGNED in conjunction with "r_pcrel=1", which is in turn
> "movq _foo(%rip), %rdx".
> The (seemingly) absolute form "movq (_label),%rdx" is not covered by those
> relocations, unless appropriate extra actions are taken. My first idea was
> explicitly using "movq rax,[qword label]",
> but that form works only with the "rax" register. *sigh* x86.
Yes, Windows on x86-64 does much the same thing, basically requiring
RIP-relative for 32-bit relocs, and only allowing absolute relocs for
64-bit values (although if I recall, this is enforced more by the linker
than the object format itself). You can simply treat everything else as
an error. What this means is peppering your asm code with (%rip) or WRT
rip, but that's the price we have to pay. :)
When it comes to the Yasm code, If you've not noticed yet, the yasm_value
structure has an ip_rel member that indicates a RIP-relative relocation.
Peter
More information about the yasm-devel
mailing list