diff options
author | Dave Flogeras <dflogeras2@gmail.com> | 2018-04-27 09:21:28 -0300 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2018-04-27 22:42:33 +0100 |
commit | 132decd2a043d0ccf799f42bf89f3ae0c11e95d5 (patch) | |
tree | a1cff2be3e4a776a27f050130fd01d3b5324b15d /ldso/libdl/libdl.c | |
parent | 04a676f3c8d2443499f27612f69ee88e12089e61 (diff) |
libdl: calculate the length for second parameter of munmap.
Revert 35105679b9a900d58dadd0852e679c235f8176ba and add some debug
code.
Diffstat (limited to 'ldso/libdl/libdl.c')
-rw-r--r-- | ldso/libdl/libdl.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index d36ac6421..213eba49f 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -856,6 +856,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; } @@ -962,13 +964,15 @@ static int do_dlclose(void *vhandle, int need_fini) } #endif - start = tpnt->mapaddr; - _dl_if_debug_print("unmapping before alignment: %s start: '%p' end: '%p'\n", tpnt->libname, start, end); end = (end + ADDR_ALIGN) & PAGE_ALIGN; start = start & ~ADDR_ALIGN; - _dl_if_debug_print("unmapping: %s start: '%p' end: '%p'\n", tpnt->libname, start, end); - if (end > start) - DL_LIB_UNMAP (tpnt, end - start); + if (end > start) { + _dl_if_debug_print("unmapping: %s at %p with length: '%p' until %p\n", tpnt->libname, tpnt->mapaddr, end - start, tpnt->mapaddr + (end - start)); + DL_LIB_UNMAP (tpnt, end - start); + } + else { + _dl_if_debug_print("NOT unmapping: %s at %p. start<end ('%p'<'%p')", tpnt->libname, tpnt->mapaddr, start, end); + } /* Free elements in RTLD_LOCAL scope list */ for (runp = tpnt->rtld_local; runp; runp = tmp) { tmp = runp->next; |