diff options
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/hooks.c | 6 | ||||
-rw-r--r-- | malloc/malloc-debug.c | 36 | ||||
-rw-r--r-- | malloc/malloc-hooks.h | 24 | ||||
-rw-r--r-- | malloc/malloc.h | 16 |
4 files changed, 41 insertions, 41 deletions
diff --git a/malloc/hooks.c b/malloc/hooks.c index 8e1afe55e5..2761e4739b 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -32,12 +32,16 @@ void weak_variable (*__after_morecore_hook) (void) = NULL; compat_symbol (libc, __after_morecore_hook, __after_morecore_hook, GLIBC_2_0); void *(*__morecore)(ptrdiff_t); compat_symbol (libc, __morecore, __morecore, GLIBC_2_0); -#endif void weak_variable (*__free_hook) (void *, const void *) = NULL; 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; +compat_symbol (libc, __free_hook, __free_hook, GLIBC_2_0); +compat_symbol (libc, __malloc_hook, __malloc_hook, GLIBC_2_0); +compat_symbol (libc, __realloc_hook, __realloc_hook, GLIBC_2_0); +compat_symbol (libc, __memalign_hook, __memalign_hook, GLIBC_2_0); +#endif /* * Local variables: diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c index b7744460e9..34523b0cc3 100644 --- a/malloc/malloc-debug.c +++ b/malloc/malloc-debug.c @@ -23,6 +23,7 @@ #include <unistd.h> #include <sys/param.h> +#if SHLIB_COMPAT (libc_malloc_debug, GLIBC_2_0, GLIBC_2_34) /* Support only the glibc allocators. */ extern void *__libc_malloc (size_t); extern void __libc_free (void *); @@ -76,9 +77,11 @@ __malloc_debug_disable (enum malloc_debug_hooks flag) #include "mtrace.c" #include "malloc-check.c" +#if SHLIB_COMPAT (libc_malloc_debug, GLIBC_2_0, GLIBC_2_24) extern void (*__malloc_initialize_hook) (void); compat_symbol_reference (libc, __malloc_initialize_hook, __malloc_initialize_hook, GLIBC_2_0); +#endif static void *malloc_hook_ini (size_t, const void *) __THROW; static void *realloc_hook_ini (void *, size_t, const void *) __THROW; @@ -115,9 +118,11 @@ generic_hook_ini (void) will not try to optimize it away. */ __libc_free (__libc_malloc (0)); +#if SHLIB_COMPAT (libc_malloc_debug, GLIBC_2_0, GLIBC_2_24) void (*hook) (void) = __malloc_initialize_hook; if (hook != NULL) (*hook)(); +#endif debug_initialized = 1; } @@ -631,3 +636,34 @@ malloc_set_state (void *msptr) compat_symbol (libc_malloc_debug, malloc_set_state, malloc_set_state, GLIBC_2_0); #endif + +/* Do not allow linking against the library. */ +compat_symbol (libc_malloc_debug, aligned_alloc, aligned_alloc, GLIBC_2_16); +compat_symbol (libc_malloc_debug, calloc, calloc, GLIBC_2_0); +compat_symbol (libc_malloc_debug, free, free, GLIBC_2_0); +compat_symbol (libc_malloc_debug, mallinfo2, mallinfo2, GLIBC_2_33); +compat_symbol (libc_malloc_debug, mallinfo, mallinfo, GLIBC_2_0); +compat_symbol (libc_malloc_debug, malloc_info, malloc_info, GLIBC_2_10); +compat_symbol (libc_malloc_debug, malloc, malloc, GLIBC_2_0); +compat_symbol (libc_malloc_debug, malloc_stats, malloc_stats, GLIBC_2_0); +compat_symbol (libc_malloc_debug, malloc_trim, malloc_trim, GLIBC_2_0); +compat_symbol (libc_malloc_debug, malloc_usable_size, malloc_usable_size, + GLIBC_2_0); +compat_symbol (libc_malloc_debug, mallopt, mallopt, GLIBC_2_0); +compat_symbol (libc_malloc_debug, mcheck_check_all, mcheck_check_all, + GLIBC_2_2); +compat_symbol (libc_malloc_debug, mcheck, mcheck, GLIBC_2_0); +compat_symbol (libc_malloc_debug, mcheck_pedantic, mcheck_pedantic, GLIBC_2_2); +compat_symbol (libc_malloc_debug, memalign, memalign, GLIBC_2_0); +compat_symbol (libc_malloc_debug, mprobe, mprobe, GLIBC_2_0); +compat_symbol (libc_malloc_debug, mtrace, mtrace, GLIBC_2_0); +compat_symbol (libc_malloc_debug, muntrace, muntrace, GLIBC_2_0); +compat_symbol (libc_malloc_debug, posix_memalign, posix_memalign, GLIBC_2_2); +compat_symbol (libc_malloc_debug, pvalloc, pvalloc, GLIBC_2_0); +compat_symbol (libc_malloc_debug, realloc, realloc, GLIBC_2_0); +compat_symbol (libc_malloc_debug, valloc, valloc, GLIBC_2_0); +compat_symbol (libc_malloc_debug, __free_hook, __free_hook, GLIBC_2_0); +compat_symbol (libc_malloc_debug, __malloc_hook, __malloc_hook, GLIBC_2_0); +compat_symbol (libc_malloc_debug, __realloc_hook, __realloc_hook, GLIBC_2_0); +compat_symbol (libc_malloc_debug, __memalign_hook, __memalign_hook, GLIBC_2_0); +#endif diff --git a/malloc/malloc-hooks.h b/malloc/malloc-hooks.h deleted file mode 100644 index 0133331b83..0000000000 --- a/malloc/malloc-hooks.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Internal declarations of malloc hooks no longer in the public API. - Copyright (C) 2016-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, see <https://www.gnu.org/licenses/>. */ - -#ifndef _MALLOC_HOOKS_H -#define _MALLOC_HOOKS_H - -void (*__malloc_initialize_hook) (void); - -#endif /* _MALLOC_HOOKS_H */ diff --git a/malloc/malloc.h b/malloc/malloc.h index 17ab9ee345..2df0b38050 100644 --- a/malloc/malloc.h +++ b/malloc/malloc.h @@ -156,21 +156,5 @@ extern void malloc_stats (void) __THROW; /* Output information about state of allocator to stream FP. */ extern int malloc_info (int __options, FILE *__fp) __THROW; -/* Hooks for debugging and user-defined versions. */ -extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr, - const void *) -__MALLOC_DEPRECATED; -extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook)(size_t __size, - const void *) -__MALLOC_DEPRECATED; -extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook)(void *__ptr, - size_t __size, - const void *) -__MALLOC_DEPRECATED; -extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment, - size_t __size, - const void *) -__MALLOC_DEPRECATED; - __END_DECLS #endif /* malloc.h */ |