Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

bug report: __etext in linker script can be unaligned

Linker script `nrf_common.ld` in nRF5 SDK v16 defines __etext to point to the end of the .text section. It needs to be 4-byte aligned according to comments in `gcc_startup_xxxx.S`, but there's nothing that forces it to be so in the linker script.

It just happened to me that by chance the last symbol in .text happened to be odd-sized, so __etext got unaligned. This lead to all .data to be loaded shifted by 1 byte leading to quite spectacular crashes :)

The fix is to add ". = ALIGN(4);" before defining __etext (line 90)

Related