diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-07-22 18:38:12 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-07-22 18:38:12 +0530 |
commit | 1e5a5866cb9541b5231dba3d86c8a1a35d516de9 (patch) | |
tree | 85e7ca8d6a87ee9f50ea09ccf3ec1fb91770ed16 /malloc/malloc-debug.c | |
parent | 0552fd2c7d4e8a570cb4fe4dfe65e96f6d24b0cd (diff) | |
download | glibc-1e5a5866cb9541b5231dba3d86c8a1a35d516de9.zip glibc-1e5a5866cb9541b5231dba3d86c8a1a35d516de9.tar.gz glibc-1e5a5866cb9541b5231dba3d86c8a1a35d516de9.tar.bz2 |
Remove malloc hooks [BZ #23328]
Make malloc hooks symbols compat-only so that new applications cannot
link against them and remove the declarations from the API. Also
remove the unused malloc-hooks.h.
Finally, mark all symbols in libc_malloc_debug.so as compat so that
the library cannot be linked against.
Add a note about the deprecation in NEWS.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'malloc/malloc-debug.c')
-rw-r--r-- | malloc/malloc-debug.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c index b774446..34523b0 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 |