Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 16 Jan 2013 13:51:19 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com, pierre@...entlife.com
Subject: Re: dladdr()

* pierre <pierre@...entlife.com> [2013-01-16 12:00:18 +0100]:
> 
>    // 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).
> 

there was a thread about dl* in static binaries, it is
not yet supported and non-trivial to get right

i linked to the most interesting posts at the bottom:
http://port70.net/~nsz/32_dynlink.html

i ran hello in gdb and it seems
 sym->st_shndx==0
for the "puts" symbol, i dont know the semantics of
st_shndx, but the following patch makes hello.c work:

diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 935367e..ba0bd8f 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -1178,7 +1178,7 @@ int __dladdr(void *addr, Dl_info *info)
        }

        for (; nsym; nsym--, sym++) {
-               if (sym->st_shndx && sym->st_value
+               if (/*sym->st_shndx &&*/ sym->st_value
                 && (1<<(sym->st_info&0xf) & OK_TYPES)
                 && (1<<(sym->st_info>>4) & OK_BINDS)) {
                        void *symaddr = p->base + sym->st_value;

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.