* __attribute__((constructor)) and order of calls
@ 2002-10-24 11:58 Gigi Sullivan
2002-10-31 4:11 ` Arunachalam G
0 siblings, 1 reply; 2+ messages in thread
From: Gigi Sullivan @ 2002-10-24 11:58 UTC (permalink / raw)
To: gcc-help
Aiee :)
Hello!
Let suppose that I've 2 or more functions which are "characterized"
by the __attribute__((constructor)) attribute.
I'm just wondering if there's a clean way to know the routines' order
of call.
Does the same rule, if any, apply to destructor attribute as well ?
TIA, bye
-- gg sullivan
--
Lorenzo Cavallaro `Gigi Sullivan' <sullivan@sikurezza.org>
Until I loved, life had no beauty;
I did not know I lived until I had loved. (Theodor Korner)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: __attribute__((constructor)) and order of calls
2002-10-24 11:58 __attribute__((constructor)) and order of calls Gigi Sullivan
@ 2002-10-31 4:11 ` Arunachalam G
0 siblings, 0 replies; 2+ messages in thread
From: Arunachalam G @ 2002-10-31 4:11 UTC (permalink / raw)
To: Gigi Sullivan; +Cc: gcc-help
Hi,
> Let suppose that I've 2 or more functions which are "characterized"
> by the __attribute__((constructor)) attribute.
>
The functions which has attribute constructor will all be grouped in
__CTORS_LIST_ and those has destructor attribute will be grouped in
__DTORS_LIST_
while the program starts the function __do_global_ctors_aux which in .init
section will call the constructors starting from the tail of
__CTORS_LIST_ .
while the program ends the functions __do_global_dtors_aux which is in
.fini section will call the destructors from the head of __DTORS_LIST_ .
for eg.
...
static void f1() __attribute__ ((constructor));
static void f2() __attribute__ ((constructor));
static void f3() __attribute__ ((constructor));
static void f2() { ...; }
static void f1() { ...; }
static void f3() { ...; }
...
the order of call will be f3, f1, f2. the order will be reversed in case
of destructors.
--
arun.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-31 12:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-24 11:58 __attribute__((constructor)) and order of calls Gigi Sullivan
2002-10-31 4:11 ` Arunachalam G
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).