mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com, Luiz Angelo Daros de Luca <luizluca@gmail.com>
Subject: Re: dlsym returning unresolved symbol address instead of dependency library symbol address
Date: Sat, 10 Aug 2019 14:35:38 +0200	[thread overview]
Message-ID: <20190810123536.GI22009@port70.net> (raw)
In-Reply-To: <20190810101111.GH22009@port70.net>

* Szabolcs Nagy <nsz@port70.net> [2019-08-10 12:11:11 +0200]:
> * Luiz Angelo Daros de Luca <luizluca@gmail.com> [2019-08-10 05:16:19 -0300]:
> > I'm ruby maintainer in OpenWrt 18.06 (musl 1.1.19). I got a bug report (
> > https://github.com/openwrt/packages/issues/9297) related to musl in mipsel
...
> yes, if the search involves the main executable then
> st_shndx==0 && st_value!=0 symbols must be included
> because it's a plt in the exe and that's how function
> addresses work.. on most targets except mips.
> 
> undef syms have st_value==0 in shared libs, maybe
> not in mips? can you post the readelf -aW output of
> the module that has st_shndx==0 && st_value!=0 entry
> in its dynamic symbol table

ah i see in the bugreport

Buildx86$ staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/bin/mips-openwrt-linux-musl-readelf -s staging_dir/target-mips_24kc_musl/root-ar71xx/usr/lib/ruby/2.5/mips-linux-gnu/stringio.so | grep mall
91: 00004930 0 FUNC GLOBAL DEFAULT UND ruby_xmalloc
187: 00004930 0 FUNC GLOBAL DEFAULT UND ruby_xmalloc
    ^^^^^^^^^
st_value!=0

that is mips specific strangeness.

it's still not clear to me why is there different
code path between first vs second dlopen, but the
right fix to the reported issue is to reuse the
find_sym logic (since the executable case need not
be handled a somewhat simpler logic may work too,
but i'd prefer a single logic for dlsym and reloc
processing exactly because of broken elf targets
like mips that make maintenance of such code harder)

> 
> i think this was going to be fixed by
> https://www.openwall.com/lists/musl/2017/02/16/1/2
> but that was never applied.
> 
> > 
> > I created a simple patch that skips a symbol if it is undefined.
> > https://raw.githubusercontent.com/luizluca/openwrt/b9674d528513c7c93205fa000fed7c0d3c6bb2e7/toolchain/musl/patches/020-dlsym_donot_return_address_from_undef_sym.patch
> > 
> 
> i think the find_sym logic should be copied
> because mips behaves differently from other targets:
> 
> http://git.musl-libc.org/cgit/musl/commit/?id=2d8cc92a7cb4a3256ed07d86843388ffd8a882b1
> 
> 
> > It fixes the issue and it did not break my system(it still boots). However,
> > I didn't test it with multiples archs nor I runned an extensive test.
> > 
> > I'm not subscribed. Please, CC me.
> > 
> > Regards,
> > ---
> >      Luiz Angelo Daros de Luca
> >             luizluca@gmail.com


  reply	other threads:[~2019-08-10 12:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10  8:16 Luiz Angelo Daros de Luca
2019-08-10 10:11 ` Szabolcs Nagy
2019-08-10 12:35   ` Szabolcs Nagy [this message]
2019-08-10 16:42   ` Rich Felker
2019-08-10 17:27     ` Szabolcs Nagy
2019-08-13  7:10       ` Luiz Angelo Daros de Luca
2019-08-13  8:50         ` Szabolcs Nagy

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=20190810123536.GI22009@port70.net \
    --to=nsz@port70.net \
    --cc=luizluca@gmail.com \
    --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).