[PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203]

H.J. Lu hjl.tools@gmail.com
Mon Sep 21 11:31:23 GMT 2020


On Mon, Sep 21, 2020 at 1:21 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> >> 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.
>
> > Unless it is removed,  _rtld_global_ro is the right place.  _rtld_global_ro
> > is initialized by dynamic relocation.  My patch does it.
>
> It initializes only part of it.  I find this rather confusing.
>
> Why is this data in ld.so in the first place?

I put it in ld.so with

commit e2e4f56056adddc3c1efe676b40a4b4f2453103b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Aug 13 03:37:47 2015 -0700

    Add _dl_x86_cpu_features to rtld_global

    This patch adds _dl_x86_cpu_features to rtld_global in x86 ld.so
    and initializes it early before __libc_start_main is called so that
    cpu_features is always available when it is used and we can avoid
    calling __init_cpu_features in IFUNC selectors.

which made many things possible, including CET support and

commit bea3f92405f705684275bffee954cafe84ffb09d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Oct 22 08:24:00 2017 -0700

    x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve [BZ #21265]

    In _dl_runtime_resolve, use fxsave/xsave/xsavec to preserve all vector,
    mask and bound registers.  It simplifies _dl_runtime_resolve and supports
    different calling conventions.  ld.so code size is reduced by more than
    1 KB.  However, use fxsave/xsave/xsavec takes a little bit more cycles
    than saving and restoring vector and bound registers individually.

-- 
H.J.


More information about the Libc-alpha mailing list