This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]