http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60731
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-04-02 Known to work| |4.4.7 Target Milestone|--- |4.7.4 Summary|dynamic library not getting |[4.7/4.8/4.9 Regression] |reinitialized on multiple |dynamic library not getting |calls to dlopen() |reinitialized on multiple | |calls to dlopen() Ever confirmed|0 |1 Known to fail| |4.5.4, 4.8.2, 4.9.0 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Works up to GCC 4.4, fails since GCC 4.5. It's not clear what makes the difference here. Btw, with LD_DEBUG=all I see 10389: opening file=./static.so [0]; direct_opencount=2 10389: 10389: symbol=routine; lookup in file=./static.so [0] 10389: binding file ./static.so [0] to ./static.so [0]: normal symbol `routine' count:2 10389: opening file=./static.so [0]; direct_opencount=3 10389: 10389: symbol=routine; lookup in file=./static.so [0] 10389: binding file ./static.so [0] to ./static.so [0]: normal symbol `routine' count:3 so the dlclose call does nothing. While in the working case: 10438: 10438: file=./static.so [0]; dynamically loaded by ./test_static [0] 10438: file=./static.so [0]; generating link map 10438: dynamic: 0x00007ffff6ffede0 base: 0x00007ffff6dfd000 size: 0x00000000002020a8 10438: entry: 0x00007ffff6dfdb10 phdr: 0x00007ffff6dfd040 phnum: 7 .... 10438: calling init: ./static.so 10438: 10438: opening file=./static.so [0]; direct_opencount=1 10438: 10438: symbol=routine; lookup in file=./static.so [0] 10438: binding file ./static.so [0] to ./static.so [0]: normal symbol `routine' count:1 10438: 10438: calling fini: ./static.so [0] 10438: 10438: 10438: file=./static.so [0]; destroying link map