public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Espie <espie@quatramaran.ens.fr>
To: ROGER.K.WELLS@saic.com
Cc: gcc@gcc.gnu.org
Subject: Re: shared library, init
Date: Fri, 21 Sep 2001 16:51:00 -0000	[thread overview]
Message-ID: <200109212350.f8LNolN25875@quatramaran.ens.fr> (raw)
In-Reply-To: <00d301c14103$3c921b00$f05a798b@mtg.saic.com>

In article < 00d301c14103$3c921b00$f05a798b@mtg.saic.com > you write:
>When I use the linker flag, -Wl,-init,  the linker complains that my _init()
>conflicts with one in crti.o.  When I give the -init flag the name of a
>function that I supply it is ignored.  Can someone advise me of the correct
>syntax to establish a shared library initialization (& termination)
>function.

In the gcc context, assuming this is C, see attribute constructor and 
destructor in the gcc documentation. For C++, this is even more trivial. 
This assumes you're running gcc on a platform with full support for 
this (which is either provided directly by ld + ELF or by collect2 usually). 

Note that the semantics are a bit hard to guarantee and check: it is often
unknown in which order several initialisation routines will be run (and how 
many times), and it is even harder to be sure that a finalization routine 
will actually be run...

      reply	other threads:[~2001-09-21 16:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-19  5:04 Roger Wells
2001-09-21 16:51 ` Marc Espie [this message]

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=200109212350.f8LNolN25875@quatramaran.ens.fr \
    --to=espie@quatramaran.ens.fr \
    --cc=ROGER.K.WELLS@saic.com \
    --cc=gcc@gcc.gnu.org \
    /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.
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).