- Thu Nov 13, 2014 1:59 pm
#2567
Just one little question about the toolchain.
So far the firmware is made of a bunch of .a blobs + user appcode. The .a libs are linked in one single link group, e.g. -Wl,--start-group -lmain -lc ... -Wl,--end-group.
There are 2 ways to link the app:
- Link all blobs in one group, your .o files afterwards.
- Combine your code in an ar library and link in the same group as the others
However both ways have a few pitfalls. The first variant that looked natural to me, however it results in some functions from libc, like skip_atoi, atoi, sprintf being undefined at linktime. My guess - they were in irom0.text and only those referenced by code in .text whiting the group were pulled out of the blobs by the linker (still trying to figure that out)
The latter one is how they do in SDK. However it has a more obscure pitfall I've triggered. For my frankenstein firmware, I use a special hack to include all console commands from different files by placing them in a section .console_cmd and if I link my usercode to a library - ld just drops them, along with all the code that implements these commands. KEEP(), __attribute__((used)) do not help much here. __attribute__((constructor)) don't work either anyway.
Any idea how to make this work?