|
发表于 2013-4-19 14:58:15
|
显示全部楼层
keil arm 下有办法,keil c51没发现相应的功能
Minimizing code size by eliminating unused functions during compilation
ARM Compiler toolchain v5.02 for µVision Using the Compiler
Home > Getting Started with the Compiler > Minimizing code size by eliminating unused functions during compilation
Minimizing code size by eliminating unused functions during compilation
To eliminate unused functions from your object files:
Compile your source code.
Use the linker option --feedback=filename to create a feedback file. By default, the type of feedback generated is for the elimination of unused functions.
Re-compile using the compiler option --feedback=filename to feed the feedback file to the compiler.
The compiler uses the feedback file generated by the linker to compile the source code in a way that enables the linker to subsequently discard the unused functions.
Note
To obtain maximum benefit from linker feedback, do a full compile and link at least twice. A single compile and link using feedback from a previous build is normally sufficient to obtain some benefit.
You can specify the --feedback=filename option even when no feedback file exists. This enables you to use the same build or make file regardless of whether a feedback file exists, for example:
armcc -c --feedback=unused.txt test.c -o test.o
armlink --feedback=unused.txt test.o -o test.axf
The first time you build the application, it compiles normally but the compiler warns you that it cannot read the specified feedback file because it does not exist. The link command then creates the feedback file and builds the image. Each subsequent compilation step uses the feedback file from the previous link step to remove any unused functions that are identified.
|
|