This is the mail archive of the 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 14-03-2013 12:14, Richard Henderson wrote:
>> +/* 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~
Hi Richard, thanks for the comments. Indeed I should have make my comment more clear.
The issue is at fixup phase on first PLT call, on IFUNC resolve at elf/dl-runtime.c:

value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value));

The value returned is expected to be an OPD entry for PPC64, while _dl_vdso_vsym always
return the function address (even on PPC64). So '__vdso_gettimeofday' will always point
to the symbol address and that's why we need the extra indirection only on PPC64.

Maybe if I rephrase the comments to:

/* This macros is need for PPC64 to return the ODP entry of vDSO symbol
   since _dl_vdso_vsym always return the function address and the fixup
   code expects a ODP entry.  */

What do you think?

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