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: Change to GOT initialization?


On Wed, Nov 27, 2002 at 05:54:20PM -0500, Thor Lancelot Simon wrote:
> > http://sources.redhat.com/ml/binutils/2002-09/msg00322.html
> > http://sources.redhat.com/ml/libc-alpha/2002-09/msg00630.html
> 
> The first message you reference appears to be a response to a non-public
> message, and without the missing context, it's very difficult to understand
> what problem, exactly, the change in question was attempting to address.

The problem is that prelink --undo needs a computable way of restoring
*r_offset (during prelink operation it stores there the computed
symbol value + addend and --undo needs to restore the binaries/libraries
to bitwise exact content the binaries/libs had before prelinking).
It really doesn't care if the rule on a particular RELA architecture is
*r_offset == 0, *r_offset == r_addend, or e.g. if r_offset falls into
.got section, then *r_offset == r_addend, otherwise *r_offset == 0.
Or even relocation r_type X has this rule, other relocation another rule.
But it has to be a general rule for the architecture.
On PPC, the value was none of the above, in some cases it e.g. put there
the addend which the relocation originally had but when that was changed
because it was against local symbol, it kept its value which
suddenly was completely out of sync with the real r_addend.
As the old local symbol was not kept either, after linking nobody can
figure out if it was originally .Lfoo + 16 (with *r_offset value 16) or
.Lbar + 8 (with *r_offset value 8, where .Lbar is .Lfoo + 8).
Alan decided 0 is the best.

> This change probably broke any other system whose ld.elf_so doesn't use
> the same hack as the current Linux implementation, as well.

And the NetBSD l_addr computation was not a hack? Relying on something
which just happens to have a particular value by luck?
Cannot understand why NetBSD cannot do what Linux had to do several times,
ie. in ld.so configury check what exactly ld is doing and base the check
on what the configury figures out.
E.g. on sparc* this had to be changed several times already, as binutils ld
was adapted to be compatible with Sun ld which over time changed relocation
algorithm of R_SPARC_RELATIVE relocations.
What you can also do, if you want another solution:
1) create hidden _begin symbol at ElfW(Ehdr) - e.g. in the linker script
2) then store that _begin and also .hidden _GLOBAL_OFFSET_TABLE_ into
   wordsize fields somewhere in .text section (such that those two have
   no dynamic relocations), then you can just subtract those two values
   and subtract the result from the value in GOT register

> Given that the rationale for the change was not really made public before
> the code was committed, AFAICT, and that the later justification relied
> on an assertion that is false -- that the data in the GOT was just random

Wrong, see above.

	Jakub


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