diff mbox series

[v8,08/10] glibc.malloc.check: Wean away from malloc hooks

Message ID 20210713073845.504356-9-siddhesh@sourceware.org
State New
Headers show
Series malloc hooks removal | expand

Commit Message

Siddhesh Poyarekar July 13, 2021, 7:38 a.m. UTC
The malloc-check debugging feature is tightly integrated into glibc
malloc, so thanks to an idea from Florian Weimer, much of the malloc
implementation has been moved into libc_malloc_debug.so to support
malloc-check.  Due to this, glibc malloc and malloc-check can no
longer work together; they use altogether different (but identical)
structures for heap management.  This should not make a difference
though since the malloc check hook is not disabled anywhere.
malloc_set_state does, but it does so early enough and that behaviour
has been ported to the debug DSO.

The only changes to malloc.c in this change is to add #if IS_IN (libc)
to not compile some functions into the debug DSO, especially the
allocator function entry points.

The malloc check tunable is now in the debug DSO and has no effect
when the DSO is not preloaded.
---
 malloc/Makefile                               |   3 +-
 malloc/Versions                               |  13 ++
 malloc/arena.c                                |  17 +-
 malloc/hooks.c                                |  17 +-
 malloc/malloc-check.c                         |  63 +++---
 malloc/malloc-debug.c                         | 181 ++++++++++++++++--
 malloc/malloc.c                               |  35 ++--
 sysdeps/aarch64/Makefile                      |   3 +
 .../mach/hurd/i386/libc_malloc_debug.abilist  |   7 +
 .../linux/aarch64/libc_malloc_debug.abilist   |   7 +
 .../linux/alpha/libc_malloc_debug.abilist     |   7 +
 .../sysv/linux/arc/libc_malloc_debug.abilist  |   7 +
 .../linux/arm/be/libc_malloc_debug.abilist    |   7 +
 .../linux/arm/le/libc_malloc_debug.abilist    |   7 +
 .../sysv/linux/csky/libc_malloc_debug.abilist |   7 +
 .../sysv/linux/hppa/libc_malloc_debug.abilist |   7 +
 .../sysv/linux/i386/libc_malloc_debug.abilist |   7 +
 .../sysv/linux/ia64/libc_malloc_debug.abilist |   7 +
 .../m68k/coldfire/libc_malloc_debug.abilist   |   7 +
 .../m68k/m680x0/libc_malloc_debug.abilist     |   7 +
 .../microblaze/be/libc_malloc_debug.abilist   |   7 +
 .../microblaze/le/libc_malloc_debug.abilist   |   7 +
 .../mips/mips32/fpu/libc_malloc_debug.abilist |   7 +
 .../mips32/nofpu/libc_malloc_debug.abilist    |   7 +
 .../mips/mips64/n32/libc_malloc_debug.abilist |   7 +
 .../mips/mips64/n64/libc_malloc_debug.abilist |   7 +
 .../linux/nios2/libc_malloc_debug.abilist     |   7 +
 .../powerpc32/fpu/libc_malloc_debug.abilist   |   7 +
 .../powerpc32/nofpu/libc_malloc_debug.abilist |   7 +
 .../powerpc64/be/libc_malloc_debug.abilist    |   7 +
 .../powerpc64/le/libc_malloc_debug.abilist    |   7 +
 .../riscv/rv32/libc_malloc_debug.abilist      |   7 +
 .../riscv/rv64/libc_malloc_debug.abilist      |   7 +
 .../s390/s390-32/libc_malloc_debug.abilist    |   7 +
 .../s390/s390-64/libc_malloc_debug.abilist    |   7 +
 .../linux/sh/be/libc_malloc_debug.abilist     |   7 +
 .../linux/sh/le/libc_malloc_debug.abilist     |   7 +
 .../sparc/sparc32/libc_malloc_debug.abilist   |   7 +
 .../sparc/sparc64/libc_malloc_debug.abilist   |   7 +
 .../linux/x86_64/64/libc_malloc_debug.abilist |   7 +
 .../x86_64/x32/libc_malloc_debug.abilist      |   7 +
 41 files changed, 482 insertions(+), 81 deletions(-)

Comments

Carlos O'Donell July 17, 2021, 10:04 p.m. UTC | #1
On 7/13/21 3:38 AM, Siddhesh Poyarekar wrote:
> The malloc-check debugging feature is tightly integrated into glibc
> malloc, so thanks to an idea from Florian Weimer, much of the malloc
> implementation has been moved into libc_malloc_debug.so to support
> malloc-check.  Due to this, glibc malloc and malloc-check can no
> longer work together; they use altogether different (but identical)
> structures for heap management.  This should not make a difference
> though since the malloc check hook is not disabled anywhere.
> malloc_set_state does, but it does so early enough and that behaviour
> has been ported to the debug DSO.
> 
> The only changes to malloc.c in this change is to add #if IS_IN (libc)
> to not compile some functions into the debug DSO, especially the
> allocator function entry points.

I can't believe this works, but it "recreates" a partial malloc oustside
of libc inside libc_malloc_debug but with calls to the internal routines
for everything else.

OK for 2.34.

Tested without regression on x86_64 and i686.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>


> The malloc check tunable is now in the debug DSO and has no effect
> when the DSO is not preloaded.
> ---
>  malloc/Makefile                               |   3 +-
>  malloc/Versions                               |  13 ++
>  malloc/arena.c                                |  17 +-
>  malloc/hooks.c                                |  17 +-
>  malloc/malloc-check.c                         |  63 +++---
>  malloc/malloc-debug.c                         | 181 ++++++++++++++++--
>  malloc/malloc.c                               |  35 ++--
>  sysdeps/aarch64/Makefile                      |   3 +
>  .../mach/hurd/i386/libc_malloc_debug.abilist  |   7 +
>  .../linux/aarch64/libc_malloc_debug.abilist   |   7 +
>  .../linux/alpha/libc_malloc_debug.abilist     |   7 +
>  .../sysv/linux/arc/libc_malloc_debug.abilist  |   7 +
>  .../linux/arm/be/libc_malloc_debug.abilist    |   7 +
>  .../linux/arm/le/libc_malloc_debug.abilist    |   7 +
>  .../sysv/linux/csky/libc_malloc_debug.abilist |   7 +
>  .../sysv/linux/hppa/libc_malloc_debug.abilist |   7 +
>  .../sysv/linux/i386/libc_malloc_debug.abilist |   7 +
>  .../sysv/linux/ia64/libc_malloc_debug.abilist |   7 +
>  .../m68k/coldfire/libc_malloc_debug.abilist   |   7 +
>  .../m68k/m680x0/libc_malloc_debug.abilist     |   7 +
>  .../microblaze/be/libc_malloc_debug.abilist   |   7 +
>  .../microblaze/le/libc_malloc_debug.abilist   |   7 +
>  .../mips/mips32/fpu/libc_malloc_debug.abilist |   7 +
>  .../mips32/nofpu/libc_malloc_debug.abilist    |   7 +
>  .../mips/mips64/n32/libc_malloc_debug.abilist |   7 +
>  .../mips/mips64/n64/libc_malloc_debug.abilist |   7 +
>  .../linux/nios2/libc_malloc_debug.abilist     |   7 +
>  .../powerpc32/fpu/libc_malloc_debug.abilist   |   7 +
>  .../powerpc32/nofpu/libc_malloc_debug.abilist |   7 +
>  .../powerpc64/be/libc_malloc_debug.abilist    |   7 +
>  .../powerpc64/le/libc_malloc_debug.abilist    |   7 +
>  .../riscv/rv32/libc_malloc_debug.abilist      |   7 +
>  .../riscv/rv64/libc_malloc_debug.abilist      |   7 +
>  .../s390/s390-32/libc_malloc_debug.abilist    |   7 +
>  .../s390/s390-64/libc_malloc_debug.abilist    |   7 +
>  .../linux/sh/be/libc_malloc_debug.abilist     |   7 +
>  .../linux/sh/le/libc_malloc_debug.abilist     |   7 +
>  .../sparc/sparc32/libc_malloc_debug.abilist   |   7 +
>  .../sparc/sparc64/libc_malloc_debug.abilist   |   7 +
>  .../linux/x86_64/64/libc_malloc_debug.abilist |   7 +
>  .../x86_64/x32/libc_malloc_debug.abilist      |   7 +
>  41 files changed, 482 insertions(+), 81 deletions(-)
> 
> diff --git a/malloc/Makefile b/malloc/Makefile
> index c0dbe04b57..c9504d0916 100644
> --- a/malloc/Makefile
> +++ b/malloc/Makefile
> @@ -133,7 +133,7 @@ test-extras = \
>  libmemusage-routines = memusage
>  libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
>  
> -libc_malloc_debug-routines = malloc-debug
> +libc_malloc_debug-routines = malloc-debug $(sysdep_malloc_debug_routines)

OK.

>  libc_malloc_debug-inhibit-o = $(filter-out .os,$(object-suffixes))
>  
>  $(objpfx)tst-malloc-backtrace: $(shared-thread-library)
> @@ -250,6 +250,7 @@ tst-malloc-usable-tunables-ENV = GLIBC_TUNABLES=glibc.malloc.check=3 \
>  
>  tst-mxfast-ENV = GLIBC_TUNABLES=glibc.malloc.tcache_count=0:glibc.malloc.mxfast=0
>  
> +CPPFLAGS-malloc-debug.c += -DUSE_TCACHE=0

OK, build the internal malloc implementations without tcache.

>  ifeq ($(experimental-malloc),yes)
>  CPPFLAGS-malloc.c += -DUSE_TCACHE=1
>  else
> diff --git a/malloc/Versions b/malloc/Versions
> index 71d933de19..2961d0796d 100644
> --- a/malloc/Versions
> +++ b/malloc/Versions
> @@ -119,13 +119,26 @@ libc_malloc_debug {
>      mprobe;
>      mtrace;
>      muntrace;
> +
> +    mallinfo;
> +    malloc_set_state;
> +    malloc_stats;
> +    malloc_trim;
> +    malloc_usable_size;
> +    mallopt;
>    }
>    GLIBC_2.2 {
>      mcheck_check_all;
>      mcheck_pedantic;
>      posix_memalign;
>    }
> +  GLIBC_2.10 {
> +    malloc_info;
> +  }
>    GLIBC_2.16 {
>      aligned_alloc;
>    }
> +  GLIBC_2.33 {
> +    mallinfo2;
> +  }
>  }
> diff --git a/malloc/arena.c b/malloc/arena.c
> index 840426f9fb..edcaa8816d 100644
> --- a/malloc/arena.c
> +++ b/malloc/arena.c
> @@ -79,7 +79,9 @@ static __thread mstate thread_arena attribute_tls_model_ie;
>     acquired after free_list_lock has been acquired.  */
>  
>  __libc_lock_define_initialized (static, free_list_lock);
> +#if IS_IN (libc)
>  static size_t narenas = 1;
> +#endif
>  static mstate free_list;
>  
>  /* list_lock prevents concurrent writes to the next member of struct
> @@ -207,14 +209,6 @@ __malloc_fork_unlock_child (void)
>  }
>  
>  #if HAVE_TUNABLES
> -static void
> -TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
> -{
> -  int32_t value = (int32_t) valp->numval;
> -  if (value != 0)
> -    __malloc_check_init ();
> -}
> -
>  # define TUNABLE_CALLBACK_FNDECL(__name, __type) \
>  static inline int do_ ## __name (__type value);				      \
>  static void									      \
> @@ -309,7 +303,7 @@ ptmalloc_init (void)
>      }
>  #endif
>  
> -#ifdef SHARED
> +#if defined SHARED && IS_IN (libc)
>    /* In case this libc copy is in a non-default namespace, never use
>       brk.  Likewise if dlopened from statically linked program.  The
>       generic sbrk implementation also enforces this, but it is not
> @@ -323,7 +317,6 @@ ptmalloc_init (void)
>    malloc_init_state (&main_arena);
>  
>  #if HAVE_TUNABLES
> -  TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check));
>    TUNABLE_GET (top_pad, size_t, TUNABLE_CALLBACK (set_top_pad));
>    TUNABLE_GET (perturb, int32_t, TUNABLE_CALLBACK (set_perturb_byte));
>    TUNABLE_GET (mmap_threshold, size_t, TUNABLE_CALLBACK (set_mmap_threshold));
> @@ -401,8 +394,6 @@ ptmalloc_init (void)
>              }
>          }
>      }
> -  if (s && s[0] != '\0' && s[0] != '0')
> -    __malloc_check_init ();
>  #endif
>  }
>  
> @@ -672,6 +663,7 @@ heap_trim (heap_info *heap, size_t pad)
>  
>  /* Create a new arena with initial size "size".  */
>  
> +#if IS_IN (libc)
>  /* If REPLACED_ARENA is not NULL, detach it from this thread.  Must be
>     called while free_list_lock is held.  */
>  static void
> @@ -947,6 +939,7 @@ arena_get_retry (mstate ar_ptr, size_t bytes)
>  
>    return ar_ptr;
>  }
> +#endif
>  
>  void
>  __malloc_arena_thread_freeres (void)
> diff --git a/malloc/hooks.c b/malloc/hooks.c
> index 8e9fefe6c3..af72b622c5 100644
> --- a/malloc/hooks.c
> +++ b/malloc/hooks.c
> @@ -39,10 +39,10 @@ void *weak_variable (*__malloc_hook) (size_t, const void *) = NULL;
>  void *weak_variable (*__realloc_hook) (void *, size_t, const void *) = NULL;
>  void *weak_variable (*__memalign_hook) (size_t, size_t, const void *) = NULL;
>  
> -#include "malloc-check.c"
> -
>  #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25)
>  
> +static void ptmalloc_init (void);
> +
>  /* Support for restoring dumped heaps contained in historic Emacs
>     executables.  The heap saving feature (malloc_get_state) is no
>     longer implemented in this version of glibc, but we have a heap
> @@ -106,14 +106,11 @@ malloc_set_state (void *msptr)
>       must be called before the first call into the malloc subsytem
>       (usually via __malloc_initialize_hook).  pthread_create always
>       calls calloc and thus must be called only afterwards, so there
> -     cannot be more than one thread when we reach this point.  */
> -
> -  /* Disable the malloc hooks (and malloc checking).  */
> -  __malloc_hook = NULL;
> -  __realloc_hook = NULL;
> -  __free_hook = NULL;
> -  __memalign_hook = NULL;
> -  using_malloc_checking = 0;
> +     cannot be more than one thread when we reach this point.  Since the
> +     initialization hook is now in libc_malloc_debug.so, we may need to
> +     initialize malloc.  */
> +  if (!__malloc_initialized)
> +    ptmalloc_init ();
>  
>    /* Patch the dumped heap.  We no longer try to integrate into the
>       existing heap.  Instead, we mark the existing chunks as mmapped.
> diff --git a/malloc/malloc-check.c b/malloc/malloc-check.c
> index dcab880510..a444c7478e 100644
> --- a/malloc/malloc-check.c
> +++ b/malloc/malloc-check.c
> @@ -17,20 +17,8 @@
>     License along with the GNU C Library; see the file COPYING.LIB.  If
>     not, see <https://www.gnu.org/licenses/>.  */
>  
> -
> -/* Whether we are using malloc checking.  */
> -static int using_malloc_checking;
> -
> -/* Activate a standard set of debugging hooks. */
> -void
> -__malloc_check_init (void)
> -{
> -  using_malloc_checking = 1;
> -  __malloc_hook = malloc_check;
> -  __free_hook = free_check;
> -  __realloc_hook = realloc_check;
> -  __memalign_hook = memalign_check;
> -}
> +#define __mremap mremap
> +#include "malloc.c"

