From 02d5e5d94a78d32e940dfb3b58ab7f06c31b0f76 Mon Sep 17 00:00:00 2001 From: Pavel Kopyl Date: Tue, 7 Jul 2015 18:45:46 +0300 Subject: Add forced deletion support to _dl_close_worker https://sourceware.org/bugzilla/show_bug.cgi?id=17833 I've a shared library that contains both undefined and unique symbols. Then I try to call the following sequence of dlopen: 1. dlopen("./libfoo.so", RTLD_NOW) 2. dlopen("./libfoo.so", RTLD_LAZY | RTLD_GLOBAL) First dlopen call terminates with error because of undefined symbols, but STB_GNU_UNIQUE ones set DF_1_NODELETE flag and hence block library in the memory. The library goes into inconsistent state as several structures remain uninitialized. For instance, relocations for GOT table were not performed. By the time of second dlopen call this library looks like as it would be fully initialized but this is not true: any call through incorrect GOT table leads to segmentation fault. On some systems this inconsistency triggers assertions in the dynamic linker. This patch adds a parameter to _dl_close_worker to implement forced object deletion in case of dlopen() failure: 1. Clears DF_1_NODELETE bit if forced, to allow library to be removed from memory. 2. For each unique symbol that is defined in this object clears appropriate entry in _ns_unique_sym_table. [BZ #17833] * elf/Makefile (tests): Add tst-nodelete. (modules-names): Add tst-nodelete-uniquemod. (tst-nodelete-uniquemod.so-no-z-defs): New. (tst-nodelete-rtldmod.so-no-z-defs): Likewise. (tst-nodelete-zmod.so-no-z-defs): Likewise. ($(objpfx)tst-nodelete): Likewise. ($(objpfx)tst-nodelete.out): Likewise. (LDFLAGS-tst-nodelete): Likewise. (LDFLAGS-tst-nodelete-zmod.so): Likewise. * elf/dl-close.c (_dl_close_worker): Add a parameter to implement forced object deletion. (_dl_close): Pass false to _dl_close_worker. * elf/dl-open.c (_dl_open): Pass true to _dl_close_worker. * elf/tst-nodelete.cc: New file. * elf/tst-nodeletelib.cc: Likewise. * elf/tst-znodeletelib.cc: Likewise. * include/dlfcn.h (_dl_close_worker): Add a new parameter. --- NEWS | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 07e8bd8..a809ce2 100644 --- a/NEWS +++ b/NEWS @@ -14,19 +14,19 @@ Version 2.22 16526, 16538, 16559, 16560, 16704, 16783, 16850, 17053, 17090, 17195, 17269, 17293, 17322, 17403, 17523, 17542, 17569, 17581, 17588, 17596, 17620, 17621, 17628, 17631, 17692, 17711, 17715, 17776, 17779, 17792, - 17836, 17841, 17912, 17916, 17930, 17932, 17944, 17949, 17964, 17965, - 17967, 17969, 17977, 17978, 17987, 17991, 17996, 17998, 17999, 18007, - 18019, 18020, 18029, 18030, 18032, 18034, 18036, 18038, 18039, 18042, - 18043, 18046, 18047, 18049, 18068, 18080, 18093, 18100, 18104, 18110, - 18111, 18116, 18125, 18128, 18138, 18185, 18196, 18197, 18206, 18210, - 18211, 18217, 18219, 18220, 18221, 18234, 18244, 18245, 18247, 18287, - 18319, 18324, 18333, 18346, 18371, 18397, 18409, 18410, 18412, 18418, - 18422, 18434, 18435, 18444, 18468, 18469, 18470, 18479, 18483, 18495, - 18496, 18497, 18498, 18502, 18507, 18508, 18512, 18513, 18519, 18520, - 18522, 18527, 18528, 18529, 18530, 18532, 18533, 18534, 18536, 18539, - 18540, 18542, 18544, 18545, 18546, 18547, 18549, 18553, 18558, 18569, - 18583, 18585, 18586, 18592, 18593, 18594, 18602, 18612, 18613, 18619, - 18633. + 17833, 17836, 17841, 17912, 17916, 17930, 17932, 17944, 17949, 17964, + 17965, 17967, 17969, 17977, 17978, 17987, 17991, 17996, 17998, 17999, + 18007, 18019, 18020, 18029, 18030, 18032, 18034, 18036, 18038, 18039, + 18042, 18043, 18046, 18047, 18049, 18068, 18080, 18093, 18100, 18104, + 18110, 18111, 18116, 18125, 18128, 18138, 18185, 18196, 18197, 18206, + 18210, 18211, 18217, 18219, 18220, 18221, 18234, 18244, 18245, 18247, + 18287, 18319, 18324, 18333, 18346, 18371, 18397, 18409, 18410, 18412, + 18418, 18422, 18434, 18435, 18444, 18468, 18469, 18470, 18479, 18483, + 18495, 18496, 18497, 18498, 18502, 18507, 18508, 18512, 18513, 18519, + 18520, 18522, 18527, 18528, 18529, 18530, 18532, 18533, 18534, 18536, + 18539, 18540, 18542, 18544, 18545, 18546, 18547, 18549, 18553, 18558, + 18569, 18583, 18585, 18586, 18592, 18593, 18594, 18602, 18612, 18613, + 18619, 18633. * Cache information can be queried via sysconf() function on s390 e.g. with _SC_LEVEL1_ICACHE_SIZE as argument. -- cgit v1.1