c++ - Does dlopen re-load already loaded dependencies? If so, what are the implications? -


i have program, code-named foo. foo depends on common.so , linked in normal way (sorry don't know technical way that). when foo running dynamically loads bar.so using dlopen(). far good.

but, bar.so depends on common.so. dlopen() re-load common.so (from i've read loads required dependencies recursively), or detect loaded? if re-load it, cause problems in program? both foo , bar.so need see changes in common.so either of them make static variables there.

maybe design needs changed or requires use of -rdynamic (which don't quite understand yet)?

the posix spec dlopen() says:

only single copy of executable object file shall brought address space, if dlopen() invoked multiple times in reference executable object file, , if different pathnames used reference executable object file.

on linux, implemented using reference count; until dlclose called equal number of times, shared object remain resident.

[update]

i realize asking shared objects implicitly loaded dependencies, same principle applies. otherwise, many things break... in particular, global constructors in shared object run multiple times, wreak havoc.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -