This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: __CTOR_LIST__
- To: alk at pobox dot com
- Subject: Re: __CTOR_LIST__
- From: Ian Lance Taylor <ian at zembu dot com>
- Date: 01 Jul 2001 20:00:53 -0700
- Cc: binutils at gcc dot gnu dot org
- References: <15165.16007.509486.880965@spanky.love.edu>
Tony Kimball <alk@pobox.com> writes:
> I'm trying to find where __CTOR_LIST__ is constructed inside ld under
> linux x86. Can someone clue me where to look? My gcj class
> initializers (_GLOBAL__I_ symbols) are not getting added to the
> __CTOR_LIST__, and although I'm searching diligently, strace'ing, and
> what not, I have yet to find where this list is being constructed.
Short answer: the linker doesn't do anything special.
x86 Linux normally uses ELF. In ELF, global constructors are normally
handled by putting the address of the constructor in the .ctors
section. When doing a final link, the compiler will include
crtbegin.o and crtend.o in the link. These will fill in the
definition of __CTOR_LIST__.
Try compiling a trivial C++ program with a constructor. You will see
that the compiler puts the address of the global constructor in the
.ctors section.
Note that the symbol name doesn't have anything to do with this. This
is different from how some other object file formats work.
Ian