Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
	       Ulrich Weigand <uweigand@de.ibm.com>,
	       Stefan Liebler <stli@linux.vnet.ibm.com>
Subject: Re: [PATCH] Pass HWCAP to ifunc resolver
Date: Thu, 01 Sep 2016 09:19:00 -0000	[thread overview]
Message-ID: <m31t14m0yv.fsf@oc1027705133.ibm.com> (raw)
In-Reply-To: <CA+=Sn1mHfspkybW-LU_mde=E6D_LDDuWDy9wD4+k86XnqmLMnA@mail.gmail.com>	(Andrew Pinski's message of "Wed, 31 Aug 2016 22:03:06 -0700")

On Thu, Sep 01 2016, Andrew Pinski wrote:

> On Wed, Aug 31, 2016 at 4:49 AM, Andreas Arnez <arnez@linux.vnet.ibm.com> wrote:
>> On various GNU Elf architectures, including AArch64, ARM, s390/s390x,
>> ppc32/64, and sparc32/64, the dynamic loader passes HWCAP as a parameter
>> to each ifunc resolver.  Currently there is an open glibc Bugzilla that
>> requests this to be generalized to all architectures:
>>
>>   https://sourceware.org/bugzilla/show_bug.cgi?id=19766
>>
>> And various ifunc resolvers already rely on receiving HWCAP.  Currently
>> GDB always calls an ifunc resolver without any arguments; thus the
>> resolver may receive garbage, and based on that, the resolver may decide
>> to return a function that is not suited for the given platform.
>>
>> This patch always passes HWCAP to ifunc resolvers, even on systems where
>> the dynamic loader currently behaves otherwise.  The rationale is
>> that (1) the dynamic loader may get adjusted on those systems as well in
>> the future; (2) passing an unused argument should not cause a problem
>> with existing resolvers; and (3) the logic is much simpler without such
>> a distinction.
>
> Doesn't some targets pass HWCAP2 too?

If I understand the glibc code correctly, no.  The loader maintains the
variables dl_hwcap and dl_hwcap2 and fills them from AT_HWCAP and
AT_HWCAP2, respectively, but the ifunc resolvers only receive dl_hwcap:

  ./sysdeps/aarch64/dl-irel.h:33:  return ((ElfW(Addr) (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/arm/dl-irel.h:33:  return ((Elf32_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/generic/dl-irel.h:26:  return ((DL_FIXUP_VALUE_TYPE (*) (void)) (addr)) ();
  ./sysdeps/hppa/dl-irel.h:36:  return ((struct fdesc) {0, 0});
  ./sysdeps/i386/dl-irel.h:32:  return ((Elf32_Addr (*) (void)) (addr)) ();
  ./sysdeps/powerpc/powerpc32/dl-irel.h:33:  return ((Elf32_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/powerpc/powerpc64/dl-irel.h:34:  return ((Elf64_Addr (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/s390/dl-irel.h:33:  return ((ElfW(Addr) (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/sparc/sparc32/dl-irel.h:34:  return ((Elf32_Addr (*) (int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/sparc/sparc64/dl-irel.h:34:  return ((Elf64_Addr (*) (int)) (addr)) (GLRO(dl_hwcap));
  ./sysdeps/x86_64/dl-irel.h:32:  return ((ElfW(Addr) (*) (void)) (addr)) ();

--
Andreas


  reply	other threads:[~2016-09-01  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 11:50 Andreas Arnez
2016-09-01  5:03 ` Andrew Pinski
2016-09-01  9:19   ` Andreas Arnez [this message]
2016-09-06 15:42 ` Ulrich Weigand
2016-09-09 18:02   ` Andreas Arnez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m31t14m0yv.fsf@oc1027705133.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pinskia@gmail.com \
    --cc=stli@linux.vnet.ibm.com \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox