From b93b98daf0dd45ac52f99fc4d906e5926cdd5239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Thu, 22 Apr 2010 08:28:10 +0000 Subject: ldso: support RTLD_NODELETE and DF_1_NODELETE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Honor the nodelete flags so we don't delete shared library if it's sticky. This is useful for libpthread if it gets pulled in by a dlopen'ed library. Signed-off-by: Timo Teräs Signed-off-by: Austin Foxley --- ldso/libdl/libdl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ldso/libdl') diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 05a68ddcc..f19a0151e 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -736,7 +736,7 @@ static int do_dlclose(void *vhandle, int need_fini) _dl_handles = rpnt->next_handle; _dl_if_debug_print("%s: usage count: %d\n", handle->dyn->libname, handle->dyn->usage_count); - if (handle->dyn->usage_count != 1) { + if (handle->dyn->usage_count != 1 || (handle->dyn->rtld_flags & RTLD_NODELETE)) { handle->dyn->usage_count--; free(handle); return 0; @@ -744,7 +744,8 @@ static int do_dlclose(void *vhandle, int need_fini) /* OK, this is a valid handle - now close out the file */ for (j = 0; j < handle->init_fini.nlist; ++j) { tpnt = handle->init_fini.init_fini[j]; - if (--tpnt->usage_count == 0) { + tpnt->usage_count--; + if (tpnt->usage_count == 0 && !(tpnt->rtld_flags & RTLD_NODELETE)) { if ((tpnt->dynamic_info[DT_FINI] || tpnt->dynamic_info[DT_FINI_ARRAY]) && need_fini -- cgit v1.2.3