mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-08 07:53:54 +00:00
b=493541 hook jemalloc into glibc's malloc r=bsmedberg
This commit is contained in:
parent
6c0e1d9ace
commit
77be8894d4
@ -7069,6 +7069,10 @@ _malloc_postfork(void)
|
||||
*/
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_MEMORY_DARWIN
|
||||
static malloc_zone_t zone;
|
||||
static struct malloc_introspection_t zone_introspect;
|
||||
@ -7229,4 +7233,27 @@ jemalloc_darwin_init(void)
|
||||
sizeof(malloc_zone_t *) * (malloc_num_zones - 1));
|
||||
malloc_zones[0] = &zone;
|
||||
}
|
||||
|
||||
#elif defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
/*
|
||||
* glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible
|
||||
* to inconsistently reference libc's malloc(3)-compatible functions
|
||||
* (bug 493541).
|
||||
*
|
||||
* These definitions interpose hooks in glibc. The functions are actually
|
||||
* passed an extra argument for the caller return address, which will be
|
||||
* ignored.
|
||||
*/
|
||||
void (*__free_hook)(void *ptr) = free;
|
||||
void *(*__malloc_hook)(size_t size) = malloc;
|
||||
void *(*__realloc_hook)(void *ptr, size_t size) = realloc;
|
||||
void *(*__memalign_hook)(size_t alignment, size_t size) = memalign;
|
||||
|
||||
#elif defined(RTLD_DEEPBIND)
|
||||
/*
|
||||
* XXX On systems that support RTLD_GROUP or DF_1_GROUP, do their
|
||||
* implementations permit similar inconsistencies? Should STV_SINGLETON
|
||||
* visibility be used for interposition where available?
|
||||
*/
|
||||
# error "Interposing malloc is unsafe on this system without libc malloc hooks."
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user