diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-04-22 08:28:10 +0000 |
---|---|---|
committer | Austin Foxley <austinf@cetoncorp.com> | 2010-04-22 08:52:17 -0700 |
commit | b93b98daf0dd45ac52f99fc4d906e5926cdd5239 (patch) | |
tree | 66c617599c0d459a479adc70c33d93c0631fbd8c /ldso/libdl/libdl.c | |
parent | dfedf78cc696bb51069ca591c3be8f05018d5be1 (diff) |
ldso: support RTLD_NODELETE and DF_1_NODELETE
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 <timo.teras@iki.fi>
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'ldso/libdl/libdl.c')
-rw-r--r-- | ldso/libdl/libdl.c | 5 |
1 files changed, 3 insertions, 2 deletions
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 |