OK. Wow, this is a complete compilation of malloc.

>  
>  /* When memory is tagged, the checking data is stored in the user part
>     of the chunk.  We can't rely on the user not having modified the
> @@ -63,14 +51,13 @@ magicbyte (const void *p)
>     must reach it with this iteration, otherwise we have witnessed a memory
>     corruption.  */
>  static size_t
> -malloc_check_get_size (mchunkptr p)
> +malloc_check_get_size (void *mem)
>  {
>    size_t size;
>    unsigned char c;
> +  mchunkptr p = mem2chunk (mem);
>    unsigned char magic = magicbyte (p);
>  
> -  assert (using_malloc_checking == 1);
> -
>    for (size = CHUNK_HDR_SZ + memsize (p) - 1;
>         (c = *SAFE_CHAR_OFFSET (p, size)) != magic;
>         size -= c)
> @@ -203,7 +190,7 @@ top_check (void)
>  }
>  
>  static void *
> -malloc_check (size_t sz, const void *caller)
> +malloc_check (size_t sz)
>  {
>    void *victim;
>    size_t nb;
> @@ -222,7 +209,7 @@ malloc_check (size_t sz, const void *caller)
>  }
>  
>  static void
> -free_check (void *mem, const void *caller)
> +free_check (void *mem)
>  {
>    mchunkptr p;
>  
> @@ -256,7 +243,7 @@ free_check (void *mem, const void *caller)
>  }
>  
>  static void *
> -realloc_check (void *oldmem, size_t bytes, const void *caller)
> +realloc_check (void *oldmem, size_t bytes)
>  {
>    INTERNAL_SIZE_T chnb;
>    void *newmem = 0;
> @@ -269,11 +256,11 @@ realloc_check (void *oldmem, size_t bytes, const void *caller)
>        return NULL;
>      }
>    if (oldmem == 0)
> -    return malloc_check (bytes, NULL);
> +    return malloc_check (bytes);
>  
>    if (bytes == 0)
>      {
> -      free_check (oldmem, NULL);
> +      free_check (oldmem);
>        return NULL;
>      }
>  
> @@ -348,12 +335,12 @@ invert:
>  }
>  
>  static void *
> -memalign_check (size_t alignment, size_t bytes, const void *caller)
> +memalign_check (size_t alignment, size_t bytes)
>  {
>    void *mem;
>  
>    if (alignment <= MALLOC_ALIGNMENT)
> -    return malloc_check (bytes, NULL);
> +    return malloc_check (bytes);
>  
>    if (alignment < MINSIZE)
>      alignment = MINSIZE;
> @@ -363,14 +350,14 @@ memalign_check (size_t alignment, size_t bytes, const void *caller)
>    if (alignment > SIZE_MAX / 2 + 1)
>      {
>        __set_errno (EINVAL);
> -      return 0;
> +      return NULL;
>      }
>  
>    /* Check for overflow.  */
>    if (bytes > SIZE_MAX - alignment - MINSIZE)
>      {
>        __set_errno (ENOMEM);
> -      return 0;
> +      return NULL;
>      }
>  
>    /* Make sure alignment is power of 2.  */
> @@ -388,3 +375,27 @@ memalign_check (size_t alignment, size_t bytes, const void *caller)
>    __libc_lock_unlock (main_arena.mutex);
>    return mem2mem_check (tag_new_usable (mem), bytes);
>  }
> +
> +static void
> +TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
> +{
> +  int32_t value = (int32_t) valp->numval;
> +  if (value != 0)
> +    __malloc_debug_enable (MALLOC_CHECK_HOOK);
> +}
> +
> +static bool
> +initialize_malloc_check (void)
> +{
> +  /* This is the copy of the malloc initializer that we pulled in along with
> +     malloc-check.  This does not affect any of the libc malloc structures.  */
> +  ptmalloc_init ();
> +#if HAVE_TUNABLES
> +  TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check));
> +#else
> +  const char *s = secure_getenv ("MALLOC_CHECK_");
> +  if (s && s[0] != '\0' && s[0] != '0')
> +    __malloc_debug_enable (MALLOC_CHECK_HOOK);
> +#endif
> +  return __is_malloc_debug_enabled (MALLOC_CHECK_HOOK);
> +}
> diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
> index 9942124e02..6e5402f20c 100644
> --- a/malloc/malloc-debug.c
> +++ b/malloc/malloc-debug.c
> @@ -50,6 +50,7 @@ enum malloc_debug_hooks
>    MALLOC_NONE_HOOK = 0,
>    MALLOC_MCHECK_HOOK = 1 << 0, /* mcheck()  */
>    MALLOC_MTRACE_HOOK = 1 << 1, /* mtrace()  */
> +  MALLOC_CHECK_HOOK = 1 << 2,  /* MALLOC_CHECK_ or glibc.malloc.check.  */
>  };
>  static unsigned __malloc_debugging_hooks;
>  
> @@ -73,6 +74,7 @@ __malloc_debug_disable (enum malloc_debug_hooks flag)
>  
>  #include "mcheck.c"
>  #include "mtrace.c"
> +#include "malloc-check.c"
>  
>  extern void (*__malloc_initialize_hook) (void);
>  compat_symbol_reference (libc, __malloc_initialize_hook,
> @@ -105,13 +107,18 @@ generic_hook_ini (void)
>    __malloc_hook = NULL;
>    __realloc_hook = NULL;
>    __memalign_hook = NULL;
> -  /* The compiler does not know that these functions are allocators, so it will
> -     not try to optimize it away.  */
> -  __libc_free (__libc_malloc (0));
> +
> +  /* malloc check does not quite co-exist with libc malloc, so initialize
> +     either on or the other.  */
> +  if (!initialize_malloc_check ())
> +    /* The compiler does not know that these functions are allocators, so it
> +       will not try to optimize it away.  */
> +    __libc_free (__libc_malloc (0));
>  
>    void (*hook) (void) = __malloc_initialize_hook;
>    if (hook != NULL)
>      (*hook)();
> +
>    debug_initialized = 1;
>  }
>  
> @@ -149,10 +156,11 @@ __debug_malloc (size_t bytes)
>  
>    void *victim = NULL;
>    size_t orig_bytes = bytes;
> -  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> -      || !malloc_mcheck_before (&bytes, &victim))
> +  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> +       || !malloc_mcheck_before (&bytes, &victim)))
>      {
> -      victim = __libc_malloc (bytes);
> +      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
> +		? malloc_check (bytes) : __libc_malloc (bytes));
>      }
>    if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK) && victim != NULL)
>      victim = malloc_mcheck_after (victim, orig_bytes);
> @@ -175,10 +183,12 @@ __debug_free (void *mem)
>  
>    if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
>      mem = free_mcheck (mem);
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    free_check (mem);
> +  else
> +    __libc_free (mem);
>    if (__is_malloc_debug_enabled (MALLOC_MTRACE_HOOK))
>      free_mtrace (mem, RETURN_ADDRESS (0));
> -
> -  __libc_free (mem);
>  }
>  strong_alias (__debug_free, free)
>  
> @@ -193,10 +203,12 @@ __debug_realloc (void *oldmem, size_t bytes)
>    size_t orig_bytes = bytes, oldsize = 0;
>    void *victim = NULL;
>  
> -  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> -      || !realloc_mcheck_before (&oldmem, &bytes, &oldsize, &victim))
> +  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> +       || !realloc_mcheck_before (&oldmem, &bytes, &oldsize, &victim)))
>      {
> -      victim = __libc_realloc (oldmem, bytes);
> +      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
> +		? realloc_check (oldmem, bytes)
> +		: __libc_realloc (oldmem, bytes));
>      }
>    if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK) && victim != NULL)
>      victim = realloc_mcheck_after (victim, oldmem, orig_bytes,
> @@ -219,10 +231,12 @@ _debug_mid_memalign (size_t alignment, size_t bytes, const void *address)
>    void *victim = NULL;
>    size_t orig_bytes = bytes;
>  
> -  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> -      || !memalign_mcheck_before (alignment, &bytes, &victim))
> +  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> +       || !memalign_mcheck_before (alignment, &bytes, &victim)))
>      {
> -      victim = __libc_memalign (alignment, bytes);
> +      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
> +		? memalign_check (alignment, bytes)
> +		: __libc_memalign (alignment, bytes));
>      }
>    if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK) && victim != NULL)
>      victim = memalign_mcheck_after (victim, alignment, orig_bytes);
> @@ -316,10 +330,11 @@ __debug_calloc (size_t nmemb, size_t size)
>    size_t orig_bytes = bytes;
>    void *victim = NULL;
>  
> -  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> -      || !malloc_mcheck_before (&bytes, &victim))
> +  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
> +       || !malloc_mcheck_before (&bytes, &victim)))
>      {
> -      victim = __libc_malloc (bytes);
> +      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
> +		? malloc_check (bytes) : __libc_malloc (bytes));
>      }
>    if (victim != NULL)
>      {
> @@ -333,3 +348,135 @@ __debug_calloc (size_t nmemb, size_t size)
>    return victim;
>  }
>  strong_alias (__debug_calloc, calloc)
> +
> +size_t
> +malloc_usable_size (void *mem)
> +{
> +  return (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
> +	  ? malloc_check_get_size (mem) : musable (mem));
> +}
> +
> +#define LIBC_SYMBOL(sym) libc_ ## sym
> +#define SYMHANDLE(sym) sym ## _handle
> +
> +#define LOAD_SYM(sym) ({ \
> +  static void *SYMHANDLE (sym);						      \
> +  if (SYMHANDLE (sym) == NULL)						      \
> +    SYMHANDLE (sym) = dlsym (RTLD_NEXT, #sym);				      \
> +  SYMHANDLE (sym);							      \
> +})
> +
> +int
> +malloc_info (int options, FILE *fp)
> +{
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return __malloc_info (options, fp);
> +
> +  int (*LIBC_SYMBOL (malloc_info)) (int, FILE *) = LOAD_SYM (malloc_info);
> +  if (LIBC_SYMBOL (malloc_info) == NULL)
> +    return -1;
> +
> +  return LIBC_SYMBOL (malloc_info) (options, fp);
> +}
> +
> +int
> +mallopt (int param_number, int value)
> +{
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return __libc_mallopt (param_number, value);
> +
> +  int (*LIBC_SYMBOL (mallopt)) (int, int) = LOAD_SYM (mallopt);
> +  if (LIBC_SYMBOL (mallopt) == NULL)
> +    return 0;
> +
> +  return LIBC_SYMBOL (mallopt) (param_number, value);
> +}
> +
> +void
> +malloc_stats (void)
> +{
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return __malloc_stats ();
> +
> +  void (*LIBC_SYMBOL (malloc_stats)) (void) = LOAD_SYM (malloc_stats);
> +  if (LIBC_SYMBOL (malloc_stats) == NULL)
> +    return;
> +
> +  LIBC_SYMBOL (malloc_stats) ();
> +}
> +
> +struct mallinfo2
> +mallinfo2 (void)
> +{
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return __libc_mallinfo2 ();
> +
> +  struct mallinfo2 (*LIBC_SYMBOL (mallinfo2)) (void) = LOAD_SYM (mallinfo2);
> +  if (LIBC_SYMBOL (mallinfo2) == NULL)
> +    {
> +      struct mallinfo2 ret = {0};
> +      return ret;
> +    }
> +
> +  return LIBC_SYMBOL (mallinfo2) ();
> +}
> +
> +struct mallinfo
> +mallinfo (void)
> +{
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return __libc_mallinfo ();
> +
> +  struct mallinfo (*LIBC_SYMBOL (mallinfo)) (void) = LOAD_SYM (mallinfo);
> +  if (LIBC_SYMBOL (mallinfo) == NULL)
> +    {
> +      struct mallinfo ret = {0};
> +      return ret;
> +    }
> +
> +  return LIBC_SYMBOL (mallinfo) ();
> +}
> +
> +int
> +malloc_trim (size_t s)
> +{
> +  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return __malloc_trim (s);
> +
> +  int (*LIBC_SYMBOL (malloc_trim)) (size_t) = LOAD_SYM (malloc_trim);
> +  if (LIBC_SYMBOL (malloc_trim) == NULL)
> +    return 0;
> +
> +  return LIBC_SYMBOL (malloc_trim) (s);
> +}
> +
> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25)
> +int
> +malloc_set_state (void *msptr)
> +{
> +  if (ms->magic != MALLOC_STATE_MAGIC)
> +    return -1;
> +
> +  /* Must fail if the major version is too high. */
> +  if ((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl))
> +    return -2;
> +
> +  if (debug_initialized && __is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
> +    return -1;
> +
> +  /* It's not too late, so disable MALLOC_CHECK_ and hand off to the libc
> +     malloc_set_state.  */
> +  __malloc_debug_disable (MALLOC_CHECK_HOOK);
> +  __malloc_hook = NULL;
> +  __realloc_hook = NULL;
> +  __free_hook = NULL;
> +  __memalign_hook = NULL;
> +
> +  int (*LIBC_SYMBOL (malloc_set_state)) (void *) = LOAD_SYM (malloc_set_state);
> +  if (LIBC_SYMBOL (malloc_set_state) == NULL)
> +    return -1;
> +
> +  return LIBC_SYMBOL (malloc_set_state) (msptr);
> +}
> +compat_symbol (libc, malloc_set_state, malloc_set_state, GLIBC_2_0);
> +#endif
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index ed0316e690..b8fcb2f2d3 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -288,6 +288,7 @@
>  #define MALLOC_DEBUG 0
>  #endif
>  
> +#if IS_IN (libc)
>  #ifndef NDEBUG
>  # define __assert_fail(assertion, file, line, function)			\
>  	 __malloc_assert(assertion, file, line, function)
> @@ -307,6 +308,7 @@ __malloc_assert (const char *assertion, const char *file, unsigned int line,
>    abort ();
>  }
>  #endif
> +#endif
>  
>  #if USE_TCACHE
>  /* We want 64 entries.  This is an arbitrary limit, which tunables can reduce.  */
> @@ -592,6 +594,7 @@ tag_at (void *ptr)
>  
>  /* ---------- description of public routines ------------ */
>  
> +#if IS_IN (libc)
>  /*
>    malloc(size_t n)
>    Returns a pointer to a newly allocated chunk of at least n bytes, or null
> @@ -815,6 +818,7 @@ void     __malloc_stats(void);
>    POSIX wrapper like memalign(), checking for validity of size.
>  */
>  int      __posix_memalign(void **, size_t, size_t);
> +#endif /* IS_IN (libc) */
>  
>  /* mallopt tuning options */
>  
> @@ -1106,24 +1110,17 @@ static void     _int_free(mstate, mchunkptr, int);
>  static void*  _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
>  			   INTERNAL_SIZE_T);
>  static void*  _int_memalign(mstate, size_t, size_t);
> +#if IS_IN (libc)
>  static void*  _mid_memalign(size_t, size_t, void *);
> +#endif
>  
>  static void malloc_printerr(const char *str) __attribute__ ((noreturn));
>  
> -static void* mem2mem_check(void *p, size_t sz);
> -static void top_check(void);
>  static void munmap_chunk(mchunkptr p);
>  #if HAVE_MREMAP
>  static mchunkptr mremap_chunk(mchunkptr p, size_t new_size);
>  #endif
>  
> -static void*   malloc_check(size_t sz, const void *caller);
> -static void      free_check(void* mem, const void *caller);
> -static void*   realloc_check(void* oldmem, size_t bytes,
> -			       const void *caller);
> -static void*   memalign_check(size_t alignment, size_t bytes,
> -				const void *caller);
> -
>  /* ------------------ MMAP support ------------------  */
>  
>  
> @@ -2385,7 +2382,9 @@ do_check_malloc_state (mstate av)
>  
>  
>  /* ----------------- Support for debugging hooks -------------------- */
> +#if IS_IN (libc)
>  #include "hooks.c"
> +#endif
>  
>  
>  /* ----------- Routines dealing with system allocation -------------- */
> @@ -3186,6 +3185,7 @@ tcache_thread_shutdown (void)
>  
>  #endif /* !USE_TCACHE  */
>  
> +#if IS_IN (libc)
>  void *
>  __libc_malloc (size_t bytes)
>  {
> @@ -3686,6 +3686,7 @@ __libc_calloc (size_t n, size_t elem_size)
>  
>    return mem;
>  }
> +#endif /* IS_IN (libc) */
>  
>  /*
>     ------------------------------ malloc ------------------------------
> @@ -5054,9 +5055,6 @@ musable (void *mem)
>  
>        p = mem2chunk (mem);
>  
> -      if (__builtin_expect (using_malloc_checking == 1, 0))
> -	return malloc_check_get_size (p);
> -
>        if (chunk_is_mmapped (p))
>  	{
>  	  if (DUMPED_MAIN_ARENA_CHUNK (p))
> @@ -5072,7 +5070,7 @@ musable (void *mem)
>    return 0;
>  }
>  
> -
> +#if IS_IN (libc)
>  size_t
>  __malloc_usable_size (void *m)
>  {
> @@ -5081,12 +5079,12 @@ __malloc_usable_size (void *m)
>    result = musable (m);
>    return result;
>  }
> +#endif
>  
>  /*
>     ------------------------------ mallinfo ------------------------------
>     Accumulate malloc statistics for arena AV into M.
>   */
> -
>  static void
>  int_mallinfo (mstate av, struct mallinfo2 *m)
>  {
> @@ -5585,10 +5583,15 @@ extern char **__libc_argv attribute_hidden;
>  static void
>  malloc_printerr (const char *str)
>  {
> +#if IS_IN (libc)
>    __libc_message (do_abort, "%s\n", str);
> +#else
> +  __libc_fatal (str);
> +#endif
>    __builtin_unreachable ();
>  }
>  
> +#if IS_IN (libc)
>  /* We need a wrapper function for one of the additions of POSIX.  */
>  int
>  __posix_memalign (void **memptr, size_t alignment, size_t size)
> @@ -5618,6 +5621,7 @@ __posix_memalign (void **memptr, size_t alignment, size_t size)
>    return ENOMEM;
>  }
>  weak_alias (__posix_memalign, posix_memalign)
> +#endif
>  
>  
>  int
> @@ -5821,9 +5825,9 @@ __malloc_info (int options, FILE *fp)
>  
>    return 0;
>  }
> +#if IS_IN (libc)
>  weak_alias (__malloc_info, malloc_info)
>  
> -
>  strong_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc)
>  strong_alias (__libc_free, __free) strong_alias (__libc_free, free)
>  strong_alias (__libc_malloc, __malloc) strong_alias (__libc_malloc, malloc)
> @@ -5841,6 +5845,7 @@ strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
>  weak_alias (__malloc_stats, malloc_stats)
>  weak_alias (__malloc_usable_size, malloc_usable_size)
>  weak_alias (__malloc_trim, malloc_trim)
> +#endif
>  
>  #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_26)
>  compat_symbol (libc, __libc_free, cfree, GLIBC_2_0);
> diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
> index 1099f1d657..7c66fb97aa 100644
> --- a/sysdeps/aarch64/Makefile
> +++ b/sysdeps/aarch64/Makefile
> @@ -42,5 +42,8 @@ ifeq ($(subdir),misc)
>  sysdep_headers += sys/ifunc.h
>  sysdep_routines += __mtag_tag_zero_region \
>  		   __mtag_tag_region
> +endif
>  
> +ifeq ($(subdir),malloc)
> +sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region
>  endif
> diff --git a/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist b/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist
> index 798d3ae8a3..c1ff86dfbd 100644
> --- a/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist
> +++ b/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2.6 __free_hook D 0x4
>  GLIBC_2.2.6 __malloc_hook D 0x4
> @@ -5,7 +6,12 @@ GLIBC_2.2.6 __memalign_hook D 0x4
>  GLIBC_2.2.6 __realloc_hook D 0x4
>  GLIBC_2.2.6 calloc F
>  GLIBC_2.2.6 free F
> +GLIBC_2.2.6 mallinfo F
>  GLIBC_2.2.6 malloc F
> +GLIBC_2.2.6 malloc_stats F
> +GLIBC_2.2.6 malloc_trim F
> +GLIBC_2.2.6 malloc_usable_size F
> +GLIBC_2.2.6 mallopt F
>  GLIBC_2.2.6 mcheck F
>  GLIBC_2.2.6 mcheck_check_all F
>  GLIBC_2.2.6 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2.6 posix_memalign F
>  GLIBC_2.2.6 pvalloc F
>  GLIBC_2.2.6 realloc F
>  GLIBC_2.2.6 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist
> index bf543ed1e0..65fb5036bd 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.17 __realloc_hook D 0x8
>  GLIBC_2.17 aligned_alloc F
>  GLIBC_2.17 calloc F
>  GLIBC_2.17 free F
> +GLIBC_2.17 mallinfo F
>  GLIBC_2.17 malloc F
> +GLIBC_2.17 malloc_info F
> +GLIBC_2.17 malloc_stats F
> +GLIBC_2.17 malloc_trim F
> +GLIBC_2.17 malloc_usable_size F
> +GLIBC_2.17 mallopt F
>  GLIBC_2.17 mcheck F
>  GLIBC_2.17 mcheck_check_all F
>  GLIBC_2.17 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.17 posix_memalign F
>  GLIBC_2.17 pvalloc F
>  GLIBC_2.17 realloc F
>  GLIBC_2.17 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist
> index fa8beb5e83..bdf3541c24 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x8
>  GLIBC_2.0 __realloc_hook D 0x8
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist
> index 14bad4f83a..cf9f611403 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.32 __realloc_hook D 0x4
>  GLIBC_2.32 aligned_alloc F
>  GLIBC_2.32 calloc F
>  GLIBC_2.32 free F
> +GLIBC_2.32 mallinfo F
>  GLIBC_2.32 malloc F
> +GLIBC_2.32 malloc_info F
> +GLIBC_2.32 malloc_stats F
> +GLIBC_2.32 malloc_trim F
> +GLIBC_2.32 malloc_usable_size F
> +GLIBC_2.32 mallopt F
>  GLIBC_2.32 mcheck F
>  GLIBC_2.32 mcheck_check_all F
>  GLIBC_2.32 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.32 posix_memalign F
>  GLIBC_2.32 pvalloc F
>  GLIBC_2.32 realloc F
>  GLIBC_2.32 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist
> index 97b470a989..81be491d53 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist
> @@ -1,11 +1,18 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __free_hook D 0x4
>  GLIBC_2.4 __malloc_hook D 0x4
>  GLIBC_2.4 __memalign_hook D 0x4
>  GLIBC_2.4 __realloc_hook D 0x4
>  GLIBC_2.4 calloc F
>  GLIBC_2.4 free F
> +GLIBC_2.4 mallinfo F
>  GLIBC_2.4 malloc F
> +GLIBC_2.4 malloc_stats F
> +GLIBC_2.4 malloc_trim F
> +GLIBC_2.4 malloc_usable_size F
> +GLIBC_2.4 mallopt F
>  GLIBC_2.4 mcheck F
>  GLIBC_2.4 mcheck_check_all F
>  GLIBC_2.4 mcheck_pedantic F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist
> index 97b470a989..81be491d53 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist
> @@ -1,11 +1,18 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __free_hook D 0x4
>  GLIBC_2.4 __malloc_hook D 0x4
>  GLIBC_2.4 __memalign_hook D 0x4
>  GLIBC_2.4 __realloc_hook D 0x4
>  GLIBC_2.4 calloc F
>  GLIBC_2.4 free F
> +GLIBC_2.4 mallinfo F
>  GLIBC_2.4 malloc F
> +GLIBC_2.4 malloc_stats F
> +GLIBC_2.4 malloc_trim F
> +GLIBC_2.4 malloc_usable_size F
> +GLIBC_2.4 mallopt F
>  GLIBC_2.4 mcheck F
>  GLIBC_2.4 mcheck_check_all F
>  GLIBC_2.4 mcheck_pedantic F
> diff --git a/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist
> index eac818b681..4cd866430b 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.29 __realloc_hook D 0x4
>  GLIBC_2.29 aligned_alloc F
>  GLIBC_2.29 calloc F
>  GLIBC_2.29 free F
> +GLIBC_2.29 mallinfo F
>  GLIBC_2.29 malloc F
> +GLIBC_2.29 malloc_info F
> +GLIBC_2.29 malloc_stats F
> +GLIBC_2.29 malloc_trim F
> +GLIBC_2.29 malloc_usable_size F
> +GLIBC_2.29 mallopt F
>  GLIBC_2.29 mcheck F
>  GLIBC_2.29 mcheck_check_all F
>  GLIBC_2.29 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.29 posix_memalign F
>  GLIBC_2.29 pvalloc F
>  GLIBC_2.29 realloc F
>  GLIBC_2.29 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist
> index 88cdf04cbe..22d0bf2d8a 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 __free_hook D 0x4
>  GLIBC_2.2 __malloc_hook D 0x4
> @@ -5,7 +6,12 @@ GLIBC_2.2 __memalign_hook D 0x4
>  GLIBC_2.2 __realloc_hook D 0x4
>  GLIBC_2.2 calloc F
>  GLIBC_2.2 free F
> +GLIBC_2.2 mallinfo F
>  GLIBC_2.2 malloc F
> +GLIBC_2.2 malloc_stats F
> +GLIBC_2.2 malloc_trim F
> +GLIBC_2.2 malloc_usable_size F
> +GLIBC_2.2 mallopt F
>  GLIBC_2.2 mcheck F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2 posix_memalign F
>  GLIBC_2.2 pvalloc F
>  GLIBC_2.2 realloc F
>  GLIBC_2.2 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist
> index ee940be29a..6d5574a760 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 __free_hook D 0x8
>  GLIBC_2.2 __malloc_hook D 0x8
> @@ -5,7 +6,12 @@ GLIBC_2.2 __memalign_hook D 0x8
>  GLIBC_2.2 __realloc_hook D 0x8
>  GLIBC_2.2 calloc F
>  GLIBC_2.2 free F
> +GLIBC_2.2 mallinfo F
>  GLIBC_2.2 malloc F
> +GLIBC_2.2 malloc_stats F
> +GLIBC_2.2 malloc_trim F
> +GLIBC_2.2 malloc_usable_size F
> +GLIBC_2.2 mallopt F
>  GLIBC_2.2 mcheck F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2 posix_memalign F
>  GLIBC_2.2 pvalloc F
>  GLIBC_2.2 realloc F
>  GLIBC_2.2 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist
> index 97b470a989..81be491d53 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist
> @@ -1,11 +1,18 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __free_hook D 0x4
>  GLIBC_2.4 __malloc_hook D 0x4
>  GLIBC_2.4 __memalign_hook D 0x4
>  GLIBC_2.4 __realloc_hook D 0x4
>  GLIBC_2.4 calloc F
>  GLIBC_2.4 free F
> +GLIBC_2.4 mallinfo F
>  GLIBC_2.4 malloc F
> +GLIBC_2.4 malloc_stats F
> +GLIBC_2.4 malloc_trim F
> +GLIBC_2.4 malloc_usable_size F
> +GLIBC_2.4 mallopt F
>  GLIBC_2.4 mcheck F
>  GLIBC_2.4 mcheck_check_all F
>  GLIBC_2.4 mcheck_pedantic F
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist
> index 48db59ebb1..daa80c4772 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.18 __realloc_hook D 0x4
>  GLIBC_2.18 aligned_alloc F
>  GLIBC_2.18 calloc F
>  GLIBC_2.18 free F
> +GLIBC_2.18 mallinfo F
>  GLIBC_2.18 malloc F
> +GLIBC_2.18 malloc_info F
> +GLIBC_2.18 malloc_stats F
> +GLIBC_2.18 malloc_trim F
> +GLIBC_2.18 malloc_usable_size F
> +GLIBC_2.18 mallopt F
>  GLIBC_2.18 mcheck F
>  GLIBC_2.18 mcheck_check_all F
>  GLIBC_2.18 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.18 posix_memalign F
>  GLIBC_2.18 pvalloc F
>  GLIBC_2.18 realloc F
>  GLIBC_2.18 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist
> index 48db59ebb1..daa80c4772 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.18 __realloc_hook D 0x4
>  GLIBC_2.18 aligned_alloc F
>  GLIBC_2.18 calloc F
>  GLIBC_2.18 free F
> +GLIBC_2.18 mallinfo F
>  GLIBC_2.18 malloc F
> +GLIBC_2.18 malloc_info F
> +GLIBC_2.18 malloc_stats F
> +GLIBC_2.18 malloc_trim F
> +GLIBC_2.18 malloc_usable_size F
> +GLIBC_2.18 mallopt F
>  GLIBC_2.18 mcheck F
>  GLIBC_2.18 mcheck_check_all F
>  GLIBC_2.18 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.18 posix_memalign F
>  GLIBC_2.18 pvalloc F
>  GLIBC_2.18 realloc F
>  GLIBC_2.18 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist
> index fa8beb5e83..bdf3541c24 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x8
>  GLIBC_2.0 __realloc_hook D 0x8
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist
> index 3a3f0a2861..ce6c5f7631 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.21 __realloc_hook D 0x4
>  GLIBC_2.21 aligned_alloc F
>  GLIBC_2.21 calloc F
>  GLIBC_2.21 free F
> +GLIBC_2.21 mallinfo F
>  GLIBC_2.21 malloc F
> +GLIBC_2.21 malloc_info F
> +GLIBC_2.21 malloc_stats F
> +GLIBC_2.21 malloc_trim F
> +GLIBC_2.21 malloc_usable_size F
> +GLIBC_2.21 mallopt F
>  GLIBC_2.21 mcheck F
>  GLIBC_2.21 mcheck_check_all F
>  GLIBC_2.21 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.21 posix_memalign F
>  GLIBC_2.21 pvalloc F
>  GLIBC_2.21 realloc F
>  GLIBC_2.21 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist
> index 9e0c7a48c0..7f134f9b48 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.3 __free_hook D 0x8
>  GLIBC_2.3 __malloc_hook D 0x8
> @@ -5,7 +6,12 @@ GLIBC_2.3 __memalign_hook D 0x8
>  GLIBC_2.3 __realloc_hook D 0x8
>  GLIBC_2.3 calloc F
>  GLIBC_2.3 free F
> +GLIBC_2.3 mallinfo F
>  GLIBC_2.3 malloc F
> +GLIBC_2.3 malloc_stats F
> +GLIBC_2.3 malloc_trim F
> +GLIBC_2.3 malloc_usable_size F
> +GLIBC_2.3 mallopt F
>  GLIBC_2.3 mcheck F
>  GLIBC_2.3 mcheck_check_all F
>  GLIBC_2.3 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.3 posix_memalign F
>  GLIBC_2.3 pvalloc F
>  GLIBC_2.3 realloc F
>  GLIBC_2.3 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist
> index bf543ed1e0..65fb5036bd 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.17 __realloc_hook D 0x8
>  GLIBC_2.17 aligned_alloc F
>  GLIBC_2.17 calloc F
>  GLIBC_2.17 free F
> +GLIBC_2.17 mallinfo F
>  GLIBC_2.17 malloc F
> +GLIBC_2.17 malloc_info F
> +GLIBC_2.17 malloc_stats F
> +GLIBC_2.17 malloc_trim F
> +GLIBC_2.17 malloc_usable_size F
> +GLIBC_2.17 mallopt F
>  GLIBC_2.17 mcheck F
>  GLIBC_2.17 mcheck_check_all F
>  GLIBC_2.17 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.17 posix_memalign F
>  GLIBC_2.17 pvalloc F
>  GLIBC_2.17 realloc F
>  GLIBC_2.17 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist
> index e2448d7b83..ff6713a479 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist
> @@ -5,7 +5,14 @@ GLIBC_2.33 __realloc_hook D 0x4
>  GLIBC_2.33 aligned_alloc F
>  GLIBC_2.33 calloc F
>  GLIBC_2.33 free F
> +GLIBC_2.33 mallinfo F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.33 malloc F
> +GLIBC_2.33 malloc_info F
> +GLIBC_2.33 malloc_stats F
> +GLIBC_2.33 malloc_trim F
> +GLIBC_2.33 malloc_usable_size F
> +GLIBC_2.33 mallopt F
>  GLIBC_2.33 mcheck F
>  GLIBC_2.33 mcheck_check_all F
>  GLIBC_2.33 mcheck_pedantic F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist
> index 622ee2e67a..65425a03ee 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.27 __realloc_hook D 0x8
>  GLIBC_2.27 aligned_alloc F
>  GLIBC_2.27 calloc F
>  GLIBC_2.27 free F
> +GLIBC_2.27 mallinfo F
>  GLIBC_2.27 malloc F
> +GLIBC_2.27 malloc_info F
> +GLIBC_2.27 malloc_stats F
> +GLIBC_2.27 malloc_trim F
> +GLIBC_2.27 malloc_usable_size F
> +GLIBC_2.27 mallopt F
>  GLIBC_2.27 mcheck F
>  GLIBC_2.27 mcheck_check_all F
>  GLIBC_2.27 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.27 posix_memalign F
>  GLIBC_2.27 pvalloc F
>  GLIBC_2.27 realloc F
>  GLIBC_2.27 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist
> index ee940be29a..6d5574a760 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 __free_hook D 0x8
>  GLIBC_2.2 __malloc_hook D 0x8
> @@ -5,7 +6,12 @@ GLIBC_2.2 __memalign_hook D 0x8
>  GLIBC_2.2 __realloc_hook D 0x8
>  GLIBC_2.2 calloc F
>  GLIBC_2.2 free F
> +GLIBC_2.2 mallinfo F
>  GLIBC_2.2 malloc F
> +GLIBC_2.2 malloc_stats F
> +GLIBC_2.2 malloc_trim F
> +GLIBC_2.2 malloc_usable_size F
> +GLIBC_2.2 mallopt F
>  GLIBC_2.2 mcheck F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2 posix_memalign F
>  GLIBC_2.2 pvalloc F
>  GLIBC_2.2 realloc F
>  GLIBC_2.2 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist
> index 88cdf04cbe..22d0bf2d8a 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 __free_hook D 0x4
>  GLIBC_2.2 __malloc_hook D 0x4
> @@ -5,7 +6,12 @@ GLIBC_2.2 __memalign_hook D 0x4
>  GLIBC_2.2 __realloc_hook D 0x4
>  GLIBC_2.2 calloc F
>  GLIBC_2.2 free F
> +GLIBC_2.2 mallinfo F
>  GLIBC_2.2 malloc F
> +GLIBC_2.2 malloc_stats F
> +GLIBC_2.2 malloc_trim F
> +GLIBC_2.2 malloc_usable_size F
> +GLIBC_2.2 mallopt F
>  GLIBC_2.2 mcheck F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2 posix_memalign F
>  GLIBC_2.2 pvalloc F
>  GLIBC_2.2 realloc F
>  GLIBC_2.2 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist
> index 88cdf04cbe..22d0bf2d8a 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 __free_hook D 0x4
>  GLIBC_2.2 __malloc_hook D 0x4
> @@ -5,7 +6,12 @@ GLIBC_2.2 __memalign_hook D 0x4
>  GLIBC_2.2 __realloc_hook D 0x4
>  GLIBC_2.2 calloc F
>  GLIBC_2.2 free F
> +GLIBC_2.2 mallinfo F
>  GLIBC_2.2 malloc F
> +GLIBC_2.2 malloc_stats F
> +GLIBC_2.2 malloc_trim F
> +GLIBC_2.2 malloc_usable_size F
> +GLIBC_2.2 mallopt F
>  GLIBC_2.2 mcheck F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2 posix_memalign F
>  GLIBC_2.2 pvalloc F
>  GLIBC_2.2 realloc F
>  GLIBC_2.2 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist
> index 96955644d5..6b3c5bfd0b 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist
> @@ -4,7 +4,12 @@ GLIBC_2.0 __memalign_hook D 0x4
>  GLIBC_2.0 __realloc_hook D 0x4
>  GLIBC_2.0 calloc F
>  GLIBC_2.0 free F
> +GLIBC_2.0 mallinfo F
>  GLIBC_2.0 malloc F
> +GLIBC_2.0 malloc_stats F
> +GLIBC_2.0 malloc_trim F
> +GLIBC_2.0 malloc_usable_size F
> +GLIBC_2.0 mallopt F
>  GLIBC_2.0 mcheck F
>  GLIBC_2.0 memalign F
>  GLIBC_2.0 mprobe F
> @@ -13,7 +18,9 @@ GLIBC_2.0 muntrace F
>  GLIBC_2.0 pvalloc F
>  GLIBC_2.0 realloc F
>  GLIBC_2.0 valloc F
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
>  GLIBC_2.2 posix_memalign F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist
> index ee940be29a..6d5574a760 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2 __free_hook D 0x8
>  GLIBC_2.2 __malloc_hook D 0x8
> @@ -5,7 +6,12 @@ GLIBC_2.2 __memalign_hook D 0x8
>  GLIBC_2.2 __realloc_hook D 0x8
>  GLIBC_2.2 calloc F
>  GLIBC_2.2 free F
> +GLIBC_2.2 mallinfo F
>  GLIBC_2.2 malloc F
> +GLIBC_2.2 malloc_stats F
> +GLIBC_2.2 malloc_trim F
> +GLIBC_2.2 malloc_usable_size F
> +GLIBC_2.2 mallopt F
>  GLIBC_2.2 mcheck F
>  GLIBC_2.2 mcheck_check_all F
>  GLIBC_2.2 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2 posix_memalign F
>  GLIBC_2.2 pvalloc F
>  GLIBC_2.2 realloc F
>  GLIBC_2.2 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist
> index e734b8f088..3b7b729d64 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist
> @@ -1,3 +1,4 @@
> +GLIBC_2.10 malloc_info F
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.2.5 __free_hook D 0x8
>  GLIBC_2.2.5 __malloc_hook D 0x8
> @@ -5,7 +6,12 @@ GLIBC_2.2.5 __memalign_hook D 0x8
>  GLIBC_2.2.5 __realloc_hook D 0x8
>  GLIBC_2.2.5 calloc F
>  GLIBC_2.2.5 free F
> +GLIBC_2.2.5 mallinfo F
>  GLIBC_2.2.5 malloc F
> +GLIBC_2.2.5 malloc_stats F
> +GLIBC_2.2.5 malloc_trim F
> +GLIBC_2.2.5 malloc_usable_size F
> +GLIBC_2.2.5 mallopt F
>  GLIBC_2.2.5 mcheck F
>  GLIBC_2.2.5 mcheck_check_all F
>  GLIBC_2.2.5 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.2.5 posix_memalign F
>  GLIBC_2.2.5 pvalloc F
>  GLIBC_2.2.5 realloc F
>  GLIBC_2.2.5 valloc F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist
> index 14efc6602f..91d737a7f8 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist
> @@ -5,7 +5,13 @@ GLIBC_2.16 __realloc_hook D 0x4
>  GLIBC_2.16 aligned_alloc F
>  GLIBC_2.16 calloc F
>  GLIBC_2.16 free F
> +GLIBC_2.16 mallinfo F
>  GLIBC_2.16 malloc F
> +GLIBC_2.16 malloc_info F
> +GLIBC_2.16 malloc_stats F
> +GLIBC_2.16 malloc_trim F
> +GLIBC_2.16 malloc_usable_size F
> +GLIBC_2.16 mallopt F
>  GLIBC_2.16 mcheck F
>  GLIBC_2.16 mcheck_check_all F
>  GLIBC_2.16 mcheck_pedantic F
> @@ -17,3 +23,4 @@ GLIBC_2.16 posix_memalign F
>  GLIBC_2.16 pvalloc F
>  GLIBC_2.16 realloc F
>  GLIBC_2.16 valloc F
> +GLIBC_2.33 mallinfo2 F
> 

