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

Initialize data section in arm/crt0.S


Hi,

I am targeting a barebones STM32F0 Cortex-M0 using gcc-4.7.4 and newlib-2.1.0 with nano.specs.

I figured out that the startup code from newlib-2.1.0/libgloss/arm/crt0.S gets used. It initializes the C/C++ runtime environment, provides initialization hooks, and eventually calls main. It looks sensible, so I would like to use it (i.e., use _start as the reset vector) instead of rolling my own.

However, while the code does zero out the BSS segment and calls C++ constructors (__libc_init_array), it does not initialize the data section. So when I get to main, static data is not initialized as it should be.

The attached patch adds data segment initialization.

The gcc-arm-embedded folks suggest that data segment initialization should happen in CPU-specific startup code, i.e., in the code that defines the vector table. Not sure if I agree. But in that case, BSS zeroization should be removed from crt0.S: either do both, or do neither.

Thanks,
Frank


--
Frank Pilhofer
Zühlke Engineering GmbH

Attachment: crt0.S.patch
Description: crt0.S.patch


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