This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Global Objects Problem NOT SOLVED!!!
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Satendra Pratap'" <spgroups at gmail dot com>,<gcc at gcc dot gnu dot org>
- Cc: <ian at airs dot com>
- Date: Thu, 5 May 2005 15:57:02 +0100
- Subject: RE: Global Objects Problem NOT SOLVED!!!
----Original Message----
>From: Satendra Pratap
>Sent: 05 May 2005 15:23
> Hi
> I can not control the disclaimer that is being appended by our office
> mailserver . Hence resending the mail from my gmail account.
Very considerate of you, thanks!
> I am building GCC 3.2 for target=sparclet-aout.
> Though there is no issue with C however the C++ global objects are not
> getting initialized.
> other global objects in the file. Now, it's the job of linker to
> accumulate all __GLOBAL__I_<> symbols from all .o into an array (of
> function pointers). The linker should (as per docs) create a symbol
> named __CTOR_LIST__ that should point to starting of the array. (In my
> __main I'm processing __CTOR_LIST__). However in the final executable
> __CTOR_LIST__ is not created at all! Though the __GLOBAL__I_<> symbols
> are linked into the final executable gracefully. (Yes I have added
> CONSTRUCTORS command to my linker script)
CONSTRUCTORS is only valid for formats such as ECOFF and XCOFF. Read the
bit in the ld manual more closely:
-----------------------------------------------
`CONSTRUCTORS'
[ ... ] When linking object file formats which do not support
arbitrary sections, such as ECOFF and XCOFF, the linker will
automatically recognize C++ global constructors and destructors by
name. For these object file formats, the `CONSTRUCTORS' command
tells the linker to place constructor information in the output
section where the `CONSTRUCTORS' command appears. The
`CONSTRUCTORS' command is ignored for other object file formats.
-----------------------------------------------
For a.out format, which doesn't have named sections for .ctors and .dtors,
I believe you will need to use the 'collect2' wrapper around ld to generate
and compile a .C file containing source code to generate the arrays
__CTOR_LIST__ and __DTOR_LIST__.
Read the gcc internals manual, nodes "Target Macros/Assembler
Format/Initialisation" and "Collect2" for full details of how it's handled.
cheers,
DaveK
--
Can't think of a witty .sigline today....