This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerPC: gettimeofday optimization by using IFUNC


On 03/14/2013 05:37 AM, Adhemerval Zanella wrote:
>> > This is fine with me as long as Richard's objection has been addressed
>> > to his liking.
>> >
>> > Ryan S. Arnold
>> >
> Hi Richard, 
> 
> Sorry to bother you. Regarding the patch, is my explanation suffice to you?
> Do you have any more concerns about this patch?

Ok, I should have looked harder originally.  My original objection, function
pointer decomposition, doesn't apply because this thing isn't a function --
it's a plain pointer variable:

init-first.c:void *__vdso_gettimeofday attribute_hidden;

That said,

> +/* Macro to return vdso_xxx value on IFUNC implementations.
> +   On PPC64 the returned value is actually an OPD entry.  */
> +#if defined(__PPC64__) || defined(__powerpc64__)
> +#define PTR_IFUNC_RET(value)  &value
> +#else
> +#define PTR_IFUNC_RET(value)  value
> +#endif

needs better commentary, or in fact a bug fix, because __vdso_gettimeofday *is*
a plain pointer variable, and not an OPD entry at all.

You probably get away with this because the code in the vdso doesn't actually
use its toc pointer, and the next word after __vdso_gettimeofday just so
happens to be readable.  So the loaded toc pointer is garbage, but gets
restored to the caller's valid value on return.

Which to me means that while you may be able to get away with this for the
vdso, the macro itself is not generally valid and may come back to bite you in
future if this macro is used in any other context.

I guess I'd be happy for now with the macro moved to gettimeofday.c and the
comment expanded as per above.  At least then one will have to work harder to
be bitten the next time someone plays with ifuncs on ppc.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]