From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2616 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: dladdr() Date: Tue, 15 Jan 2013 13:48:20 -0500 Message-ID: <20130115184820.GA20323@brightrain.aerifal.cx> References: <1358206649.32505.21@driftwood> <22145EB4-CF32-4BCA-8DE6-93790F3E267F@palsenberg.com> <1358254713.32505.27@driftwood> <1358261684.3766.10.camel@6-core> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1358275717 4319 80.91.229.3 (15 Jan 2013 18:48:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jan 2013 18:48:37 +0000 (UTC) To: musl@lists.openwall.com, pierre@silentlife.com Original-X-From: musl-return-2617-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 15 19:48:55 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TvBZ3-0006Qn-DQ for gllmg-musl@plane.gmane.org; Tue, 15 Jan 2013 19:48:49 +0100 Original-Received: (qmail 15736 invoked by uid 550); 15 Jan 2013 18:48:32 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15728 invoked from network); 15 Jan 2013 18:48:32 -0000 Content-Disposition: inline In-Reply-To: <1358261684.3766.10.camel@6-core> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2616 Archived-At: On Tue, Jan 15, 2013 at 03:54:44PM +0100, pierre wrote: > Latest musl-libc dladdr() fails here: > > // glibc: > // gcc hello.c -o hello -ldl > // > // ret:1 > // dli_fname:./hello:0x400000 > // dli_sname:puts:0x4004c0 > > // musl: > // musl-gcc hello.c -o hello > // > // ret:0 > // dli_fname:(null):0 > // dli_sname:(null):0 > > Dl_info dl = {0}; > int ret = dladdr(puts + 0, &dl); > > printf("ret:%d\n" > "dli_fname:%s:%p\n" > "dli_sname:%s:%p\n\n", > ret, > dl.dli_fname, dl.dli_fbase, > dl.dli_sname, dl.dli_saddr); > > What is missing to make this work? Are you using static or dynamic linking? If static, dladdr is just a stub that always fails. It could be implemented to work under some conditions, but it would be highly dependent on what options you compile the binary with, since by default static binaries do not contain the bloat that would be needed to perform introspection. Rich