On Wed, 30 Jul 2025 at 01:15, Richard Henderson <richard.hender...@linaro.org> wrote: > > All definitions of ELF_HWCAP2 are now identical. The only > catch is whether or not a target defines it. Unlike the > primary AT_HWCAP, we'd like to omit AT_HWCAP2 entirely if > there is no definition for it. > > Mark get_elf_hwcap2 as weak, so that the function may be omitted. > Check that the function exists before calling it. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
> +/* > + * Locally declare get_elf_hwcap2 weak, so a target may omit it, and > + * so that here in elfload.c we can tell that the target omitted it. > + * The declaration in loader.h, used by the definitions in arch/hwcap.c, > + * remains strong. > + */ > +#pragma GCC diagnostic push > +#pragma GCC diagnostic ignored "-Wredundant-decls" > +abi_ulong get_elf_hwcap2(CPUState *cs) __attribute__((weak)); > +#pragma GCC diagnostic pop Having to do this dance with the GCC diagnostic pragma doesn't look very nice. I would be inclined to go with the more straightforward approach of having the target define a TARGET_HAS_ELF_HWCAP2 somewhere if it implements hwcap2. -- PMM