OK.
diff mbox series

Patch

diff --git a/malloc/Makefile b/malloc/Makefile
index c0dbe04b57..c9504d0916 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -133,7 +133,7 @@  test-extras = \
 libmemusage-routines = memusage
 libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
 
-libc_malloc_debug-routines = malloc-debug
+libc_malloc_debug-routines = malloc-debug $(sysdep_malloc_debug_routines)
 libc_malloc_debug-inhibit-o = $(filter-out .os,$(object-suffixes))
 
 $(objpfx)tst-malloc-backtrace: $(shared-thread-library)
@@ -250,6 +250,7 @@  tst-malloc-usable-tunables-ENV = GLIBC_TUNABLES=glibc.malloc.check=3 \
 
 tst-mxfast-ENV = GLIBC_TUNABLES=glibc.malloc.tcache_count=0:glibc.malloc.mxfast=0
 
+CPPFLAGS-malloc-debug.c += -DUSE_TCACHE=0
 ifeq ($(experimental-malloc),yes)
 CPPFLAGS-malloc.c += -DUSE_TCACHE=1
 else
diff --git a/malloc/Versions b/malloc/Versions
index 71d933de19..2961d0796d 100644
--- a/malloc/Versions
+++ b/malloc/Versions
@@ -119,13 +119,26 @@  libc_malloc_debug {
     mprobe;
     mtrace;
     muntrace;
+
+    mallinfo;
+    malloc_set_state;
+    malloc_stats;
+    malloc_trim;
+    malloc_usable_size;
+    mallopt;
   }
   GLIBC_2.2 {
     mcheck_check_all;
     mcheck_pedantic;
     posix_memalign;
   }
