V5 [PATCH 2/2] x86: Add a LD_PRELOAD IFUNC resolver test for CPU_FEATURE_USABLE

H.J. Lu hjl.tools@gmail.com
Wed Oct 24 11:01:00 GMT 2018


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.



More information about the Libc-alpha mailing list