The executable file is too large after the CMSIS DSP static library is linked

phenomenon

After compiling the CMSIS static library .a file, link the executable file 780+KB generated by the APP program.
After checking the flash map file, it is found that the APP uses a function in the DSP library, which calls the DSP library file Commmontables.c, which contains a series of global constant tables, and all tables are linked after compilation.

the reason

When compiling, the compiler will link all global variables by default, which will take up a lot of space

solve

When compiling the library and APP , add compile options as follows:

CFLAGS+= -ffunction-sections -fdata-sections
LFLAGS+=-Wl,--gc-sections

This option will create a separate section for each function. When linking, only the constant table used will be linked according to the function call. After compilation, the executable file is only 70+KB.

Guess you like

Origin blog.csdn.net/jimaofu0494/article/details/102560655