My ARM based app reports > 1,250,000 bytes of program memory, but most of that is .rodata ("Read-only const") and not code. I found this in the .map file:
.rodata%268 0x00407318 0xe0b38
.rodata 0x00407318 0xe0b38 ..\src\packs\CMSIS\CMSIS\DSP\Lib\GCC\libarm_cortexM7lfdp_math.a(commontables.o)
0x00407318 arm_rfft_sR_q15_len8192
0x00407330 arm_rfft_sR_q15_len4096
0x00407348 arm_rfft_sR_q15_len2048
0x00407360 arm_rfft_sR_q15_len1024
0x00407378 arm_rfft_sR_q15_len512
0x00407390 arm_rfft_sR_q15_len256
...
It appears that the linker is dragging 0xeb038 (962616) bytes of RO data for the CMSIS DSP library. Is there a linker option (or some other technique) that would only load the tables that are used?
Is there a linker option that would only load the tables that are used
Yes, that's what linkers do by default!
Your real question should be: "why does this stuff (that I think is unused) end up in my binary"?
To answer that, you can use the linker -y
flag. From man ld
:
-y symbol
--trace-symbol=symbol
Print the name of each linked file in which symbol appears.
So if you relink your binary with -Wl,-y,arm_rfft_sR_q15_len8192
, you will find out which code (which other symbol) uses this symbol. Repeat for that other symbol, and you'll eventually find your code that causes arm_rfft_sR_q15_len8192
to be linked in.
P.S. Here is a good description of how linking with archive libraries works.