+  GLIBC_2.10 {
+    malloc_info;
+  }
   GLIBC_2.16 {
     aligned_alloc;
   }
+  GLIBC_2.33 {
+    mallinfo2;
+  }
 }
diff --git a/malloc/arena.c b/malloc/arena.c
index 840426f9fb..edcaa8816d 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -79,7 +79,9 @@  static __thread mstate thread_arena attribute_tls_model_ie;
    acquired after free_list_lock has been acquired.  */
 
 __libc_lock_define_initialized (static, free_list_lock);
+#if IS_IN (libc)
 static size_t narenas = 1;
+#endif
 static mstate free_list;
 
 /* list_lock prevents concurrent writes to the next member of struct
@@ -207,14 +209,6 @@  __malloc_fork_unlock_child (void)
 }
 
 #if HAVE_TUNABLES
-static void
-TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
-{
-  int32_t value = (int32_t) valp->numval;
-  if (value != 0)
-    __malloc_check_init ();
-}
-
 # define TUNABLE_CALLBACK_FNDECL(__name, __type) \
 static inline int do_ ## __name (__type value);				      \
 static void									      \
@@ -309,7 +303,7 @@  ptmalloc_init (void)
     }
 #endif
 
-#ifdef SHARED
+#if defined SHARED && IS_IN (libc)
   /* In case this libc copy is in a non-default namespace, never use
      brk.  Likewise if dlopened from statically linked program.  The
      generic sbrk implementation also enforces this, but it is not
@@ -323,7 +317,6 @@  ptmalloc_init (void)
   malloc_init_state (&main_arena);
 
 #if HAVE_TUNABLES
-  TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check));
   TUNABLE_GET (top_pad, size_t, TUNABLE_CALLBACK (set_top_pad));
   TUNABLE_GET (perturb, int32_t, TUNABLE_CALLBACK (set_perturb_byte));
   TUNABLE_GET (mmap_threshold, size_t, TUNABLE_CALLBACK (set_mmap_threshold));
@@ -401,8 +394,6 @@  ptmalloc_init (void)
             }
         }
     }
-  if (s && s[0] != '\0' && s[0] != '0')
-    __malloc_check_init ();
 #endif
 }
 
@@ -672,6 +663,7 @@  heap_trim (heap_info *heap, size_t pad)
 
 /* Create a new arena with initial size "size".  */
 
