GCC 3.2.2 (OAR build) question

Thomas Doerfler Thomas.Doerfler at imd-systems.de
Tue Feb 28 11:44:34 UTC 2006


since nobody else answered yet: I am not a C++ guru, but maybe your 
linker command file misses a section for the global constructors?

AFAIK gcc would add an entry in the global constructor table for  your 
object (this should be visible in the a.o file).

If you are missing a section in the linker command file, maybe this 
entry will not be added there (the linker might drop it?) and then your 
module "a.o" will not be referenced.

This really is a wild guess, but maybe it helps.

best wishes,

leonp at plris.com wrote:
> Hello, all.
> Please, forgive me for 99% off-topic question, but as I use not "native" 
> gcc...:-))
> I have the following very strange gcc problem - in the file a.cpp there is 
> some cCL class declaration and also global object CL is created. The 
> constructor of the class inserts 'this' pointer into a global array pCLs. 
> This array is declared system wide and all usage of the object therefore is 
> done using this pointer and the object is never referenced directly.
> Now, when everything is linked in - the 'a' object module is never used!
> I checked the a.o content - there is an object CL (record of type 000B) and 
> everything looks OK, but the executable has no a.o at all in its map file 
> (and nothing works obviously).
> Just for experiment, I added the following into a.cpp: 'volatile int 
> x;' (global var declaration) and 'extern volatile int x' into main.cpp.
> Magic! Now everything is OK - CL constructor was added into CTORS, all 
> functions appeared in the map file.
> Can someone help me to understand where the first variant is incorrect?
> Many many thanks ahead.

IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de
PGP public key available at:

More information about the users mailing list