From 3d5cec4ff704c2dec151f3cdbcc426d746d37fcc Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sat, 9 Jul 2011 14:06:52 +0200 Subject: libdl: add option for controlling dl_cleanup When debugging memory leaks with Valgrind, it is required that dynamically loaded shared objects are not unloaded when a process exits, otherwise symbols from those files aren't correctly resolved in allocation traces. This patch adds the LDSO_NO_CLEANUP configuration option to control this behaviour. Signed-off-by: Richard Braun Signed-off-by: Carmelo Amoroso --- ldso/libdl/Makefile.in | 6 +++++- ldso/libdl/libdl.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'ldso') diff --git a/ldso/libdl/Makefile.in b/ldso/libdl/Makefile.in index 152185e37..be236c83f 100644 --- a/ldso/libdl/Makefile.in +++ b/ldso/libdl/Makefile.in @@ -20,7 +20,11 @@ endif CFLAGS-libdl.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libdl.so := -Wl,--dsbt-index=3 -LDFLAGS-libdl.so := $(LDFLAGS) -Wl,-fini,dl_cleanup +LDFLAGS-libdl.so := $(LDFLAGS) + +ifeq ($(LDSO_NO_CLEANUP),) +LDFLAGS-libdl.so += -Wl,-fini,dl_cleanup +endif LIBS-libdl.so := $(LIBS) $(ldso) diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 4ecd1c55e..2c8dfbb79 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -260,6 +260,7 @@ remove_slotinfo(size_t idx, struct dtv_slotinfo_list *listp, size_t disp, } #endif +#ifndef __LDSO_NO_CLEANUP__ void dl_cleanup(void) __attribute__ ((destructor)); void dl_cleanup(void) { @@ -270,6 +271,7 @@ void dl_cleanup(void) do_dlclose(h, 1); } } +#endif static ptrdiff_t _dl_build_local_scope (struct elf_resolve **list, struct elf_resolve *map) -- cgit v1.2.3