This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: .init/.fini section question
- From: Ian Lance Taylor <iant at google dot com>
- To: "Darryl L. Miles" <darryl-mailinglists at netbauds dot net>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 07 Apr 2010 07:41:59 -0700
- Subject: Re: .init/.fini section question
- References: <4BB29032.9050903@netbauds.net>
"Darryl L. Miles" <darryl-mailinglists@netbauds.net> writes:
> First where is the best source of documentation over ELF features that
> can be used by DSOs ?
Excellent question.
> * The dynamic linker serializes all invocations to an individual DSOs
> .init/.fini pointers (clarification covered in next 3 points).
Invocations are serialized yes, but not because of the dynamic linker.
The dynamic linker simply runs the code that the DT_INIT and
DT_INIT_ARRAY dynamic tags point to.
> * That protection is provided between pointers of a single DSOs,
> i.e. they are fired in order of the ELF section synchronously.
Yes.
> * That protection is provided between two (or more) independent
> threads causing the same DSO to be loaded. i.e. the dynamic linker
> provides a mutex around the loading procedure and each user that is
> increasing the reference count gets to do their thing in turns.
Yes.
> * This results in the .init/.fini pointers conforming to a
> single-threaded model (which is being enforced by the dynamic linker,
> even if the outside world is a multi-threaded enviroment).
Yes.
> * That each loading the DSO fires the .init/.fini, meaning each time
> the reference count inside the dynamic linker increments we always get
> the callbacks fired (for example through dlopen()).
No, if you dlopen the same DSO twice without dlclosing it in between,
the DT_INIT tags will only get run once.
> * Does the .init/.fini method have a way of asking the dynamic linker
> for its own handle/reference and what information does the dynamic
> linker make available through that.
I don't know of a way to do this. There may be one.
Ian