hi all.
I want to recude the build image. but i find some functions are not used in my project.
for example, two functions who comes from one source file. now fun1() is used, fun2() not used, they are belong to text section.
but all function code are added into the fina image after armlink
so what command or option can be used for armlink, which can delete unused funciton code in image, not delete total section.
Thanks ,
The linker works with ELF sections. Each object (.o) file contains one or more (usually more) ELF sections.
From the linker's perspective, ELF sections are indivisible. So if any function within an ELF section is used, it must include the entire ELF section. The compiler will default to putting all the code from a given source file into a single ELF section. Again meaning that if any function in that file is used, all of them will be pulled in.
There are a couple of things you can do about this.
Armlink has a feature called "linker feedback", this outputs a list of functions that were used within the image. You can then re-compile passing the list to armcc. Armcc will then put those functions into separate ELF sections, allowing armlink to remove them.
ARM Compiler armcc User Guide : 2.17 Minimizing code size by eliminating unused functions during compilation
You can also tell armcc to put _all_ functions into separate ELF sections:
ARM Compiler armcc User Guide : 8.175 --split_sections
Or, individually label a function as being in a separate section:
ARM Compiler armcc User Guide : 10.79 #pragma arm section [section_type_list]