This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((constructor)), shared object files and C++...
On Wed, May 07, 2003 at 10:31:20AM -0700, Muthukumar Ratty wrote:
>
> Hi Daniel,
>
> I have one more question about this for the C example
>
> I did ...
>
> ld -shared -soname libtest.so.1 -o libtest.so.1.0 -lc libtest.o
>
> and looked into the generated ELF file for this case and found that it
> lacks .init and .fini sections which has the constructors and destructors.
> So I tried the following
>
> gcc -shared -Wl,-soname -Wl,libtest.so.1 -o libtest.so.1.0 -lc libtest.o
>
> and I see the .init and .fini sections and the executable calls the
> constructors and destructors correctly.
>
> So ld doesnt recognize __attribute__ key word? Any idea how to make it
> work? (looking at the ld manual, i got the idea that it may be possible using
> __CTORS_LIST__ etc. in the linker script? Is that right?
>
They come from crti.o/crtn.o added by gcc/g++.
H.J.