>> If you're interested in the latter, I can hack something on >> top of the TLPI examples. > > I don't mind too much as long as it's simple and easy to reproduce. > I've attached a tar.bz2 file with an example based on the TLPI code in the shlibs/ subdir - I reworked mod1.c to use a constructor and destructor routine; then in dynload_nodelete.c I'm loading the library in argv[1] with RTLD_NODELETE, call dlclose() and then dlopen() it again: $ LD_LIBRARY_PATH=. ./dynload_nodelete libdemo.so.1 x1 Called init-1 libdemo.so.1 loaded Called mod1-x1 libdemo.so.1 unloaded, waiting libdemo.so.1 loaded again Called fini-1 Notice fini1() is only called when the process exits. Also, notice init1() is only called when libdemo is first loaded. I've compiled it as a separate dir under tlpi-dist (the extra version) called shlibs_nodelete, it seemed like the easiest approach. Oh, and by the way, great book! Thanks, Stefan.
Attachment:
shlibs_nodelete.tar.bz2
Description: BZip2 compressed data