This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [SPARC] Segfault when resolving STT_GNU_IFUNC functions
On Fri, Jun 10, 2011 at 11:13:41PM +0200, Aurelien Jarno wrote:
> Hi,
>
> On Mon, Jun 06, 2011 at 04:51:23PM -0700, David Miller wrote:
> > From: David Miller <davem@davemloft.net>
> > Date: Wed, 25 May 2011 15:16:29 -0700 (PDT)
> >
> > > From: Aurelien Jarno <aurelien@aurel32.net>
> > > Date: Sun, 8 May 2011 20:25:09 +0200
> > >
> > >> I am experiencing an issue with glibc 2.13 on sparc32 and sparc64 when
> > >> multiarch is enabled. In some cases, probably depending on order the
> > >> relocations are done, the resolution of STT_GNU_IFUNC functions
> > >> (typically memset or memcpy) does a segmentation fault, with a
> > >> backtrace looking like that:
> > > ...
> > >> Help to solve this issue would be appreciated.
> > >
> > > Thanks for reporting this bug, I'll try to figure out what's wrong
> > > and fix it.
> >
> > Can you give this patch a try?
> >
>
> Thanks a lot for the patch, and sorry to not come back to you earlier. I
> have just tried this patch, and unfortunately it doesn't seems to work
> correctly: the niagara version of the function is executed even on an
> ultra III system. I haven't debug it more right now, I'll do that
> over the week-end and keep you updated.
>
The problems happens because the IFUNC resolvers are sometimes also
called from generic code, in this case from elf/dl-runtime.c. The patch
below fixes the problem on sparc following the same principle, but is
just there to show the issue, it's not acceptable for mainline.
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index b27cfbf..840e114 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -146,7 +146,7 @@ _dl_fixup (
if (sym != NULL
&& __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0))
- value = ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (value)) ();
+ value = ((DL_FIXUP_VALUE_TYPE (*) (int)) DL_FIXUP_VALUE_ADDR (value)) (GLRO(dl_hwcap));
/* Finally, fix up the plt itself. */
if (__builtin_expect (GLRO(dl_bind_not), 0))
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net