This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PowerPC: gettimeofday optimization by using IFUNC
On 03/14/2013 09:40 AM, Adhemerval Zanella wrote:
> 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?
You're still missing the fact that either:
(1) __vdso_gettimeofday is a pointer to an OPD and so taking the address of
__vdso_gettimeofday is wrong, or
(2) __vdso_gettimeofday is not itself an OPD.
I don't really believe (1) is true because that would never have survived even
minimal testing with that address-of operator included.
Recall that the format of an OPD is:
struct {
void *code_ptr;
void *toc_ptr;
void *chain_ptr;
};
It's clear that "&pointer" does not qualify and thus (2) is true.
How about something like:
/* This macro is needed for PPC64 to return a skeleton OPD entry of a vDSO
symbol. This works because _dl_vdso_vsym always return the function
address, and no vDSO symbols use the TOC or chain pointers from the OPD
so we can allow them to be garbage. */
and then name the macro "VDSO_IFUNC_RET" to make it clear we're not talking
about generic pointers as "PTR_IFUNC_RET" might suggest.
Future work might include cleaning all this up so that it's much more obvious
what's going on. Consider:
struct __vdso_opd {
void *code;
#ifndef USE_PPC64_OVERLAPPING_OPD
void *toc;
void *chain;
#endif
};
typedef struct __vdso_opd __vdso_ret;
Change the return type of _dl_vdso_vsym generically to __vdso_ret, where the
default version is a typedef to void*.
I'm not sure that you can adjust DL_SYMBOL_ADDRESS, as that's also used by the
regular part of the dynamic linker. You could either invent a new macro to be
used by the generic dl-vdso.c, or make a private copy for ppc64. If a new
macro, you could fairly easily compute the value as (__vdso_ret){ ... } to fill
in only the first entry of the structure (letting C rules fill the rest w/0).
Adjust VDSO_IFUNC_RET so that the type of the object passed is validated.
r~