mach-o objfmt, amd64 relocation issues

Henryk Richter buggs at comlab.uni-rostock.de
Fri Jan 5 11:16:43 PST 2007


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.

> Perhaps the difficultly you're running into is that RIP-relative  
> displacement in NASM syntax is specified using not movq rax, [rip 
> +_some_label] but movq rax, [_some_label WRT rip].  The reason for  
> this is that the additive notation is very confusing.  The GAS  
> parser jumps through some hoops to make _some_label(%rip) translate  
> into the WRT form.

Thanks for the clarification. I was unaware of that syntax. That  
explains why I missed the "rip relative" flags in the output routine  
(and in turn enabled "pcrel=1" for all symbols not 64 bit wide). I'll  
post the
updated routines next week.

--Henryk

___________________________________________


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cvs.tortall.net/pipermail/yasm-devel/attachments/20070105/dac287fd/attachment.html 


More information about the yasm-devel mailing list