This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Linking into objects using C++
- From: KÃvesdi GyÃrgy <kgy at deverto dot hu>
- To: binutils at sourceware dot org
- Date: Fri, 10 Aug 2007 20:01:59 +0200
- Subject: Linking into objects using C++
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.