This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] x86-64: support newer relocation types


> > >> If so, this would seem to be an unrelated change, as the GOTPC32 reloc in my
> > >>patch is handled exactly like the i386 one (which of course is very broken, but
> > >>obviously cannot be fixed). Or maybe I don't see how you would see
> > >>BFD_RELOC_32_PCREL to end up here.
> > >
> > >i386 GOT relocation is different from GOTPC32 in a way that one is IP
> > >relative and other not.
> > >I386 way of encoding GOT relocation is:
> > >        addl    $_GLOBAL_OFFSET_TABLE_+[.-.L2], %ebx
> > >While for x86-64 we want something like:
> > >	leaq    _GLOBAL_OFFSET_TABLE_(%rip), %rbx
> > >So the expression to match needs tobe slightly different.
> > 
> > While the explanation is only partly right (we're talking about i386's
> > GOTPC vs. x86-64's GOTPC32 here, which have identical semantics), it
> 
> Oops, sorry.  I forgot that the i386 equivalent also ends up in PC
> relative relocation despite the lack of harware support, but anyway I
> would like to have the RIP relative syntax instead of having to invent
> new labels to encode GOTPC32

Not quite right either - extra label is not needed here, but
leaq    _GLOBAL_OFFSET_TABLE_-., %rbx would be absolute addressing and 
leaq    _GLOBAL_OFFSET_TABLE_-.(%rip), %rbx would be IP relative
addressing to the same address as line above, so there would be no way
to encode IP relative addressing to _GLOBAL_OFFSET_TABLE_ via this kind
of arithmetics...

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]