First look at the situation (careful headache)
Client. C compiled to obtain the client; dlopen (". /LIBA. so ", rtld_lazy | rtld_global) Open LIBA. so, and call LIBA. the START function in so; in LIBA. the start_fcn function in so tries to call the startup_fcn function in the client through the handle obtained by dlopen (0, rtld_global | rtld_lazy. Use GCC client. c-o client-LDL obtains the client and GCC-FPIC-shared LIBA. c-o LIBA. so to get the LIBA. so found LIBA. so the startup_fcn function defined in the client cannot be found. After being reminded by pacman2k, we found the LD parameter-E/-- export-dynamic. With gcc-wl,-e client. C-O client can be called successfully after the client program is re-compiled.
-E parameters:
-E
-- Export-dynamic
When creating a dynamically linked executable, add all symbols to the dynamic symbol table.
Dynamic symbol table is the set of symbols which are visible from dynamic objects at run time.
If you do not use this option, the dynamic symbol table will normally contain only those symbols
Which are referenced by some dynamic object mentioned in the link.
If you use "dlopen" to load a dynamic object which needs to refer back to the symbols defined by
Program, rather than some other dynamic object, then you will probably need to use this option when
Linking the program itself.
The last section is about the "Callback situation 』
About rtld_global
After testing, all dlopen cancel the rtld_global parameter and still run normally. The role of the rtld_global parameter is to be investigated.