This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Change to GOT initialization?
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Thor Lancelot Simon <tls at reefedge dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 28 Nov 2002 10:30:52 +1030
- Subject: Re: Change to GOT initialization?
- References: <20021127175420.A23968@reefedge.com>
On Wed, Nov 27, 2002 at 05:54:20PM -0500, Thor Lancelot Simon wrote:
> On Thu, 28 Nov 2002 at 08:45:31 +1030, Alan Modra wrote:
>
> > On Wed, Nov 27, 2002 at 01:26:24PM -0800, Jason R Thorpe wrote:
> > > The way we compute our relocation base is:
> > >
> > > bl _GLOBAL_OFFSET_TABLE_@local-4
> > > mflr %r31 # r31 = (real) GOT
> > > lwz %r30,_GLOBAL_OFFSET_TABLE_@got(31)
> > > # the linker thought GOT were ...
> > > subf %r4,%r30,%r31 # r4 = relocbase
> > >
> > > ...but this falls over completely, because 0 ends up being loaded
> > > info %r30, so we can't compute the relocbase (nor can we compute
> > > the real address of _DYNAMIC, since we don't know the relocbase to
> > > add to the base-relative offset in _DYNAMIC's GOT entry).
> > >
> > > So, I guess I have two questions:
> > >
> > > 1. Can anyone tell me when this change was made, and why?
> >
> > 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.
Well, yes. I forget the details, but Jakub may be able to explain
why prelink support needed the change.
> The second message you reference explains the change as justified, in part,
> because the values in the GOT were "random" in the old scheme of things,
> which is a false assertion. Indeed, to avoid the gross hack of disassembling
> a PC-relative branch that you suggest we now switch to, the NetBSD dynamic
> linker relied, as Jason's pointed out, upon the very much *non-random*
> values that used to be in the GOT.
I think it's a far more gross hack to read unrelocated .got section
contents on RELA targets and expect anything sensible except for
locations specified by the ABI. To apply a RELA reloc, the linker
(or dynamic linker) doesn't need to read the section contents for
the bits that the reloc applies to.
> would it it be too much to ask that
> the change in question be backed out?
That would break prelink, I think. If Jakub can suggest some change
that's suitable for both prelink and NetBSD, then I wouldn't object
to the linker relocating .got for you.
--
Alan Modra
IBM OzLabs - Linux Technology Centre