public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203]
Date: Fri, 18 Sep 2020 16:22:55 +0200	[thread overview]
Message-ID: <87y2l75fls.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOqDwrj5Jba2=y1HaZfs09-SQ3QRrsqF9XEQCASTxfD8jw@mail.gmail.com> (H. J. Lu's message of "Fri, 18 Sep 2020 07:18:52 -0700")

* H. J. Lu:

> On Fri, Sep 18, 2020 at 6:59 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > On Fri, Sep 18, 2020 at 1:06 AM Florian Weimer <fweimer@redhat.com> wrote:
>> >>
>> >> * H. J. Lu via Libc-alpha:
>> >>
>> >> > X86 CPU features in ld.so are initialized by init_cpu_features, which is
>> >> > invoked by DL_PLATFORM_INIT from _dl_sysdep_start.  But when ld.so is
>> >> > loaded by static executable, DL_PLATFORM_INIT is never called.
>> >>
>> >> I don't think that's accurate.  It's called from elf/dl-support.c in the
>> >> static case.  But I agree that it's too late in this case.
>> >
>> > I was referring to the ld.so case.  elf/dl-support.c isn't used for ld.so.
>>
>> I missed that.
>>
>> You cannot use ld.so in a static executable because it is
>> uninitialized/dormant.
>>
>> If you need functionality after static dlopen, it has to reside in
>> libc.so.6, not the dynamic loader.
>
> Here is the problem.  static dlopen uses libc.so.6 which brings in ld.so
> with _rtld_global and _rtld_global_ro via DT_NEEDED.  My patch is
> trying to deal with it to initialize CPU info in _rtld_global_ro in this case.

Putting this data into _rtld_global_ro is not correct if it is required
after static dlopen.  The current static dlopen approach simply does not
support that.  You can only assume that libc.so has been initialized
after static dlopen.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


  reply	other threads:[~2020-09-18 14:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 13:44 [PATCH 0/3] ld.so: Add --list-tunables to print tunable values H.J. Lu
2020-09-12 13:44 ` [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203] H.J. Lu
2020-09-18  8:06   ` Florian Weimer
2020-09-18 13:55     ` H.J. Lu
2020-09-18 13:59       ` Florian Weimer
2020-09-18 14:18         ` H.J. Lu
2020-09-18 14:22           ` Florian Weimer [this message]
2020-09-18 14:30             ` H.J. Lu
2020-09-21  8:21               ` Florian Weimer
2020-09-21 11:31                 ` H.J. Lu
2020-09-25 12:55                   ` Florian Weimer
2020-09-12 13:44 ` [PATCH 2/3] Set tunable value as well as min/max values H.J. Lu
2020-09-18  8:29   ` Florian Weimer
2020-09-18 15:11     ` H.J. Lu
2020-09-12 13:44 ` [PATCH 3/3] ld.so: Add --list-tunables to print tunable values H.J. Lu
2020-09-18  8:13   ` Florian Weimer
2020-09-18 15:24     ` H.J. Lu
  -- strict thread matches above, loose matches on Subject: below --
2020-07-12 14:24 [PATCH 0/3] " H.J. Lu
2020-07-12 14:24 ` [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203] H.J. Lu

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=87y2l75fls.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).