I've tried to patch the libc i'm using to never call malloc hook. But this hook is actually initialized with a pointer to this function:
malloc_hook_ini (size_t sz, const void *caller)
{
__malloc_hook = NULL;
ptmalloc_init ();
return __libc_malloc (sz);
}
I think this function is responsible for critical initializations in malloc, so it needs to be called at least once. For instance since the free hook is not initialized with a critical function, i can just nop the call instruction
DJ Delorie posted a patch which removes the hooks. It requires some porting to the current tree, though.
Alternatively, you could interpose a different malloc which does not have such hooks. If you do this, glibc will use the interposed malloc, so the hooks are never called, either.