[PATCH 2/2] aarch64: Add workaround for GDB bug handling string literals

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Jun 30 14:15:44 GMT 2026


Hi,

> I don't like it either, but I don't see a better alternative to keep some
> compatibility with old gdb.
>
> But I also think this approach is fragile: it require some assumptions on how
> gdb implements this and adds some magic number.  I think a better alternative
> is invert the assumption: the only exactly legitimate caller of an IFUNC
> resolver is the the dynamic loader's relocation machinery
> (elf_ifunc_invoke / _dl_fixup):

On AArch64 we can just check for !(arg0 & IFUNC_ARG_HWCAP) since we always
invoke ifuncs with that bit set from GLIBC (obviously the value is way too large to
ever be a valid allocation). You could also check arg0 == GLRO (dl_hwcap) for other
targets.

I'd suggest to give an error since it is a bug in GDB and you only get it in some
scenarios (hence hard to justify risky hacks in GLIBC to make some cases work).

Btw is it possible for GDB to call malloc before initialization? Malloc no longer does
auto-init, so we rely on initialization to be called first. There are lots of issues with
an external agent inserting calls besides killing the repeatable debug experience...

Cheers,
Wilco



More information about the Libc-alpha mailing list