[PATCH v3] aarch64: add support for hwcap3,4
Yury Khrustalev
yury.khrustalev@arm.com
Thu Apr 24 08:53:24 GMT 2025
On Wed, Apr 23, 2025 at 06:22:47PM +0200, Florian Weimer wrote:
> ...
>
So, do I understand you correctly, that this is the proposed solution:
1. Keep the _hwcap and _hwcap2 fields in the struct (so that existing
code can continue using them).
2. Add new _hwcap3,4 fields to the struct (and keep adding them in the
future). We'll use this struct in elf_ifunc_invoke() internally.
3. Explain in the comments and docs that the struct should not be used
by ifunc resolvers.
4. Provide access function to retrieve a hwcap element by its number
or zero depending on runtime availability. Recommend using this
function in resolvers (see note below).
__ifunc_hwcap (const __ifunc_arg_t *__arg, unsigned long int __n);
5. Maybe also provide a function to check validity of the object: it
could check the value in the _size field against one of the allowed
values _IFUNC_ARG_SIZE_VER{0,1}.
Note that I use "const __ifunc_arg_t *__arg" in the function above
because we already use this type as part of API, we could do cast
to "unsigned long int *" inside this function. Also in this case we
don't need to change the resolver function type:
ElfW(Addr) ifunc_resolver (uint64_t, const __ifunc_arg_t *);
I like this solution. The only problem is how user will use it when
writing resolvers. Right now even presence of the <sys/ifunc.h> header
is not guaranteed (it was backported back to 2.30 which means that distros
that are still actively supported, e.g. Ubuntu 18.04 with Glibc 2.27)
can't use it.
So what people do is something like this:
#if __has_include(<sys/ifunc.h>)
# include <sys/ifunc.h>
#else
/* Copy-paste some version of that header. */
#endif
And now, when the header is present they will also have to check if the
_IFUNC_HWCAP_MAX macro is defined and if not **still write their own
implementation** if it's not.
So, in essence trying to include this header does more bad than good.
What I think we should do is to document how to access individual hwcap
elements (e.g. put the suggested __ifunc_hwcap implementation in the ABI
spec) and only use <sys/ifunc.h> internally.
Does this make sense?
Thanks,
Yury
More information about the Libc-alpha
mailing list