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

Custom linker sections not working when linking NRF SDK code as static library

I wasted way to much time figuring this one out (and after I did find the problem, I realized I had run into this about a year ago in another project :-S)

In my project I'm building the various subsystems as static libraries (.a files) that get linked into a final firmware.

Unfortunately, the placement of data into custom linker sections (for `.sdh_ble_observers`, `.sdh_stack_observers.`, `.sdh_state_observers`, etc.) doesn't seem to work properly when the contents are coming from an .a file. They end up getting stripped if when their contents come from an .a file.

The easy work-around is to not bundle the .o object files into a .a file, but just link the .o files into the final firmware directly.

Anyway, I'm posting this here for my future self or for anyone else running into this problem.

Related