This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos 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]

Problems with __attribute__((constructor ())) and gc-sections


I'm seeing a crash in SPI because cyg_spi_at91_bus_init is
being invoked twice.

The problem is that SPI is using *both* the old style C++
constructors as well as the new C global constructors.

In cyg_type.h, CYGBLD_ATTRIB_C_INIT_PRI is only defined
for C files, so the C++ file will build the C++ constructors as well.

My first attempt at fixing this failed, because linker garbage
collection will toss out cyg_spi_at91_bus_init() when there is
no reference to it. Apparently a C global constructor is not
a reference that the linker takes into account...

My next attempt will be to remove the usage of the C constructor
in spi_at91.c. It's the *ONLY* place it is used in the entire eCos.
Wouldn't it be better to wait until there is some clean fix for this?

Is there a GCC attribute to mark a fn as KEEP() or does this
require diving into the linker script?

Using built-in specs.
Target: arm-eabi
Configured with: /home/test/src/toolchains/gcc/gcc-4.3.2/configure -v
--target=arm-eabi --prefix=/home/test/build/toolchains/arm-eabi/tools
--with-newlib --with-gnu-as --with-gnu-ld --enable-languages=c,c++
--disable-__cxa_atexit --enable-threads
--with-bugurl=http://bugs.ecos.sourceware.org/
--with-pkgversion='eCosCentric GNU tools 4.3.2-sw' --with-cpu=arm7tdmi
--with-gmp=/opt/gmp-4.2.2 --with-mpfr=/opt/mpfr-2.3.0
Thread model: single
gcc version 4.3.2 (eCosCentric GNU tools 4.3.2-sw)


-- 
Ãyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer

Attachment: spicrashwip.txt
Description: Text document

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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