+#if IS_IN (libc)
 /* If REPLACED_ARENA is not NULL, detach it from this thread.  Must be
    called while free_list_lock is held.  */
 static void
@@ -947,6 +939,7 @@  arena_get_retry (mstate ar_ptr, size_t bytes)
 
   return ar_ptr;
 }
+#endif
 
 void
 __malloc_arena_thread_freeres (void)
diff --git a/malloc/hooks.c b/malloc/hooks.c
index 8e9fefe6c3..af72b622c5 100644
--- a/malloc/hooks.c
+++ b/malloc/hooks.c
@@ -39,10 +39,10 @@  void *weak_variable (*__malloc_hook) (size_t, const void *) = NULL;
 void *weak_variable (*__realloc_hook) (void *, size_t, const void *) = NULL;
 void *weak_variable (*__memalign_hook) (size_t, size_t, const void *) = NULL;
 
-#include "malloc-check.c"
-
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25)
 
+static void ptmalloc_init (void);
+
 /* Support for restoring dumped heaps contained in historic Emacs
    executables.  The heap saving feature (malloc_get_state) is no
    longer implemented in this version of glibc, but we have a heap
@@ -106,14 +106,11 @@  malloc_set_state (void *msptr)
      must be called before the first call into the malloc subsytem
      (usually via __malloc_initialize_hook).  pthread_create always
      calls calloc and thus must be called only afterwards, so there
-     cannot be more than one thread when we reach this point.  */
-
-  /* Disable the malloc hooks (and malloc checking).  */
-  __malloc_hook = NULL;
-  __realloc_hook = NULL;
-  __free_hook = NULL;
-  __memalign_hook = NULL;
-  using_malloc_checking = 0;
+     cannot be more than one thread when we reach this point.  Since the
+     initialization hook is now in libc_malloc_debug.so, we may need to
+     initialize malloc.  */
+  if (!__malloc_initialized)
+    ptmalloc_init ();
 
   /* Patch the dumped heap.  We no longer try to integrate into the
      existing heap.  Instead, we mark the existing chunks as mmapped.
diff --git a/malloc/malloc-check.c b/malloc/malloc-check.c
index dcab880510..a444c7478e 100644
--- a/malloc/malloc-check.c
+++ b/malloc/malloc-check.c
@@ -17,20 +17,8 @@ 
    License along with the GNU C Library; see the file COPYING.LIB.  If
    not, see <https://www.gnu.org/licenses/>.  */
 
-
-/* Whether we are using malloc checking.  */
-static int using_malloc_checking;
-
-/* Activate a standard set of debugging hooks. */
-void
-__malloc_check_init (void)
-{
-  using_malloc_checking = 1;
-  __malloc_hook = malloc_check;
-  __free_hook = free_check;
-  __realloc_hook = realloc_check;
-  __memalign_hook = memalign_check;
-}
+#define __mremap mremap
+#include "malloc.c"
 
 /* When memory is tagged, the checking data is stored in the user part
    of the chunk.  We can't rely on the user not having modified the
@@ -63,14 +51,13 @@  magicbyte (const void *p)
    must reach it with this iteration, otherwise we have witnessed a memory
    corruption.  */
 static size_t
