From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7933 invoked by alias); 2 Dec 2013 04:59:47 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 7915 invoked by uid 89); 2 Dec 2013 04:59:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-lb0-f179.google.com Received: from Unknown (HELO mail-lb0-f179.google.com) (209.85.217.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 02 Dec 2013 04:59:45 +0000 Received: by mail-lb0-f179.google.com with SMTP id l4so8051860lbv.24 for ; Sun, 01 Dec 2013 20:59:35 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.150.103 with SMTP id uh7mr50463lbb.34.1385960375278; Sun, 01 Dec 2013 20:59:35 -0800 (PST) Received: by 10.112.14.105 with HTTP; Sun, 1 Dec 2013 20:59:35 -0800 (PST) In-Reply-To: References: Date: Mon, 02 Dec 2013 04:59:00 -0000 Message-ID: Subject: Re: reload .so without restarting process From: Hatt Tom To: Sam Varshavchik , gcc-help Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00010.txt.bz2 thanks for reply! I have used dlsym() to reload function A address , function B is called from A , if I have modified function B ,do I need to use dlsym() to reload B's address ? I think it does not need ,as the dynamic linker will do this when linking function A . Am I right ? 2013/12/2 Sam Varshavchik : > Hatt Tom writes: > >> Thanks ! >> I have tried this method ,but the problem is the main process still >> use old functions , though I have dlclose that .so and then load the >> newer one . >> >> >> what is the reason ?How could I fix this ? > > > In order for you to be able to dlclose a .so, it must've been initially > opened with dlopen. > > You cannot dlclose a .so that you've linked your executable to, in the us= ual > fashion. > > If you want to be able to reload a .so, you must manually open it with > dlopen(), and then use dlsym() to look up the functions' addresses in the > .so. > > After you dlclose() the .so, and dlopen() it back again you must then use > dlsym() again to look up all the functions' addresses. Even functions that > have not been changed, in the new version of your .so, might now be loaded > at a completely different address. > > > >> >> >> 2013/12/1 Sam Varshavchik : >> > Hatt Tom writes: >> > >> >> hi: >> >> >> >> Is it possible to reload .so file withour restarting thr process ? >> >> >> >> As I=A1=A1need to update some functions in my .so , and it is not >> >> pleasure to interrupt the main process . is there way to achive this? >> > >> > >> > Only if you, yourself has manually loaded the .so with dlopen(). Then, >> > you >> > just dlclose() and dlopen() it again. >> > >> > man dlopen >> > >> > >> >> >> >> -- >> Best Regards! --=20 Best Regards!