Linking into objects using C++
Kövesdi György
kgy@deverto.hu
Fri Aug 10 18:02:00 GMT 2007
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.
More information about the Binutils
mailing list