1) Add -ffunction-sections to the compilation step
2) Add --gc-sections to the linking step
Step 1 puts each function into its own section - whereas previously functions foo() and bar() would both go to the .text section, now they will go to .text.foo and .text.bar sections.
At the second step, linker is instructed to drop unused sections. While linking, it will build call graph between sections and drop the ones that are not marked at the end. Because each function is now in its own section, this means dropping unused functions.
So, normally, it's as easy as adding one option to compile and link steps. In the case of SDK, some small tweaks to linker script may also be necessary. In our ESP8266 project we managed to save 30K by recompiling just libc and libm with -ffunction-sections, i'm sure a lot more can be saved if proprietary parts of the SDK are compiled with this flag.
For changes to crosstool to compile libc/libm, see this commit.
Who is online
Users browsing this forum: No registered users and 20 guests
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
We also have a RTOS version and a MESH version too!
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!