This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [Patch] sh/sh64: Zero-initialize dynamic relocation sections
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: "Clarke, Stephen" <stephen dot clarke at superh dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 22 Aug 2002 14:20:33 -0400
- Subject: Re: [Patch] sh/sh64: Zero-initialize dynamic relocation sections
- References: <287E4644B5249D449C56FA5409A874AE03C73D@sh-us-ex01.us.w2k.superh.com>
Coincidences...
On Thu, Aug 22, 2002 at 10:35:23AM -0700, Clarke, Stephen wrote:
>
> The attached file contains a patch for an sh/sh64 linker problem in
> which the linker allocates space for dynamic relocations, but then does
> not initialize that space.
>
> The patch is very simple, though the explanation is rather
> convoluted.
>
> Space for dynamic relocations is calculated by sh_elf_check_relocs(),
> before the information in a version script has been processed.
> At this time a symbol can appear to be globally visible,
> and so a relocation which references it has to be resolved dynamically,
> so space is set aside for that dynamic relocation.
>
> After this, the version script is processed, and some symbols
> may be forced local.
>
> The contents of the dynamic relocations are actually written by
> sh_elf_relocate_section(). A symbol that originally appeared
> to be global may by now have been forced local. A PC-relative
> relocation can be resolved statically for such a symbol, there
> is no longer any need for the dynamic relocation. So although
> space for a dynamic relocation was allocated, it is now
> unnecessary, and is left uninitialized.
>
> This patch simply zero-initializes the space allocated for the
> dynamic relocations, which means they are set to
> R_SH_NONE, rather than random garbage.
>
> I've included a test for sh64 only, though I think the problem will
> also occur on sh, I haven't been able to construct a test case.
>
> (I should add that this change was also present in the following
> patch submitted by Kaz Kojima:
>
> http://sources.redhat.com/ml/binutils/2002-06/msg00765.html
>
> I'm still hoping to provide the required changes to get Kaz'
> patch working for sh64 and accepted at some stage, but first
> I want to get some simpler patches done...)
Now that you mention it, I went to look at Kaz's patch. He includes a
more thorough version of the changes I made earlier today... my
question for you is, does the forced-local patch I posted earlier work
for you instead of your patch, or are there non-GOT symbols affected
also? I prevent emitting space for the relocs in the first place. Be
sure to try using a current CVS snapshot, since Alan and I fixed a
related problem in GOT refcounts yesterday.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer