gcc 3.4.4 miscompiles eCos

Guennadi Liakhovetski gl@dsa-ac.de
Fri Feb 9 12:10:00 GMT 2007


Hello all

(I am not subscribed to the list, please cc all replies)

I am cross-building the RedBoot bootloader (a part of the eCos project) 
for a PXA270 target. I can successfully build it with gcc 3.3.2, but if 
the same sources are compiled with 3.4.4, it crashes. The project is 
mostly in C with some asm parts and C++... I traced the crash down to a 
loop in a C file where they call various initialisation functions... which 
actually are C++ constructors... Using some linker magic

__CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \

they build a list of C++ constructors and then call then one after the 
other (see (*) code excerpt below).

Now, up to some gcc version there has been a -finit-priority option, which 
was also used in eCos. As this option disappeared, having become silent 
default, it worked also without it... with 3.4.4 no longer. Binutils 
version used with 3.4.4 is 2.15.96.

Is there a way to get it to work with 3.4.4? Preferrably without patching 
compiler sources / rebuilding it. And whose bug is this - gcc or eCos?

Thanks
Guennadi
---------------------------------
Guennadi Liakhovetski, Ph.D.
DSA Daten- und Systemtechnik GmbH
Pascalstr. 28
D-52076 Aachen
Germany

* calling C++ constructors:

typedef void (*pfunc) (void);
extern pfunc __CTOR_LIST__[];
extern pfunc __CTOR_END__[];

void
cyg_hal_invoke_constructors (void)
{
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
     static pfunc *p = &__CTOR_END__[-1];

     cyg_hal_stop_constructors = 0;
     for (; p >= __CTOR_LIST__; p--) {
 	    diag_printf("Invoking constructor @ 0x%08x\n", *p);
         (*p) ();
         if (cyg_hal_stop_constructors) {
             p--;
             break;
         }
     }
#else
     pfunc *p;

     for (p = &__CTOR_END__[-1]; p >= __CTOR_LIST__; p--) {
 	    diag_printf("Invoking constructor @ 0x%08x\n", *p);
         (*p) ();
     }
#endif
}



More information about the Gcc mailing list