This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: reload .so without restarting process
- From: Hatt Tom <net dot study dot sea at gmail dot com>
- To: Sam Varshavchik <mrsam at courier-mta dot com>, gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 3 Dec 2013 10:28:10 +0800
- Subject: Re: reload .so without restarting process
- Authentication-results: sourceware.org; auth=none
- References: <CAHvbk5NkESYiD=adbi35saSDkFBv7CzstRQyLieQC3c1852zHQ at mail dot gmail dot com> <cone dot 1385908076 dot 862933 dot 19303 dot 1000 at monster dot email-scan dot com> <CAHvbk5PhE86RoxLxXtENwSTgAOxZXjzqh_z2gN_GTctDvHy_Sw at mail dot gmail dot com> <cone dot 1385955381 dot 779839 dot 10275 dot 1000 at monster dot email-scan dot com> <CAHvbk5OVSk60DsJhXuR6MfW9WOPXfn9MFLo2sHE-Ar7=P+gRxw at mail dot gmail dot com> <20131202062442 dot GA29869 at opentech dot at> <CAHvbk5PQnhBQT=ubtbBqoMwnCuK5PnLDaFSmPf9f++4K5AKAOQ at mail dot gmail dot com> <cone dot 1385985344 dot 398176 dot 13181 dot 1000 at monster dot email-scan dot com> <CAHvbk5N2Na5j4LCkimBHJSS-P=2FGgdANFvchcXA+jP7SQLV6g at mail dot gmail dot com> <cone dot 1386036320 dot 381412 dot 20574 dot 1000 at monster dot email-scan dot com>
Here is one example :
First, I linked liba.so into executable target by the compiler
command "g++ -la " at linking stage .
then ,I use dlopen to load liba.so in the executable's process .
At this time ,the reference count of liba.so is 2 , am I right ?
2013/12/3 Sam Varshavchik <mrsam@courier-mta.com>:
> Hatt Tom writes:
>
>> Thanks ! The problem has been resolved .
>>
>> And hereis one question I should get to be clear of . if I link one
>> .so into one executeable file , would this increase the reference
>> count by one already ? so dlclose would not unload that .so until the
>> reference count decrease to zero .
>
>
> Correct.
>
>
>>
>> 2013/12/2 Sam Varshavchik <mrsam@courier-mta.com>:
>> > Hatt Tom writes:
>> >
>> >> If I use dlsym() to load the address manually ,will GOT be needed
>> >> any
>> >> more ?
>> >
>> >
>> > If you always use dlopen(), and the dlsym() to call methods from a .so,
>> > you
>> > don't really need to link to it directly, any more, so this is a moot
>> > point.
>> >
>> >
>> >
>> >> 2013/12/2 Nicholas Mc Guire <der.herr@hofr.at>:
>> >> > On Mon, 02 Dec 2013, Hatt Tom wrote:
>> >> >
>> >> >> And also : why cannot I dlclose a .so that I've linked my executable
>> >> >> to, in the usual fashion.
>> >> >>
>> >> >> is it because the reference count of that .so would not alwayes to
>> >> >> be
>> >> >> zero ?
>> >> >>
>> >> >> It seems puzzling to me ?
>> >> >>
>> >> > how would you ensure consistency of the GOT ?
>> >> > I think the problem is that you would end up with invalid addresses
>> >> > in
>> >> > the GOT
>> >> > as they were setup by ld based on link-time information.
>> >> >
>> >> > thx!
>> >> > hofrat
>> >>
>> >>
>> >>
>> >> --
>> >> Best Regards!
>>
>>
>>
>> --
>> Best Regards!
--
Best Regards!