From owner-freebsd-hackers Tue Apr 2 11:58:41 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from a.mx.everquick.net (a.mx.everquick.net [216.89.137.3]) by hub.freebsd.org (Postfix) with ESMTP id B858037B41E for ; Tue, 2 Apr 2002 11:58:32 -0800 (PST) Received: from localhost (eddy@localhost) by a.mx.everquick.net (8.11.6/8.10.2) with ESMTP id g32JwaI22401; Tue, 2 Apr 2002 19:58:36 GMT X-EverQuick-No-Abuse: Report any e-mail abuse to Date: Tue, 2 Apr 2002 19:58:35 +0000 (GMT) From: "E.B. Dreger" To: Alfred Perlstein Cc: hackers@freebsd.org Subject: Re: dlopen(), ld.so, and library wrappers In-Reply-To: <20020402190552.GT93885@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > Date: Tue, 2 Apr 2002 11:05:52 -0800 > From: Alfred Perlstein > From the dlopen manpage: I reread that right before initial post. > If dlsym() is called with the special handle RTLD_NEXT, then the search > for the symbol is limited to the shared objects which were loaded after > the one issuing the call to dlsym(). Thus, if the function is called Am I confused on loading order? I thought that linked libraries were loaded _before_ dlopen() shared objects. > from the main program, all the shared libraries are searched. If it is > called from a shared library, all subsequent shared libraries are > searched. RTLD_NEXT is useful for implementing wrappers around library > functions. For example, a wrapper function getpid() could access the > ``real'' getpid() with dlsym(RTLD_NEXT, "getpid"). > > How does that sound? So you're saying that: 1) Program foo contains function called getpid() 2) Program foo links with libc 3) foo.getpid uses dlsym(RTLD_NEXT, "getpid") to call libc.getpid 4) Shared object bar, loaded by foo, will receive a pointer to foo.getpid instead of libc.getpid when getpid is resolved. ??? If that'll work, great. But I didn't interpret the manpage that way. I read it as shared object bar being able to provide a wrapper for program foo, which is the _opposite_ of what I want. I'll try the above. If that doesn't do what I want, I'll see if I can restate more clearly. -- Eddy Brotsman & Dreger, Inc. - EverQuick Internet Division Phone: +1 (316) 794-8922 Wichita/(Inter)national Phone: +1 (785) 865-5885 Lawrence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Date: Mon, 21 May 2001 11:23:58 +0000 (GMT) From: A Trap To: blacklist@brics.com Subject: Please ignore this portion of my mail signature. These last few lines are a trap for address-harvesting spambots. Do NOT send mail to , or you are likely to be blocked. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message