-malloc_check_get_size (mchunkptr p)
+malloc_check_get_size (void *mem)
 {
   size_t size;
   unsigned char c;
+  mchunkptr p = mem2chunk (mem);
   unsigned char magic = magicbyte (p);
 
-  assert (using_malloc_checking == 1);
-
   for (size = CHUNK_HDR_SZ + memsize (p) - 1;
        (c = *SAFE_CHAR_OFFSET (p, size)) != magic;
        size -= c)
@@ -203,7 +190,7 @@  top_check (void)
 }
 
 static void *
-malloc_check (size_t sz, const void *caller)
+malloc_check (size_t sz)
 {
   void *victim;
   size_t nb;
@@ -222,7 +209,7 @@  malloc_check (size_t sz, const void *caller)
 }
 
 static void
-free_check (void *mem, const void *caller)
+free_check (void *mem)
 {
   mchunkptr p;
 
@@ -256,7 +243,7 @@  free_check (void *mem, const void *caller)
 }
 
 static void *
-realloc_check (void *oldmem, size_t bytes, const void *caller)
+realloc_check (void *oldmem, size_t bytes)
 {
   INTERNAL_SIZE_T chnb;
   void *newmem = 0;
@@ -269,11 +256,11 @@  realloc_check (void *oldmem, size_t bytes, const void *caller)
       return NULL;
     }
   if (oldmem == 0)
-    return malloc_check (bytes, NULL);
+    return malloc_check (bytes);
 
   if (bytes == 0)
     {
-      free_check (oldmem, NULL);
+      free_check (oldmem);
       return NULL;
     }
 
@@ -348,12 +335,12 @@  invert:
 }
 
 static void *
-memalign_check (size_t alignment, size_t bytes, const void *caller)
+memalign_check (size_t alignment, size_t bytes)
 {
   void *mem;
 
   if (alignment <= MALLOC_ALIGNMENT)
-    return malloc_check (bytes, NULL);
+    return malloc_check (bytes);
 
   if (alignment < MINSIZE)
     alignment = MINSIZE;
@@ -363,14 +350,14 @@  memalign_check (size_t alignment, size_t bytes, const void *caller)
   if (alignment > SIZE_MAX / 2 + 1)
     {
       __set_errno (EINVAL);
-      return 0;
+      return NULL;
     }
 
   /* Check for overflow.  */
   if (bytes > SIZE_MAX - alignment - MINSIZE)
     {
       __set_errno (ENOMEM);
-      return 0;
+      return NULL;
     }
 
   /* Make sure alignment is power of 2.  */
@@ -388,3 +375,27 @@  memalign_check (size_t alignment, size_t bytes, const void *caller)
   __libc_lock_unlock (main_arena.mutex);
   return mem2mem_check (tag_new_usable (mem), bytes);
 }
+
+static void
+TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
+{
+  int32_t value = (int32_t) valp->numval;
+  if (value != 0)
+    __malloc_debug_enable (MALLOC_CHECK_HOOK);
+}
+
+static bool
+initialize_malloc_check (void)
+{
+  /* This is the copy of the malloc initializer that we pulled in along with
+     malloc-check.  This does not affect any of the libc malloc structures.  */
+  ptmalloc_init ();
+#if HAVE_TUNABLES
+  TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check));
+#else
+  const char *s = secure_getenv ("MALLOC_CHECK_");
+  if (s && s[0] != '\0' && s[0] != '0')
+    __malloc_debug_enable (MALLOC_CHECK_HOOK);
+#endif
+  return __is_malloc_debug_enabled (MALLOC_CHECK_HOOK);
+}
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
index 9942124e02..6e5402f20c 100644
--- a/malloc/malloc-debug.c
+++ b/malloc/malloc-debug.c
@@ -50,6 +50,7 @@  enum malloc_debug_hooks
   MALLOC_NONE_HOOK = 0,
   MALLOC_MCHECK_HOOK = 1 << 0, /* mcheck()  */
   MALLOC_MTRACE_HOOK = 1 << 1, /* mtrace()  */
+  MALLOC_CHECK_HOOK = 1 << 2,  /* MALLOC_CHECK_ or glibc.malloc.check.  */
 };
 static unsigned __malloc_debugging_hooks;
 
@@ -73,6 +74,7 @@  __malloc_debug_disable (enum malloc_debug_hooks flag)
 
 #include "mcheck.c"
 #include "mtrace.c"
+#include "malloc-check.c"
 
 extern void (*__malloc_initialize_hook) (void);
 compat_symbol_reference (libc, __malloc_initialize_hook,
@@ -105,13 +107,18 @@  generic_hook_ini (void)
   __malloc_hook = NULL;
   __realloc_hook = NULL;
   __memalign_hook = NULL;
-  /* The compiler does not know that these functions are allocators, so it will
-     not try to optimize it away.  */
-  __libc_free (__libc_malloc (0));
+
+  /* malloc check does not quite co-exist with libc malloc, so initialize
+     either on or the other.  */
+  if (!initialize_malloc_check ())
+    /* The compiler does not know that these functions are allocators, so it
+       will not try to optimize it away.  */
+    __libc_free (__libc_malloc (0));
 
   void (*hook) (void) = __malloc_initialize_hook;
   if (hook != NULL)
     (*hook)();
+
   debug_initialized = 1;
 }
 
@@ -149,10 +156,11 @@  __debug_malloc (size_t bytes)
 
   void *victim = NULL;
   size_t orig_bytes = bytes;
-  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
-      || !malloc_mcheck_before (&bytes, &victim))
+  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
+       || !malloc_mcheck_before (&bytes, &victim)))
     {
-      victim = __libc_malloc (bytes);
+      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
+		? malloc_check (bytes) : __libc_malloc (bytes));
     }
   if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK) && victim != NULL)
     victim = malloc_mcheck_after (victim, orig_bytes);
@@ -175,10 +183,12 @@  __debug_free (void *mem)
 
   if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
     mem = free_mcheck (mem);
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    free_check (mem);
+  else
+    __libc_free (mem);
   if (__is_malloc_debug_enabled (MALLOC_MTRACE_HOOK))
     free_mtrace (mem, RETURN_ADDRESS (0));
-
-  __libc_free (mem);
 }
 strong_alias (__debug_free, free)
 
@@ -193,10 +203,12 @@  __debug_realloc (void *oldmem, size_t bytes)
   size_t orig_bytes = bytes, oldsize = 0;
   void *victim = NULL;
 
-  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
-      || !realloc_mcheck_before (&oldmem, &bytes, &oldsize, &victim))
+  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
+       || !realloc_mcheck_before (&oldmem, &bytes, &oldsize, &victim)))
     {
-      victim = __libc_realloc (oldmem, bytes);
+      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
+		? realloc_check (oldmem, bytes)
+		: __libc_realloc (oldmem, bytes));
     }
   if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK) && victim != NULL)
     victim = realloc_mcheck_after (victim, oldmem, orig_bytes,
@@ -219,10 +231,12 @@  _debug_mid_memalign (size_t alignment, size_t bytes, const void *address)
   void *victim = NULL;
   size_t orig_bytes = bytes;
 
-  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
-      || !memalign_mcheck_before (alignment, &bytes, &victim))
+  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
+       || !memalign_mcheck_before (alignment, &bytes, &victim)))
     {
-      victim = __libc_memalign (alignment, bytes);
+      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
+		? memalign_check (alignment, bytes)
+		: __libc_memalign (alignment, bytes));
     }
   if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK) && victim != NULL)
     victim = memalign_mcheck_after (victim, alignment, orig_bytes);
@@ -316,10 +330,11 @@  __debug_calloc (size_t nmemb, size_t size)
   size_t orig_bytes = bytes;
   void *victim = NULL;
 
-  if (!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
-      || !malloc_mcheck_before (&bytes, &victim))
+  if ((!__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)
+       || !malloc_mcheck_before (&bytes, &victim)))
     {
-      victim = __libc_malloc (bytes);
+      victim = (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
+		? malloc_check (bytes) : __libc_malloc (bytes));
     }
   if (victim != NULL)
     {
@@ -333,3 +348,135 @@  __debug_calloc (size_t nmemb, size_t size)
   return victim;
 }
 strong_alias (__debug_calloc, calloc)
+
+size_t
+malloc_usable_size (void *mem)
+{
+  return (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
+	  ? malloc_check_get_size (mem) : musable (mem));
+}
+
+#define LIBC_SYMBOL(sym) libc_ ## sym
+#define SYMHANDLE(sym) sym ## _handle
+
+#define LOAD_SYM(sym) ({ \
+  static void *SYMHANDLE (sym);						      \
+  if (SYMHANDLE (sym) == NULL)						      \
+    SYMHANDLE (sym) = dlsym (RTLD_NEXT, #sym);				      \
+  SYMHANDLE (sym);							      \
+})
+
+int
+malloc_info (int options, FILE *fp)
+{
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return __malloc_info (options, fp);
+
+  int (*LIBC_SYMBOL (malloc_info)) (int, FILE *) = LOAD_SYM (malloc_info);
+  if (LIBC_SYMBOL (malloc_info) == NULL)
+    return -1;
+
+  return LIBC_SYMBOL (malloc_info) (options, fp);
+}
+
+int
+mallopt (int param_number, int value)
+{
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return __libc_mallopt (param_number, value);
+
+  int (*LIBC_SYMBOL (mallopt)) (int, int) = LOAD_SYM (mallopt);
+  if (LIBC_SYMBOL (mallopt) == NULL)
+    return 0;
+
+  return LIBC_SYMBOL (mallopt) (param_number, value);
+}
+
+void
+malloc_stats (void)
+{
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return __malloc_stats ();
+
+  void (*LIBC_SYMBOL (malloc_stats)) (void) = LOAD_SYM (malloc_stats);
+  if (LIBC_SYMBOL (malloc_stats) == NULL)
+    return;
+
+  LIBC_SYMBOL (malloc_stats) ();
+}
+
+struct mallinfo2
+mallinfo2 (void)
+{
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return __libc_mallinfo2 ();
+
+  struct mallinfo2 (*LIBC_SYMBOL (mallinfo2)) (void) = LOAD_SYM (mallinfo2);
+  if (LIBC_SYMBOL (mallinfo2) == NULL)
+    {
+      struct mallinfo2 ret = {0};
+      return ret;
+    }
+
+  return LIBC_SYMBOL (mallinfo2) ();
+}
+
+struct mallinfo
+mallinfo (void)
+{
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return __libc_mallinfo ();
+
+  struct mallinfo (*LIBC_SYMBOL (mallinfo)) (void) = LOAD_SYM (mallinfo);
+  if (LIBC_SYMBOL (mallinfo) == NULL)
+    {
+      struct mallinfo ret = {0};
+      return ret;
+    }
+
+  return LIBC_SYMBOL (mallinfo) ();
+}
+
+int
+malloc_trim (size_t s)
+{
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return __malloc_trim (s);
+
+  int (*LIBC_SYMBOL (malloc_trim)) (size_t) = LOAD_SYM (malloc_trim);
+  if (LIBC_SYMBOL (malloc_trim) == NULL)
+    return 0;
+
+  return LIBC_SYMBOL (malloc_trim) (s);
+}
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25)
+int
+malloc_set_state (void *msptr)
+{
+  if (ms->magic != MALLOC_STATE_MAGIC)
+    return -1;
+
+  /* Must fail if the major version is too high. */
+  if ((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl))
+    return -2;
+
+  if (debug_initialized && __is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return -1;
+
+  /* It's not too late, so disable MALLOC_CHECK_ and hand off to the libc
+     malloc_set_state.  */
+  __malloc_debug_disable (MALLOC_CHECK_HOOK);
+  __malloc_hook = NULL;
+  __realloc_hook = NULL;
+  __free_hook = NULL;
+  __memalign_hook = NULL;
+
+  int (*LIBC_SYMBOL (malloc_set_state)) (void *) = LOAD_SYM (malloc_set_state);
+  if (LIBC_SYMBOL (malloc_set_state) == NULL)
+    return -1;
+
+  return LIBC_SYMBOL (malloc_set_state) (msptr);
+}
+compat_symbol (libc, malloc_set_state, malloc_set_state, GLIBC_2_0);
+#endif
diff --git a/malloc/malloc.c b/malloc/malloc.c
index ed0316e690..b8fcb2f2d3 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -288,6 +288,7 @@ 
 #define MALLOC_DEBUG 0
 #endif
 
+#if IS_IN (libc)
 #ifndef NDEBUG
 # define __assert_fail(assertion, file, line, function)			\
 	 __malloc_assert(assertion, file, line, function)
@@ -307,6 +308,7 @@  __malloc_assert (const char *assertion, const char *file, unsigned int line,
   abort ();
 }
 #endif
+#endif
 
 #if USE_TCACHE
 /* We want 64 entries.  This is an arbitrary limit, which tunables can reduce.  */
@@ -592,6 +594,7 @@  tag_at (void *ptr)
 
 /* ---------- description of public routines ------------ */
 
+#if IS_IN (libc)
 /*
   malloc(size_t n)
   Returns a pointer to a newly allocated chunk of at least n bytes, or null
@@ -815,6 +818,7 @@  void     __malloc_stats(void);
   POSIX wrapper like memalign(), checking for validity of size.
 */
 int      __posix_memalign(void **, size_t, size_t);
+#endif /* IS_IN (libc) */
 
 /* mallopt tuning options */
 
@@ -1106,24 +1110,17 @@  static void     _int_free(mstate, mchunkptr, int);
 static void*  _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
 			   INTERNAL_SIZE_T);
 static void*  _int_memalign(mstate, size_t, size_t);
