This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: __CTOR_LIST__


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]