crownstone / crownstone-microapp

Crownstone microapp. Contains several examples and library to communicate with bluenet.
Apache License 2.0
2 stars 6 forks source link

Calls contructors before main #24

Closed mrquincle closed 2 years ago

mrquincle commented 2 years ago

Implements __libc_init_array. Later on we might try to find out why this isn't done. For now this calls all constructors manually in main.c before main() is called.

This fixes issues with globally defined constructors.

mrquincle commented 2 years ago

Ah, it is easy to explain, we define _start ourselves and don't use the (nano) newlib functions because of microapp size optimization.

You can see this in config.mk. To include the nano newlib functions like malloc, memset, and _start, you would write

--specs=nano.specs -Wl,-lc_nano

This wasn't the case. Only --specs=nano.specs was written which doesn't include _start on itself. Now, config.mk contains --specs=nosys.specs -Wl,-lnosys to better reflect the situation.