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

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Jun 30 15:17:37 GMT 2026



On 30/06/26 11:15, Wilco Dijkstra wrote:
> 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.

This adds extra complexity for debuggers to have arch-specific knowledge of
how ifunc works when called directly.  Doable, but it is essentially another
undocumented semantic. 

But this workaround already would require debuggers to parse whether the ifunc
return code is the resolver or an ifunc selection anyway; so this might not be
a problem anyway.

And I think this might add another subtle issue where it might not be safe to
call glibc functions mixing memory allocated with different allocators.

> 
> 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...
Afaik there is no constraint after libc being mapped, but the runtime not yet
initialized. There is still the window where it can be called *before* TLS /
thread point initialization, where even with this workaround the inferior
will most likely crash. The _dl_rtld_map way at least make the crash more
reliable (compare to GLRO(dl_entry) check).




More information about the Libc-alpha mailing list