reload .so without restarting process
Hatt Tom
net.study.sea@gmail.com
Thu Dec 5 05:24:00 GMT 2013
Thanks for reply!
In my project , there need one script.so lib to be dynamiclly
modified and reloaded without reboot the process .the main process
uses its export functions ,I think dlopen and dlsym can do this .
At prevoius ,I failed to achive this due to linking script.so lib
against executable at compling time with "g++ -l "command ,it result
into dlclose can not remove script.so fully ,it would be because the
reference count of script.so library . So the modification does not
work after reloading script.so .
After that failure , I tried to link script.so to middle.so ,than link
middle.so directly to executable .
It works ! script.so can be reloaded successfully , dlclose can remove
script.so fully .
During this work ,I find there are details of linking I should get to
be clear of .
Thanks!
.
2013/12/5 Jonathan Wakely <jwakely.gcc@gmail.com>:
> On 5 December 2013 02:02, Hatt Tom wrote:
>>
>> So if I link that .so against my executable by "g++ -l " command
>> ,then I can not dlclose it fully in process at all ?
>
> Right. Why is that a problem? Why do you think you need to dlclose it?
>
>> Tp dlclose it fully , I must not link it by compiler ,but manually
>> use dlopen and dlsym to resolve the external symbols .
>>
>> But if so ,how to make the compiler not to compalain "not reference
>> to symbol xxx" at compiling stage ?
>
> That means your program depends on symbols in the library directly, so
> you should link to it directly, and then you can't dlclose it. But
> that should not be a problem.
>
> What are you trying to do? Why can't you just let the linker do its
> job normally?
--
Best Regards!
More information about the Gcc-help
mailing list