Basically, this is about pruning unused SDK code. There are a lot of functions in the SDK, and many of them are unused in each individual project and should not be in the firmware. However, by default, linker will only drop whole object files, i.e. if nothing from that file is used. That is rarely true. However, this pruning can be pushed down to the function level with two steps:
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.
SDK compiled with -ffunction-sections
Who is online
Users browsing this forum: No registered users and 16 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.