From: pierre <pierre@silentlife.com>
To: musl@lists.openwall.com, Rich Felker <dalias@aerifal.cx>
Subject: Re: dladdr()
Date: Wed, 16 Jan 2013 12:00:18 +0100 [thread overview]
Message-ID: <1358334018.2170.23.camel@6-core> (raw)
In-Reply-To: <20130115184820.GA20323@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 927 bytes --]
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 <dladdr@plt>
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
[-- Attachment #2: hello.c --]
[-- Type: text/x-csrc, Size: 685 bytes --]
// ------------------------------
// 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 <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
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;
}
next prev parent reply other threads:[~2013-01-16 11:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-14 17:17 malloc(0) behaviour Igmar Palsenberg
2013-01-14 18:05 ` Rich Felker
2013-01-14 22:22 ` Strake
2013-01-14 23:05 ` Rich Felker
2013-01-15 8:32 ` Igmar Palsenberg
2013-01-15 12:53 ` Rob Landley
2013-01-15 22:18 ` Igmar Palsenberg
2013-01-15 8:31 ` Igmar Palsenberg
2013-01-15 11:06 ` Szabolcs Nagy
2013-01-15 12:33 ` Igmar Palsenberg
2013-01-15 13:48 ` Rich Felker
2013-01-15 22:28 ` Igmar Palsenberg
2013-01-15 23:22 ` Rob
2013-01-16 7:46 ` Igmar Palsenberg
2013-01-15 13:46 ` Rich Felker
2013-01-15 12:52 ` Rob Landley
2013-01-14 23:37 ` Rob Landley
2013-01-15 0:24 ` Rich Felker
2013-01-15 12:17 ` Rob Landley
2013-01-15 9:01 ` Igmar Palsenberg
2013-01-15 12:58 ` Rob Landley
2013-01-15 14:54 ` dladdr() pierre
2013-01-15 18:48 ` dladdr() Rich Felker
2013-01-16 11:00 ` pierre [this message]
2013-01-16 12:51 ` dladdr() Szabolcs Nagy
2013-01-16 14:24 ` dladdr() musl
2013-01-16 15:20 ` dladdr() pierre
2013-01-16 16:49 ` dladdr() Rich Felker
2013-01-16 17:42 ` dladdr() musl
2013-01-21 2:03 ` dladdr() Rich Felker
2013-01-21 6:58 ` dladdr() pierre
2013-01-21 18:35 ` dladdr() Rich Felker
2013-01-22 6:27 ` dladdr() pierre
2013-01-22 13:07 ` dladdr() Szabolcs Nagy
2013-01-22 13:40 ` dladdr() pierre
2013-01-22 13:51 ` dladdr() Rich Felker
2013-01-22 14:59 ` dladdr() pierre
2013-01-22 16:11 ` dladdr() Szabolcs Nagy
2013-01-22 23:43 ` dladdr() Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358334018.2170.23.camel@6-core \
--to=pierre@silentlife.com \
--cc=dalias@aerifal.cx \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).