Linking into objects using C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I use avr platform, but this problem might be related to other platforms too.

I have a source, let's say x.cpp, containing global constructors.
I compile it this way:

avr-gcc -c -o x.o x.cpp
avr-ld -o x x.o

It works.
If it is done in two steps:

avr-gcc -c -o x.o x.cpp
avr-ld -Ur -o y.o x.o
avr-ld -o x y.o

then the global constructors are not run, because the section .ctors is 
missing from y.o. The additional linking phase discarded it.
I tried it with -r and -Ur option, both seems wrong.
Creating an archive does not help me because there are no external references 
to those objects, and therefore it would not be linked in.

How could I do it?

Regards
K. Gy.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux