diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2018-03-14 05:30:55 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2018-03-14 05:32:07 +0100 |
commit | 5bdc2b4dee516c8e4d7ba9f5d26c9bf31418b52f (patch) | |
tree | 6423db470469c33713e33a4483c0524a0f38eca3 /ldso/libdl/libdl.c | |
parent | 490e84f5e146485a26dea2f41279a4ff13aaca05 (diff) |
Revert "Revert "libdl: fix size parameter when unmap library in dlclose""
This reverts commit 952bb00f0b2eb576b0bf48c4f87018429a42e28d.
And adds this fix for 64 Bit systems.
http://lists.busybox.net/pipermail/uclibc/2014-December/048737.html
Diffstat (limited to 'ldso/libdl/libdl.c')
-rw-r--r-- | ldso/libdl/libdl.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index f34f78152..d102a48ab 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -790,7 +790,7 @@ static int do_dlclose(void *vhandle, int need_fini) int (*dl_elf_fini) (void); void (*dl_brk) (void); struct dyn_elf *handle; - unsigned int end; + ElfW(Addr) end = 0, start = (ElfW(Addr))(~0ULL); unsigned int i, j; struct r_scope_elem *ls, *ls_next = NULL; struct elf_resolve **handle_rlist; @@ -867,6 +867,8 @@ static int do_dlclose(void *vhandle, int need_fini) i < tpnt->n_phent; ppnt++, i++) { if (ppnt->p_type != PT_LOAD) continue; + if (ppnt->p_vaddr < start) + start = ppnt->p_vaddr; if (end < ppnt->p_vaddr + ppnt->p_memsz) end = ppnt->p_vaddr + ppnt->p_memsz; } @@ -973,7 +975,9 @@ static int do_dlclose(void *vhandle, int need_fini) } #endif - DL_LIB_UNMAP (tpnt, end - tpnt->mapaddr); + end = (end + ADDR_ALIGN) & PAGE_ALIGN; + start = start & ~ADDR_ALIGN; + DL_LIB_UNMAP (tpnt, end - start); /* Free elements in RTLD_LOCAL scope list */ for (runp = tpnt->rtld_local; runp; runp = tmp) { tmp = runp->next; |