From 500744cc0a820aa13e5b1ea29b3274e50477b69c Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Fri, 7 Jan 2022 16:18:51 +0100 Subject: [PATCH] Drop extraneous libc overrides Changing symbol visibility wasn't actually necessary. The true issue was that upstream jemalloc already overrides these symbols, so we didn't need these definitions in the first place. This reverts the following commits: * dea850b30a00354f08b72f4df94e70f3c093f9f9 ("Adds missing posix_memalign alias") * 32a326c650d02b31cf0f7d3e86555050601a70bd ("Override regular malloc symbols as well") * be75f8a338eeab066d28c374aee7e582a87e8839 ("Override the correct malloc_usable_size symbol") * 5ac9b456403c8e030c2191ce411ad01c346bd072 ("Make sure to override __malloc_usable_size") * 9c3fd4b0779bec99ad1b2f3296b7d943c04ab9c0 ("Use visibility("default") attribute for libc overrides") --- src/jemalloc.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/jemalloc.c b/src/jemalloc.c index 30ec49c9a1..0cf62ed449 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -2978,49 +2978,30 @@ JEMALLOC_EXPORT void *(*__memalign_hook)(size_t alignment, size_t size) = * be implemented also, so none of glibc's malloc.o functions are added to the * link. */ -# define ALIAS(je_fn) __attribute__((alias (#je_fn), visibility("default"))) +# define ALIAS(je_fn) __attribute__((alias (#je_fn), used)) /* To force macro expansion of je_ prefix before stringification. */ # define PREALIAS(je_fn) ALIAS(je_fn) # ifdef JEMALLOC_OVERRIDE___LIBC_CALLOC void *__libc_calloc(size_t n, size_t size) PREALIAS(je_calloc); -void *calloc(size_t n, size_t size) PREALIAS(je_calloc); # endif # ifdef JEMALLOC_OVERRIDE___LIBC_FREE void __libc_free(void* ptr) PREALIAS(je_free); -void free(void* ptr) PREALIAS(je_free); # endif # ifdef JEMALLOC_OVERRIDE___LIBC_MALLOC void *__libc_malloc(size_t size) PREALIAS(je_malloc); -void *malloc(size_t size) PREALIAS(je_malloc); # endif # ifdef JEMALLOC_OVERRIDE___LIBC_MEMALIGN void *__libc_memalign(size_t align, size_t s) PREALIAS(je_memalign); -void *memalign(size_t align, size_t s) PREALIAS(je_memalign); # endif # ifdef JEMALLOC_OVERRIDE___LIBC_REALLOC void *__libc_realloc(void* ptr, size_t size) PREALIAS(je_realloc); -void *realloc(void* ptr, size_t size) PREALIAS(je_realloc); # endif # ifdef JEMALLOC_OVERRIDE___LIBC_VALLOC void *__libc_valloc(size_t size) PREALIAS(je_valloc); -void *valloc(size_t size) PREALIAS(je_valloc); # endif # ifdef JEMALLOC_OVERRIDE___POSIX_MEMALIGN int __posix_memalign(void** r, size_t a, size_t s) PREALIAS(je_posix_memalign); -int posix_memalign(void** r, size_t a, size_t s) PREALIAS(je_posix_memalign); # endif - -void *aligned_alloc(size_t a, size_t s) PREALIAS(je_aligned_alloc); - -// If we replace libc malloc and an application calls the malloc_usable_size then we can get a crash -// Symbol doesn't alias exactly so just wrap it -JEMALLOC_EXPORT size_t __malloc_usable_size(void *ptr) { - return je_malloc_usable_size(ptr); -} -JEMALLOC_EXPORT size_t malloc_usable_size(void *ptr) { - return je_malloc_usable_size(ptr); -} - # undef PREALIAS # undef ALIAS # endif