This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: V5 [PATCH 2/2] x86: Add a LD_PRELOAD IFUNC resolver test for CPU_FEATURE_USABLE
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 24 Oct 2018 04:00:36 -0700
- Subject: Re: V5 [PATCH 2/2] x86: Add a LD_PRELOAD IFUNC resolver test for CPU_FEATURE_USABLE
- References: <20180927194327.7683-1-hjl.tools@gmail.com> <20180927194327.7683-3-hjl.tools@gmail.com> <878t2n908g.fsf@oldenburg.str.redhat.com>
On 10/24/18, Florian Weimer <fweimer@redhat.com> wrote:
> * H. J. Lu:
>
>> +static bool
>> +ifunc_check_sse2 (void)
>> +{
>> + return CPU_FEATURE_USABLE (SSE2);
>> +}
>> +
>> +static bool
>> +(*get_check_sse2 (void)) (void)
>> +{
>> + return ifunc_check_sse2;
>> +}
>> +
>> +bool check_sse2 (void) __attribute__((ifunc("get_check_sse2")));
>
> The IFUNC resolver does not call CPU_FEATURE_USABLE, so this is not the
> test I had in mind.
>
> The patch below fixes this, and adds something that actually violates
> the ordering constraints. With these changes, I get this when building
> glibc with --enable-bind-now:
>
> elf/tst-x86-platform-4: Relink `./libc.so.6' with
> `elf/tst-x86-platform-preload-4.so' for IFUNC symbol `free'
> Segmentation fault (core dumped)
>
> I think using CPU_FEATURE_USABLE in a malloc implementation is something
> that could be quite natural, so I think this really should be fixed in
> some way.
>
>
...
> +
> +static __typeof__ (free) *
> +get_free (void)
> {
> - return ifunc_check_avx2;
> + if (CPU_FEATURE_USABLE (RTM))
> + return free_with_rtm;
> + if (CPU_FEATURE_USABLE (AVX2))
> + return free_with_avx2;
> + if (CPU_FEATURE_USABLE (AVX))
> + return free_with_avx;
> + if (CPU_FEATURE_USABLE (SSE))
> + return free_with_see;
> + return free_fallback;
> }
>
> -bool check_avx2 (void) __attribute__((ifunc("get_check_avx2")));
> +void free (void *) __attribute__ ((ifunc ("get_free")));
>
I guess you knew that this issue was independent of my new functions.
You will get the same error regardless of what the get_free body has.
--
H.J.