Re: [PATCH 2/2] malloc: aarch64: Add ifuncs for malloc functions

Adhemerval Zanella Netto <[email protected]> Wed, 29 Jul 2026 15:59:32 -0300
Newsgroups gmane.comp.lib.glibc.alpha
Organization Linaro
Message-ID <[email protected]>

On 29/07/26 10:21, Yury Khrustalev wrote:
> On Tue, Jul 28, 2026 at 05:12:15PM +0100, Yury Khrustalev wrote:
>> Introduce ifuncs and resolvers for functions pertinent to the
>> malloc interface on the AArch64 target: malloc, calloc, free,
>> realloc, memalign, valloc, pvalloc, posix_memalign, aligned_alloc,
>> free_sized, free_aligned_sized, malloc_usable_size.
>>
>> A target can define the USE_MULTIARCH_MALLOC macro. In this case
>> it must provide alternative aliases for the malloc functions that
>> point to the ifuncs.
>>
>> This implementation respects the --disable-multi-arch configure
>> flag. If multi-arch support is disabled, the generic aliases
>> are used on aarch64.
>>
>> This patch contains aarch64-specific resolvers. At this point they
>> return core implementations but in the future they can be changed
>> to support for features, e.g. to handle memory tagging.
>> ---
>>  malloc/malloc-internal.h                  |  1 +
>>  malloc/malloc.c                           | 11 ++-
>>  sysdeps/aarch64/multiarch/Makefile        |  6 ++
>>  sysdeps/aarch64/multiarch/malloc-ifuncs.c | 82 +++++++++++++++++++++++
>>  sysdeps/aarch64/multiarch/malloc-ifuncs.h | 25 +++++++
>>  sysdeps/generic/malloc-ifuncs.h           | 36 ++++++++++
>>  6 files changed, 159 insertions(+), 2 deletions(-)
>>  create mode 100644 sysdeps/aarch64/multiarch/malloc-ifuncs.c
>>  create mode 100644 sysdeps/aarch64/multiarch/malloc-ifuncs.h
>>  create mode 100644 sysdeps/generic/malloc-ifuncs.h
> 
> To work around this bug in GDB [1], it is possible to apply this GDB
> patch from Muhammad [2]. It cleanly applies to GDB master as of now and
> provides a fix that resolves the issue with malloc being ifunc.
> 
> Although, [2] is not a final fix, it resolves the immediate problem and
> is stable (passes regression). This might be useful after malloc ifuncs
> are merged to Glibc master and before GDB is fixed.

The change looks ok and I think it would be good to have it at the start of
the development to have a lot of time for testing.

And what is missing from [2] to be considered a final fix? Are Muhammad aimed
to change how gdb allocates process memory to make the function call (like
using mmap or something else like stack allocation to avoid interfere with
malloc metadata)?

> 
> [1]: https://sourceware.org/bugzilla/show_bug.cgi?id=34330
> [2]: https://inbox.sourceware.org/gdb-patches/[email protected]/
> 
> Thanks,
> Yury
>