[PATCH] aarch64: Fix static PIE CPU feature detection (BZ 34205)

Wilco Dijkstra Wilco.Dijkstra@arm.com
Fri Jun 5 14:56:58 GMT 2026


Hi Adhemerval,

> ARCH_INIT_CPU_FEATURES is called from __libc_start_main before
> _dl_relocate_static_pie, so any code it runs must not rely on
> relocations being applied yet.  Two issues break this under static PIE:
>
>  1. The cpu_list table held 'const char *name' members, whose
>     addresses are not link-time constants under PIE and thus require
>     base-relative relocations that are not yet in place.  Replace the
>     array of structs with a flat NUL-separated name string and a
>     parallel midr array, removing the pointer relocations.

Isn't that true as well for struct tunable_str_t? How is it possible for one
to fail but the other to work when they are both using const char* and
both are in the same static executable?

Also should these relocations be done at the same point whether we are
static/dynamic, PIC/PIE or not? If the order is different then it is hard to get
anything right...

>  2. tunable_strcmp pulls in memcmp, which is an IFUNC and is likewise
>     unresolved at this point.  Redirect memcmp to __memcmp_generic in
>     the aarch64 dl-symbol-redir-ifunc.h and include it from
>     csu/libc-start.c.

Given all the recent fixes to various dl-symbol-redir-ifunc.h, would it not
be best to add all ifuncs to it?

Could we check that the early init object files in the linker do not use any PLT
calls so there is at least an error if people forget when adding a new ifunc?


The changes look fine - though I don't believe get_midr_from_mcpu is very useful...

Cheers,
Wilco


More information about the Libc-alpha mailing list