Move malloc hooks into a compat DSO

System Internals / glibc - Siddhesh Poyarekar [sourceware.org] - 22 July 2021 13:07 UTC

Remove all malloc hook uses from core malloc functions and move it into a new library libc_malloc_debug.so. With this, the hooks now no longer have any effect on the core library.

libc_malloc_debug.so is a malloc interposer that needs to be preloaded to get hooks functionality back so that the debugging features that depend on the hooks, i.e. malloc-check, mcheck and mtrace work again. Without the preloaded DSO these debugging features will be nops. These features will be ported away from hooks in subsequent patches.

Similarly, legacy applications that need hooks functionality need to preload libc_malloc_debug.so.

The symbols exported by libc_malloc_debug.so are maintained at exactly the same version as libc.so.

Finally, static binaries will no longer be able to use malloc debugging features since they cannot preload the debugging DSO.

2d2d9f2b48 Move malloc hooks into a compat DSO
NEWS | 6 +
Rules | 9 +-
catgets/Makefile | 4 +-
elf/Makefile | 15 +-
elf/tst-leaks1-static.c | 1 -
iconvdata/Makefile | 3 +-
intl/tst-gettext.sh | 1 +
libio/Makefile | 12 +-
localedata/Makefile | 3 +-
malloc/Makefile | 47 +++--
malloc/Versions | 20 +++
malloc/arena.c | 7 -
malloc/hooks.c | 64 +++++--
malloc/malloc-debug.c | 189 +++++++++++++++++++++
malloc/malloc.c | 85 ++-------
malloc/mcheck.c | 1 +
malloc/mtrace.c | 1 +
malloc/tst-compathooks-off.c | 145 ++++++++++++++++
malloc/tst-compathooks-on.c | 2 +
malloc/tst-malloc-usable-static-tunables.c | 1 -
malloc/tst-malloc-usable-static.c | 1 -
malloc/tst-mtrace.sh | 1 +
manual/memory.texi | 16 +-
manual/tunables.texi | 4 +-
misc/Makefile | 6 +-
nptl/Makefile | 3 +-
posix/Makefile | 40 +++--
resolv/Makefile | 9 +-
shlib-versions | 3 +
stdio-common/Makefile | 15 +-
sysdeps/generic/libc_malloc_debug.abilist | 0
sysdeps/mach/hurd/Makefile | 1 +
sysdeps/mach/hurd/i386/libc_malloc_debug.abilist | 9 +
sysdeps/pthread/Makefile | 3 +-
.../sysv/linux/aarch64/libc_malloc_debug.abilist | 9 +
.../sysv/linux/alpha/libc_malloc_debug.abilist | 9 +
.../unix/sysv/linux/arc/libc_malloc_debug.abilist | 9 +
.../sysv/linux/arm/be/libc_malloc_debug.abilist | 9 +
.../sysv/linux/arm/le/libc_malloc_debug.abilist | 9 +
.../unix/sysv/linux/csky/libc_malloc_debug.abilist | 9 +
.../unix/sysv/linux/hppa/libc_malloc_debug.abilist | 9 +
sysdeps/unix/sysv/linux/hppa/shlib-versions | 2 +
.../unix/sysv/linux/i386/libc_malloc_debug.abilist | 9 +
.../unix/sysv/linux/ia64/libc_malloc_debug.abilist | 9 +
sysdeps/unix/sysv/linux/ia64/shlib-versions | 2 +
.../linux/m68k/coldfire/libc_malloc_debug.abilist | 9 +
.../linux/m68k/m680x0/libc_malloc_debug.abilist | 9 +
.../linux/microblaze/be/libc_malloc_debug.abilist | 9 +
.../linux/microblaze/le/libc_malloc_debug.abilist | 9 +
.../mips/mips32/fpu/libc_malloc_debug.abilist | 9 +
.../mips/mips32/nofpu/libc_malloc_debug.abilist | 9 +
.../mips/mips64/n32/libc_malloc_debug.abilist | 9 +
.../mips/mips64/n64/libc_malloc_debug.abilist | 9 +
sysdeps/unix/sysv/linux/mips/shlib-versions | 2 +
.../sysv/linux/nios2/libc_malloc_debug.abilist | 9 +
.../powerpc32/fpu/libc_malloc_debug.abilist | 9 +
.../powerpc32/nofpu/libc_malloc_debug.abilist | 9 +
.../powerpc/powerpc64/be/libc_malloc_debug.abilist | 9 +
.../powerpc/powerpc64/le/libc_malloc_debug.abilist | 9 +
.../linux/riscv/rv32/libc_malloc_debug.abilist | 9 +
.../linux/riscv/rv64/libc_malloc_debug.abilist | 9 +
.../linux/s390/s390-32/libc_malloc_debug.abilist | 9 +
.../linux/s390/s390-64/libc_malloc_debug.abilist | 9 +
.../sysv/linux/sh/be/libc_malloc_debug.abilist | 9 +
.../sysv/linux/sh/le/libc_malloc_debug.abilist | 9 +
sysdeps/unix/sysv/linux/sh/shlib-versions | 1 +
.../linux/sparc/sparc32/libc_malloc_debug.abilist | 9 +
.../linux/sparc/sparc64/libc_malloc_debug.abilist | 9 +
.../unix/sysv/linux/sparc/sparc64/shlib-versions | 1 +
.../sysv/linux/x86_64/64/libc_malloc_debug.abilist | 9 +
.../linux/x86_64/x32/libc_malloc_debug.abilist | 9 +
71 files changed, 865 insertions(+), 158 deletions(-)

Upstream: sourceware.org


  • Share