+#if IS_IN (libc)
 static void*  _mid_memalign(size_t, size_t, void *);
+#endif
 
 static void malloc_printerr(const char *str) __attribute__ ((noreturn));
 
-static void* mem2mem_check(void *p, size_t sz);
-static void top_check(void);
 static void munmap_chunk(mchunkptr p);
 #if HAVE_MREMAP
 static mchunkptr mremap_chunk(mchunkptr p, size_t new_size);
 #endif
 
-static void*   malloc_check(size_t sz, const void *caller);
-static void      free_check(void* mem, const void *caller);
-static void*   realloc_check(void* oldmem, size_t bytes,
-			       const void *caller);
-static void*   memalign_check(size_t alignment, size_t bytes,
-				const void *caller);
-
 /* ------------------ MMAP support ------------------  */
 
 
@@ -2385,7 +2382,9 @@  do_check_malloc_state (mstate av)
 
 
 /* ----------------- Support for debugging hooks -------------------- */
+#if IS_IN (libc)
 #include "hooks.c"
+#endif
 
 
 /* ----------- Routines dealing with system allocation -------------- */
@@ -3186,6 +3185,7 @@  tcache_thread_shutdown (void)
 
 #endif /* !USE_TCACHE  */
 
+#if IS_IN (libc)
 void *
 __libc_malloc (size_t bytes)
 {
@@ -3686,6 +3686,7 @@  __libc_calloc (size_t n, size_t elem_size)
 
   return mem;
 }
+#endif /* IS_IN (libc) */
 
 /*
    ------------------------------ malloc ------------------------------
@@ -5054,9 +5055,6 @@  musable (void *mem)
 
       p = mem2chunk (mem);
 
-      if (__builtin_expect (using_malloc_checking == 1, 0))
-	return malloc_check_get_size (p);
-
       if (chunk_is_mmapped (p))
 	{
 	  if (DUMPED_MAIN_ARENA_CHUNK (p))
@@ -5072,7 +5070,7 @@  musable (void *mem)
   return 0;
 }
 
-
+#if IS_IN (libc)
 size_t
 __malloc_usable_size (void *m)
 {
@@ -5081,12 +5079,12 @@  __malloc_usable_size (void *m)
   result = musable (m);
   return result;
 }
+#endif
 
 /*
    ------------------------------ mallinfo ------------------------------
    Accumulate malloc statistics for arena AV into M.
  */
-
 static void
 int_mallinfo (mstate av, struct mallinfo2 *m)
 {
@@ -5585,10 +5583,15 @@  extern char **__libc_argv attribute_hidden;
 static void
 malloc_printerr (const char *str)
 {
+#if IS_IN (libc)
   __libc_message (do_abort, "%s\n", str);
+#else
+  __libc_fatal (str);
+#endif
   __builtin_unreachable ();
 }
 
+#if IS_IN (libc)
 /* We need a wrapper function for one of the additions of POSIX.  */
 int
 __posix_memalign (void **memptr, size_t alignment, size_t size)
@@ -5618,6 +5621,7 @@  __posix_memalign (void **memptr, size_t alignment, size_t size)
   return ENOMEM;
 }
 weak_alias (__posix_memalign, posix_memalign)
+#endif
 
 
 int
@@ -5821,9 +5825,9 @@  __malloc_info (int options, FILE *fp)
 
   return 0;
 }
+#if IS_IN (libc)
 weak_alias (__malloc_info, malloc_info)
 
-
 strong_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc)
 strong_alias (__libc_free, __free) strong_alias (__libc_free, free)
 strong_alias (__libc_malloc, __malloc) strong_alias (__libc_malloc, malloc)
@@ -5841,6 +5845,7 @@  strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
 weak_alias (__malloc_stats, malloc_stats)
 weak_alias (__malloc_usable_size, malloc_usable_size)
 weak_alias (__malloc_trim, malloc_trim)
+#endif
 
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_26)
 compat_symbol (libc, __libc_free, cfree, GLIBC_2_0);
diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
index 1099f1d657..7c66fb97aa 100644
--- a/sysdeps/aarch64/Makefile
+++ b/sysdeps/aarch64/Makefile
@@ -42,5 +42,8 @@  ifeq ($(subdir),misc)
 sysdep_headers += sys/ifunc.h
 sysdep_routines += __mtag_tag_zero_region \
 		   __mtag_tag_region
+endif
 
+ifeq ($(subdir),malloc)
+sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region
 endif
diff --git a/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist b/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist
index 798d3ae8a3..c1ff86dfbd 100644
--- a/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist
+++ b/sysdeps/mach/hurd/i386/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2.6 __free_hook D 0x4
 GLIBC_2.2.6 __malloc_hook D 0x4
@@ -5,7 +6,12 @@  GLIBC_2.2.6 __memalign_hook D 0x4
 GLIBC_2.2.6 __realloc_hook D 0x4
 GLIBC_2.2.6 calloc F
 GLIBC_2.2.6 free F
+GLIBC_2.2.6 mallinfo F
 GLIBC_2.2.6 malloc F
+GLIBC_2.2.6 malloc_stats F
+GLIBC_2.2.6 malloc_trim F
+GLIBC_2.2.6 malloc_usable_size F
+GLIBC_2.2.6 mallopt F
 GLIBC_2.2.6 mcheck F
 GLIBC_2.2.6 mcheck_check_all F
 GLIBC_2.2.6 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2.6 posix_memalign F
 GLIBC_2.2.6 pvalloc F
 GLIBC_2.2.6 realloc F
 GLIBC_2.2.6 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist
index bf543ed1e0..65fb5036bd 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.17 __realloc_hook D 0x8
 GLIBC_2.17 aligned_alloc F
 GLIBC_2.17 calloc F
 GLIBC_2.17 free F
+GLIBC_2.17 mallinfo F
 GLIBC_2.17 malloc F
+GLIBC_2.17 malloc_info F
+GLIBC_2.17 malloc_stats F
+GLIBC_2.17 malloc_trim F
+GLIBC_2.17 malloc_usable_size F
+GLIBC_2.17 mallopt F
 GLIBC_2.17 mcheck F
 GLIBC_2.17 mcheck_check_all F
 GLIBC_2.17 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.17 posix_memalign F
 GLIBC_2.17 pvalloc F
 GLIBC_2.17 realloc F
 GLIBC_2.17 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist
index fa8beb5e83..bdf3541c24 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x8
 GLIBC_2.0 __realloc_hook D 0x8
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist
index 14bad4f83a..cf9f611403 100644
--- a/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.32 __realloc_hook D 0x4
 GLIBC_2.32 aligned_alloc F
 GLIBC_2.32 calloc F
 GLIBC_2.32 free F
+GLIBC_2.32 mallinfo F
 GLIBC_2.32 malloc F
+GLIBC_2.32 malloc_info F
+GLIBC_2.32 malloc_stats F
+GLIBC_2.32 malloc_trim F
+GLIBC_2.32 malloc_usable_size F
+GLIBC_2.32 mallopt F
 GLIBC_2.32 mcheck F
 GLIBC_2.32 mcheck_check_all F
 GLIBC_2.32 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.32 posix_memalign F
 GLIBC_2.32 pvalloc F
 GLIBC_2.32 realloc F
 GLIBC_2.32 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist
index 97b470a989..81be491d53 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc_malloc_debug.abilist
@@ -1,11 +1,18 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __free_hook D 0x4
 GLIBC_2.4 __malloc_hook D 0x4
 GLIBC_2.4 __memalign_hook D 0x4
 GLIBC_2.4 __realloc_hook D 0x4
 GLIBC_2.4 calloc F
 GLIBC_2.4 free F
+GLIBC_2.4 mallinfo F
 GLIBC_2.4 malloc F
+GLIBC_2.4 malloc_stats F
+GLIBC_2.4 malloc_trim F
+GLIBC_2.4 malloc_usable_size F
+GLIBC_2.4 mallopt F
 GLIBC_2.4 mcheck F
 GLIBC_2.4 mcheck_check_all F
 GLIBC_2.4 mcheck_pedantic F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist
index 97b470a989..81be491d53 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc_malloc_debug.abilist
@@ -1,11 +1,18 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __free_hook D 0x4
 GLIBC_2.4 __malloc_hook D 0x4
 GLIBC_2.4 __memalign_hook D 0x4
 GLIBC_2.4 __realloc_hook D 0x4
 GLIBC_2.4 calloc F
 GLIBC_2.4 free F
+GLIBC_2.4 mallinfo F
 GLIBC_2.4 malloc F
+GLIBC_2.4 malloc_stats F
+GLIBC_2.4 malloc_trim F
+GLIBC_2.4 malloc_usable_size F
+GLIBC_2.4 mallopt F
 GLIBC_2.4 mcheck F
 GLIBC_2.4 mcheck_check_all F
 GLIBC_2.4 mcheck_pedantic F
diff --git a/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist
index eac818b681..4cd866430b 100644
--- a/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.29 __realloc_hook D 0x4
 GLIBC_2.29 aligned_alloc F
 GLIBC_2.29 calloc F
 GLIBC_2.29 free F
+GLIBC_2.29 mallinfo F
 GLIBC_2.29 malloc F
+GLIBC_2.29 malloc_info F
+GLIBC_2.29 malloc_stats F
+GLIBC_2.29 malloc_trim F
+GLIBC_2.29 malloc_usable_size F
+GLIBC_2.29 mallopt F
 GLIBC_2.29 mcheck F
 GLIBC_2.29 mcheck_check_all F
 GLIBC_2.29 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.29 posix_memalign F
 GLIBC_2.29 pvalloc F
 GLIBC_2.29 realloc F
 GLIBC_2.29 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist
index 88cdf04cbe..22d0bf2d8a 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 __free_hook D 0x4
 GLIBC_2.2 __malloc_hook D 0x4
@@ -5,7 +6,12 @@  GLIBC_2.2 __memalign_hook D 0x4
 GLIBC_2.2 __realloc_hook D 0x4
 GLIBC_2.2 calloc F
 GLIBC_2.2 free F
+GLIBC_2.2 mallinfo F
 GLIBC_2.2 malloc F
+GLIBC_2.2 malloc_stats F
+GLIBC_2.2 malloc_trim F
+GLIBC_2.2 malloc_usable_size F
+GLIBC_2.2 mallopt F
 GLIBC_2.2 mcheck F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2 posix_memalign F
 GLIBC_2.2 pvalloc F
 GLIBC_2.2 realloc F
 GLIBC_2.2 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist
index ee940be29a..6d5574a760 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 __free_hook D 0x8
 GLIBC_2.2 __malloc_hook D 0x8
@@ -5,7 +6,12 @@  GLIBC_2.2 __memalign_hook D 0x8
 GLIBC_2.2 __realloc_hook D 0x8
 GLIBC_2.2 calloc F
 GLIBC_2.2 free F
+GLIBC_2.2 mallinfo F
 GLIBC_2.2 malloc F
+GLIBC_2.2 malloc_stats F
+GLIBC_2.2 malloc_trim F
+GLIBC_2.2 malloc_usable_size F
+GLIBC_2.2 mallopt F
 GLIBC_2.2 mcheck F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2 posix_memalign F
 GLIBC_2.2 pvalloc F
 GLIBC_2.2 realloc F
 GLIBC_2.2 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist
index 97b470a989..81be491d53 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc_malloc_debug.abilist
@@ -1,11 +1,18 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __free_hook D 0x4
 GLIBC_2.4 __malloc_hook D 0x4
 GLIBC_2.4 __memalign_hook D 0x4
 GLIBC_2.4 __realloc_hook D 0x4
 GLIBC_2.4 calloc F
 GLIBC_2.4 free F
