This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BUG: GCC linker scripts don't keep .init_array sections

The GCC linker scripts included with the nRF51822 SDK (checked: 6.0.0 and 6.1.0 as well as nrf51-pure-gcc-setup) include .init_array sections, but do not specify them as KEEP sections (as .init is). This causes them to be discarded when linking with the --gc-sections option, necessary to remove unused code (combined with compiler options -ffunction-sections and -fdata-sections), along with whatever vtables and methods are referenced solely from those sections.

I am using GNU Tools for ARM Embedded Processors 4.8-2014-q2 (on a Windows host).

When I add KEEP() around the .preinit_array, .init_array, and .fini_array lines in gcc_nrf51_common.ld it fixes the issue (I will try to attach an updated version from 6.0.0).

(This is not a question as such, but this forum appears to also be used to post bug reports. I don't need further support, although it would be nice to see the fix in a future SDK.)

Parents Reply Children
Related