From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2622 Path: news.gmane.org!not-for-mail From: pierre Newsgroups: gmane.linux.lib.musl.general Subject: Re: dladdr() Date: Wed, 16 Jan 2013 12:00:18 +0100 Message-ID: <1358334018.2170.23.camel@6-core> References: <1358206649.32505.21@driftwood> <22145EB4-CF32-4BCA-8DE6-93790F3E267F@palsenberg.com> <1358254713.32505.27@driftwood> <1358261684.3766.10.camel@6-core> <20130115184820.GA20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-UOwRc7Te6OOEy7BlTngn" X-Trace: ger.gmane.org 1358334021 11215 80.91.229.3 (16 Jan 2013 11:00:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2013 11:00:21 +0000 (UTC) To: musl@lists.openwall.com, Rich Felker Original-X-From: musl-return-2623-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 16 12:00:39 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 1TvQjW-0001l0-HD for gllmg-musl@plane.gmane.org; Wed, 16 Jan 2013 12:00:38 +0100 Original-Received: (qmail 20156 invoked by uid 550); 16 Jan 2013 11:00:20 -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 20148 invoked from network); 16 Jan 2013 11:00:20 -0000 Original-Reply-To: pierre@silentlife.com In-Reply-To: <20130115184820.GA20323@brightrain.aerifal.cx> X-Mailer: Evolution 3.2.3-0ubuntu6 Xref: news.gmane.org gmane.linux.lib.musl.general:2622 Archived-At: --=-UOwRc7Te6OOEy7BlTngn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Rich, > Are you using static or dynamic linking? Dynamic. Before posting here, I checked the musl source code, and the binary: 'objdump -z -d hello' gives: callq 4003e0 Further, 'musl-gcc -static hello.c -o hello_s' weights 23KB while the shared binary above weights only 7KB. Finally, my example provided the compilation/linking cmd line, which, by default, is dynamic: // glibc: // gcc hello.c -o hello -ldl // musl: // musl-gcc hello.c -o hello I am attaching the source code linked with musl 0.9.8 so you can duplicate this issue without wasting time. Besides knowing how to enable dladdr() in dynamic mode, I am interested in knowing what other steps are needed beyond replacing the #ifdef SHARED by another custom define (#ifdef __FORCE_DL) for musl's dl implementation to do the job in static binaries (with exported symbols). Thank you for musl, a much-needed alternative. Pierre --=-UOwRc7Te6OOEy7BlTngn Content-Disposition: attachment; filename="hello.c" Content-Type: text/x-csrc; name="hello.c"; charset="UTF-8" Content-Transfer-Encoding: 7bit // ------------------------------ // 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 // ------------------------------ #define _GNU_SOURCE #include #include #include int main(void) { puts("\nhello world!\n"); 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); return 0; } --=-UOwRc7Te6OOEy7BlTngn--