public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Usage of rtld_active() in dlfcn functions
@ 2020-09-03  7:17 Fengkai Sun
  2020-09-03  8:08 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Fengkai Sun @ 2020-09-03  7:17 UTC (permalink / raw)
  To: libc-help

Hi list,

I've noticed that every function in dlfcn.h calls rtld_active() at the very
beginning of their implementation, and use _dlfcn_hook to actually call
those functions.

In sysdeps/generic/ldsodefs.h it says about this function "Return true if
the ld.so copy in this namespace is actually active and working. If false,
the dl_open/dlfcn hooks have to be used to call into the outer dynamic
linker (which happens after static dlopen)".

My question is, why can dlfcn functions be called before ld.so is
initialized? Obviously a program written by the user cannot do that, and I
can't find the reference to dlfcn functions in rtld.c.
So what is rtld_active() used for?

Additionally, what does "static dlopen" mean?


Many thanks,
Fengkai

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

* Re: Usage of rtld_active() in dlfcn functions
  2020-09-03  7:17 Usage of rtld_active() in dlfcn functions Fengkai Sun
@ 2020-09-03  8:08 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2020-09-03  8:08 UTC (permalink / raw)
  To: Fengkai Sun via Libc-help; +Cc: Fengkai Sun

* Fengkai Sun via Libc-help:

> My question is, why can dlfcn functions be called before ld.so is
> initialized? Obviously a program written by the user cannot do that, and I
> can't find the reference to dlfcn functions in rtld.c.
> So what is rtld_active() used for?
>
> Additionally, what does "static dlopen" mean?

It means dlopen called from a statically linked application.  The
application does not use ld.so in this case.  It gets still loaded after
dlopen, but this version is not functional.  It cannot be initialized
because that would conflict with the process initialization the
statically linked program has already performed.

This is just how things are today.  Other approaches might be possible,
some of which could well eliminate this problem and use ld.so directly
even from statically linked programs.

Thanks,
Florian


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

end of thread, other threads:[~2020-09-03  8:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03  7:17 Usage of rtld_active() in dlfcn functions Fengkai Sun
2020-09-03  8:08 ` Florian Weimer

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 read-only IMAP folder(s) and NNTP newsgroup(s).