This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: __CTORS__
- To: Rafael Rodríguez Velilla <rrv at tid dot es>
- Subject: Re: [ECOS] __CTORS__
- From: Jesper Skov <jskov at redhat dot com>
- Date: 07 Dec 2000 13:12:14 +0100
- Cc: ecos <ecos-discuss at sourceware dot cygnus dot com>
- References: <3A2F673F.709A1965@tid.es>
>>>>> "Rafael" == Rafael Rodríguez Velilla <rrv@tid.es> writes:
Rafael> void cyg_invoque_constructors(void) { pfunc *p; for
Rafael> (p=&__CTOR_END__[-1];p >= __CTOR_LIST__;p--) (*p) (); }
Rafael> I have search what these extern symbols are (__CTOR_LIST__
Rafael> and __CTOR_END__). I found it at the linker script arm.ld.
Rafael> Can anybody explain me which constructors are referenced at
Rafael> __CTOR__LIST__ and what does it means when you reference it
Rafael> with brackets? The symbol at arm.ld is just __CTOR_END__, but
Rafael> at this routine is called with __CTOR_END__[-1].
The two symbols are the limits of an array of pointers to
constructors. The pointers in this array get sorted (see linker
script) according to their priority. We add the brackets in the C code
to make the compiler treat the symbols as array references -- type
information only exists in the compiler; in the linker a symbols is
just named entity associated with an address.
The code above iterates through the array from the top to the bottom
(end-1 to start), calling each constructor in turn.
Hope that helps.
Jesper