+GLIBC_2.4 mallinfo F
 GLIBC_2.4 malloc F
+GLIBC_2.4 malloc_stats F
+GLIBC_2.4 malloc_trim F
+GLIBC_2.4 malloc_usable_size F
+GLIBC_2.4 mallopt F
 GLIBC_2.4 mcheck F
 GLIBC_2.4 mcheck_check_all F
 GLIBC_2.4 mcheck_pedantic F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist
index 48db59ebb1..daa80c4772 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.18 __realloc_hook D 0x4
 GLIBC_2.18 aligned_alloc F
 GLIBC_2.18 calloc F
 GLIBC_2.18 free F
+GLIBC_2.18 mallinfo F
 GLIBC_2.18 malloc F
+GLIBC_2.18 malloc_info F
+GLIBC_2.18 malloc_stats F
+GLIBC_2.18 malloc_trim F
+GLIBC_2.18 malloc_usable_size F
+GLIBC_2.18 mallopt F
 GLIBC_2.18 mcheck F
 GLIBC_2.18 mcheck_check_all F
 GLIBC_2.18 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.18 posix_memalign F
 GLIBC_2.18 pvalloc F
 GLIBC_2.18 realloc F
 GLIBC_2.18 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist
index 48db59ebb1..daa80c4772 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.18 __realloc_hook D 0x4
 GLIBC_2.18 aligned_alloc F
 GLIBC_2.18 calloc F
 GLIBC_2.18 free F
+GLIBC_2.18 mallinfo F
 GLIBC_2.18 malloc F
+GLIBC_2.18 malloc_info F
+GLIBC_2.18 malloc_stats F
+GLIBC_2.18 malloc_trim F
+GLIBC_2.18 malloc_usable_size F
+GLIBC_2.18 mallopt F
 GLIBC_2.18 mcheck F
 GLIBC_2.18 mcheck_check_all F
 GLIBC_2.18 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.18 posix_memalign F
 GLIBC_2.18 pvalloc F
 GLIBC_2.18 realloc F
 GLIBC_2.18 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist
index fa8beb5e83..bdf3541c24 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x8
 GLIBC_2.0 __realloc_hook D 0x8
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist
index 3a3f0a2861..ce6c5f7631 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.21 __realloc_hook D 0x4
 GLIBC_2.21 aligned_alloc F
 GLIBC_2.21 calloc F
 GLIBC_2.21 free F
+GLIBC_2.21 mallinfo F
 GLIBC_2.21 malloc F
+GLIBC_2.21 malloc_info F
+GLIBC_2.21 malloc_stats F
+GLIBC_2.21 malloc_trim F
+GLIBC_2.21 malloc_usable_size F
+GLIBC_2.21 mallopt F
 GLIBC_2.21 mcheck F
 GLIBC_2.21 mcheck_check_all F
 GLIBC_2.21 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.21 posix_memalign F
 GLIBC_2.21 pvalloc F
 GLIBC_2.21 realloc F
 GLIBC_2.21 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist
index 9e0c7a48c0..7f134f9b48 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.3 __free_hook D 0x8
 GLIBC_2.3 __malloc_hook D 0x8
@@ -5,7 +6,12 @@  GLIBC_2.3 __memalign_hook D 0x8
 GLIBC_2.3 __realloc_hook D 0x8
 GLIBC_2.3 calloc F
 GLIBC_2.3 free F
+GLIBC_2.3 mallinfo F
 GLIBC_2.3 malloc F
+GLIBC_2.3 malloc_stats F
+GLIBC_2.3 malloc_trim F
+GLIBC_2.3 malloc_usable_size F
+GLIBC_2.3 mallopt F
 GLIBC_2.3 mcheck F
 GLIBC_2.3 mcheck_check_all F
 GLIBC_2.3 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.3 posix_memalign F
 GLIBC_2.3 pvalloc F
 GLIBC_2.3 realloc F
 GLIBC_2.3 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist
index bf543ed1e0..65fb5036bd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.17 __realloc_hook D 0x8
 GLIBC_2.17 aligned_alloc F
 GLIBC_2.17 calloc F
 GLIBC_2.17 free F
+GLIBC_2.17 mallinfo F
 GLIBC_2.17 malloc F
+GLIBC_2.17 malloc_info F
+GLIBC_2.17 malloc_stats F
+GLIBC_2.17 malloc_trim F
+GLIBC_2.17 malloc_usable_size F
+GLIBC_2.17 mallopt F
 GLIBC_2.17 mcheck F
 GLIBC_2.17 mcheck_check_all F
 GLIBC_2.17 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.17 posix_memalign F
 GLIBC_2.17 pvalloc F
 GLIBC_2.17 realloc F
 GLIBC_2.17 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist
index e2448d7b83..ff6713a479 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc_malloc_debug.abilist
@@ -5,7 +5,14 @@  GLIBC_2.33 __realloc_hook D 0x4
 GLIBC_2.33 aligned_alloc F
 GLIBC_2.33 calloc F
 GLIBC_2.33 free F
+GLIBC_2.33 mallinfo F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.33 malloc F
+GLIBC_2.33 malloc_info F
+GLIBC_2.33 malloc_stats F
+GLIBC_2.33 malloc_trim F
+GLIBC_2.33 malloc_usable_size F
+GLIBC_2.33 mallopt F
 GLIBC_2.33 mcheck F
 GLIBC_2.33 mcheck_check_all F
 GLIBC_2.33 mcheck_pedantic F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist
index 622ee2e67a..65425a03ee 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.27 __realloc_hook D 0x8
 GLIBC_2.27 aligned_alloc F
 GLIBC_2.27 calloc F
 GLIBC_2.27 free F
+GLIBC_2.27 mallinfo F
 GLIBC_2.27 malloc F
+GLIBC_2.27 malloc_info F
+GLIBC_2.27 malloc_stats F
+GLIBC_2.27 malloc_trim F
+GLIBC_2.27 malloc_usable_size F
+GLIBC_2.27 mallopt F
 GLIBC_2.27 mcheck F
 GLIBC_2.27 mcheck_check_all F
 GLIBC_2.27 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.27 posix_memalign F
 GLIBC_2.27 pvalloc F
 GLIBC_2.27 realloc F
 GLIBC_2.27 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist
index ee940be29a..6d5574a760 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 __free_hook D 0x8
 GLIBC_2.2 __malloc_hook D 0x8
@@ -5,7 +6,12 @@  GLIBC_2.2 __memalign_hook D 0x8
 GLIBC_2.2 __realloc_hook D 0x8
 GLIBC_2.2 calloc F
 GLIBC_2.2 free F
+GLIBC_2.2 mallinfo F
 GLIBC_2.2 malloc F
+GLIBC_2.2 malloc_stats F
+GLIBC_2.2 malloc_trim F
+GLIBC_2.2 malloc_usable_size F
+GLIBC_2.2 mallopt F
 GLIBC_2.2 mcheck F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2 posix_memalign F
 GLIBC_2.2 pvalloc F
 GLIBC_2.2 realloc F
 GLIBC_2.2 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist
index 88cdf04cbe..22d0bf2d8a 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 __free_hook D 0x4
 GLIBC_2.2 __malloc_hook D 0x4
@@ -5,7 +6,12 @@  GLIBC_2.2 __memalign_hook D 0x4
 GLIBC_2.2 __realloc_hook D 0x4
 GLIBC_2.2 calloc F
 GLIBC_2.2 free F
+GLIBC_2.2 mallinfo F
 GLIBC_2.2 malloc F
+GLIBC_2.2 malloc_stats F
+GLIBC_2.2 malloc_trim F
+GLIBC_2.2 malloc_usable_size F
+GLIBC_2.2 mallopt F
 GLIBC_2.2 mcheck F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2 posix_memalign F
 GLIBC_2.2 pvalloc F
 GLIBC_2.2 realloc F
 GLIBC_2.2 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist
index 88cdf04cbe..22d0bf2d8a 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 __free_hook D 0x4
 GLIBC_2.2 __malloc_hook D 0x4
@@ -5,7 +6,12 @@  GLIBC_2.2 __memalign_hook D 0x4
 GLIBC_2.2 __realloc_hook D 0x4
 GLIBC_2.2 calloc F
 GLIBC_2.2 free F
+GLIBC_2.2 mallinfo F
 GLIBC_2.2 malloc F
+GLIBC_2.2 malloc_stats F
+GLIBC_2.2 malloc_trim F
+GLIBC_2.2 malloc_usable_size F
+GLIBC_2.2 mallopt F
 GLIBC_2.2 mcheck F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2 posix_memalign F
 GLIBC_2.2 pvalloc F
 GLIBC_2.2 realloc F
 GLIBC_2.2 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist
index 96955644d5..6b3c5bfd0b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc_malloc_debug.abilist
@@ -4,7 +4,12 @@  GLIBC_2.0 __memalign_hook D 0x4
 GLIBC_2.0 __realloc_hook D 0x4
 GLIBC_2.0 calloc F
 GLIBC_2.0 free F
+GLIBC_2.0 mallinfo F
 GLIBC_2.0 malloc F
+GLIBC_2.0 malloc_stats F
+GLIBC_2.0 malloc_trim F
+GLIBC_2.0 malloc_usable_size F
+GLIBC_2.0 mallopt F
 GLIBC_2.0 mcheck F
 GLIBC_2.0 memalign F
 GLIBC_2.0 mprobe F
@@ -13,7 +18,9 @@  GLIBC_2.0 muntrace F
 GLIBC_2.0 pvalloc F
 GLIBC_2.0 realloc F
 GLIBC_2.0 valloc F
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
 GLIBC_2.2 posix_memalign F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist
index ee940be29a..6d5574a760 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2 __free_hook D 0x8
 GLIBC_2.2 __malloc_hook D 0x8
@@ -5,7 +6,12 @@  GLIBC_2.2 __memalign_hook D 0x8
 GLIBC_2.2 __realloc_hook D 0x8
 GLIBC_2.2 calloc F
 GLIBC_2.2 free F
+GLIBC_2.2 mallinfo F
 GLIBC_2.2 malloc F
+GLIBC_2.2 malloc_stats F
+GLIBC_2.2 malloc_trim F
+GLIBC_2.2 malloc_usable_size F
+GLIBC_2.2 mallopt F
 GLIBC_2.2 mcheck F
 GLIBC_2.2 mcheck_check_all F
 GLIBC_2.2 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2 posix_memalign F
 GLIBC_2.2 pvalloc F
 GLIBC_2.2 realloc F
 GLIBC_2.2 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist
index e734b8f088..3b7b729d64 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc_malloc_debug.abilist
@@ -1,3 +1,4 @@ 
+GLIBC_2.10 malloc_info F
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.2.5 __free_hook D 0x8
 GLIBC_2.2.5 __malloc_hook D 0x8
@@ -5,7 +6,12 @@  GLIBC_2.2.5 __memalign_hook D 0x8
 GLIBC_2.2.5 __realloc_hook D 0x8
 GLIBC_2.2.5 calloc F
 GLIBC_2.2.5 free F
+GLIBC_2.2.5 mallinfo F
 GLIBC_2.2.5 malloc F
+GLIBC_2.2.5 malloc_stats F
+GLIBC_2.2.5 malloc_trim F
+GLIBC_2.2.5 malloc_usable_size F
+GLIBC_2.2.5 mallopt F
 GLIBC_2.2.5 mcheck F
 GLIBC_2.2.5 mcheck_check_all F
 GLIBC_2.2.5 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.2.5 posix_memalign F
 GLIBC_2.2.5 pvalloc F
 GLIBC_2.2.5 realloc F
 GLIBC_2.2.5 valloc F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist
index 14efc6602f..91d737a7f8 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc_malloc_debug.abilist
@@ -5,7 +5,13 @@  GLIBC_2.16 __realloc_hook D 0x4
 GLIBC_2.16 aligned_alloc F
 GLIBC_2.16 calloc F
 GLIBC_2.16 free F
+GLIBC_2.16 mallinfo F
 GLIBC_2.16 malloc F
+GLIBC_2.16 malloc_info F
+GLIBC_2.16 malloc_stats F
+GLIBC_2.16 malloc_trim F
+GLIBC_2.16 malloc_usable_size F
+GLIBC_2.16 mallopt F
 GLIBC_2.16 mcheck F
 GLIBC_2.16 mcheck_check_all F
 GLIBC_2.16 mcheck_pedantic F
@@ -17,3 +23,4 @@  GLIBC_2.16 posix_memalign F
 GLIBC_2.16 pvalloc F
 GLIBC_2.16 realloc F
 GLIBC_2.16 valloc F
+GLIBC_2.33 mallinfo2 F