From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 3 02:22:59 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 58CD916A4CE for ; Wed, 3 Dec 2003 02:22:59 -0800 (PST) Received: from smtp.netli.com (ip2-pal-focal.netli.com [66.243.52.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 62E9543FBD for ; Wed, 3 Dec 2003 02:22:57 -0800 (PST) (envelope-from vlm@netli.com) Received: (qmail 28037 invoked by uid 84); 3 Dec 2003 10:20:24 -0000 Received: from vlm@netli.com by l3-1 with qmail-scanner-0.96 (uvscan: v4.1.40/v4121. . Clean. Processed in 0.159118 secs); 03 Dec 2003 10:20:24 -0000 Received: from unknown (HELO netli.com) (172.17.1.12) by mx01-pal-lan.netli.lan with SMTP; 3 Dec 2003 10:20:24 -0000 Message-ID: <3FCDB996.4090603@netli.com> Date: Wed, 03 Dec 2003 02:23:18 -0800 From: Lev Walkin Organization: Netli, Inc. User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031019 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Sergey Lyubka References: <20031203121658.A822@oasis.uptsoft.com> In-Reply-To: <20031203121658.A822@oasis.uptsoft.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org Subject: Re: dlopen() and -pg flag X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2003 10:22:59 -0000 -pg on your system implies static linking. dlopen() is not available in statically linked binaries on FreeBSD and many other systems. Consider building your binary dynamic by making sure there is a dynamic version of libc with profiling support (something like /usr/lib/libc_p.so). Otherwise, there seems to be no obvious way to do it. Sergey Lyubka wrote: > Below is a little snipper that tries to dlopen(argv[1]). > It works fine until it is compiled with profiling support, -pg flag. > > Compiled with -pg, dlopen() reports "Service unavailable". > > How to fix that ? > > -sergey > > > > #include > #include > #include > > int main(int argc, char *argv[]) > { > void *handle, *sym; > > if (argc > 1) { > handle = dlopen(argv[1], RTLD_NOW); > if (handle == NULL) { > fprintf(stderr, "dlopen: %s\n", dlerror()); > } else { > fprintf(stderr, "handle: %p\n", handle); > if (argc > 2) { > sym = dlsym(handle, argv[2]); > fprintf(stderr, "%s: %p\n", argv[2], sym); > } > } > } > > return (EXIT_SUCCESS); > } > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" -- Lev Walkin vlm@netli.com