The main method to achieve this is to optimize your code using the proper library, and to modify the linker script.
For example, if you use xil_printf, this uses fewer resources than standard printf. For more information, refer to the document, oslib_rm.pdf, in "%EDK_install_directory%/doc".
Also, you can use "-ffunction-sections -Wl,--gc-sections" as command line options to GCC; this accomplishes the following:
-ffunction-sections: puts every function into a separate section during compilation
-Wl,-gc-sections: the linker removes unused sections
As a result, unused functions are discarded.
You might need to adapt or write your own linker script, because the compiler will invent section names of the form ".text*" as a result of "-ffunction-sections". For example:
.text : { *(.text*) }
instead of:
.text : { *(.text) }
Additionally, an outside chip memory is a another way to work around this problem.
NOTE: The -g switch increases the size of the ELF by including the debug section, but this debug section is discarded when the executable is loaded into the embedded system.
AR# 21533 | |
---|---|
日期 | 08/16/2010 |
状态 | Active |
Type | 综合文章 |
Tools |