mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Questions about dlopen
@ 2022-11-02  3:16 guolongqiang
  2022-11-02  3:26 ` [musl] 答复: " guolongqiang
  2022-11-02 12:56 ` [musl] " Rich Felker
  0 siblings, 2 replies; 3+ messages in thread
From: guolongqiang @ 2022-11-02  3:16 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 220 bytes --]

Dear maintainer,

How does RTLD_LAZY option in dlopen work on musl libc? As I can't find any runtime resolve interface.
But I find that we support dlopen5, which depends on caller providing a resolve hook.

Thanks

[-- Attachment #2: Type: text/html, Size: 2582 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [musl] 答复: Questions about dlopen
  2022-11-02  3:16 [musl] Questions about dlopen guolongqiang
@ 2022-11-02  3:26 ` guolongqiang
  2022-11-02 12:56 ` [musl] " Rich Felker
  1 sibling, 0 replies; 3+ messages in thread
From: guolongqiang @ 2022-11-02  3:26 UTC (permalink / raw)
  To: musl; +Cc: changdiankang

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

I’m sorry for dlopen5, ignore that.

发件人: guolongqiang [mailto:guolongqiang@huawei.com]
发送时间: 2022年11月2日 11:17
收件人: musl@lists.openwall.com
主题: [musl] Questions about dlopen

Dear maintainer,

How does RTLD_LAZY option in dlopen work on musl libc? As I can’t find any runtime resolve interface.
But I find that we support dlopen5, which depends on caller providing a resolve hook.

Thanks

[-- Attachment #2: Type: text/html, Size: 4153 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [musl] Questions about dlopen
  2022-11-02  3:16 [musl] Questions about dlopen guolongqiang
  2022-11-02  3:26 ` [musl] 答复: " guolongqiang
@ 2022-11-02 12:56 ` Rich Felker
  1 sibling, 0 replies; 3+ messages in thread
From: Rich Felker @ 2022-11-02 12:56 UTC (permalink / raw)
  To: guolongqiang; +Cc: musl

On Wed, Nov 02, 2022 at 03:16:56AM +0000, guolongqiang wrote:
> Dear maintainer,
> 
> How does RTLD_LAZY option in dlopen work on musl libc? As I can't
> find any runtime resolve interface.

We intentionally do not have any runtime resolve interface. This is
because, in implementations that do use one, it's historically been a
gigantic source of bugs. This is partly because it runs in an
extremely restricted context where it can't make any assumptions about
availability of locks or having consistent state, and partly because
it has to be able to save and restore the entire register file, even
registers that didn't exist when it was written, because the
application's calling convention might be using them to pass
arguments.

RTLD_LAZY does not carry a contract for dlopen to do lazy resolution,
it just allows it. Originally, we just completely ignored it.

Because some software (notably, X.org server modules) was written to
depend on RTLD_LAZY, commit 6476b8135760659b25c93ff9308425ca98a9e777
introduced a "deferred relocation" feature that behaves the same from
the standpoint of the application. Since the set of available symbols
to bind to only changes when new libraries are loaded with dlopen, it
works like this:

- If RTLD_LAZY was passed to dlopen, missing symbols are not treated
  as an error.

- Instead, the relocations referring to them are saved in a list to be
  reprocessed later.

- After each subsequent dlopen, all these deferred relocation lists
  are re-processed and any relocations referring to symbols that are
  now defined get applied, and removed from the list.

> But I find that we support dlopen5, which depends on caller
> providing a resolve hook.

I know you said in the follow-up to disregard dlopen5. Regarding a
resolve hook, there is no resolve function so nothing to hook. More
broadly, musl does not provide or support any kind of hooking of
internals.

Rich

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-02 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02  3:16 [musl] Questions about dlopen guolongqiang
2022-11-02  3:26 ` [musl] 答复: " guolongqiang
2022-11-02 12:56 ` [musl] " Rich Felker

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).