This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: SPARC64 dynamic linker crash undoing prelinking
- From: David Miller <davem at davemloft dot net>
- To: joseph at codesourcery dot com
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 18 Mar 2009 18:44:23 -0700 (PDT)
- Subject: Re: SPARC64 dynamic linker crash undoing prelinking
- References: <Pine.LNX.4.64.0902122051210.4982@digraph.polyomino.org.uk>
From: "Joseph S. Myers" <joseph@codesourcery.com>
Date: Thu, 12 Feb 2009 20:52:41 +0000 (UTC)
> In various circumstances the dynamic linker needs to undo prelinking
> of prelinked shared libraries; in particular, if they were loaded at
> an address other than that assigned by the prelinker.
>
> On SPARC64, undoing prelinking involves rewriting the PLT. The code
> in question writes various values at address rela->r_offset, where
> rela is a relocation from .rela.plt. This address, however, has not
> been adjusted for the library possibly having been loaded at an
> address other than that assigned by the prelinker, leading to a
> segfault in that case.
>
> This patch changes the code to add l->l_addr, the offset of the
> address at which the library was loaded compared to that the prelinker
> assigned, when computing the addresses of PLT entries to rewrite. It
> looks like the sparc32 version has the same issue, but not having
> observed this issue there I have not prepared the corresponding patch.
>
> 2009-02-12 Joseph Myers <joseph@codesourcery.com>
>
> * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_runtime_setup):
> Adjust rela->r_offset by l->l_addr when rewriting PLT.
These changes look good to me.
I think it would be wise to make the same change on the 32-bit
side just for completeness.