In an embedded system, this method can be used when the program size is high
There is often a situation in the code, not all functions in the library will be used. However, useless functions are eventually compiled into executable files.
To avoid this, you can add the option: -ffunction-sections -fdata-sections when compiling. This option leaves each function and data alone
When linking, add options: -Wl, -gc-sections. This option will remove useless segments.
It should be noted that once -Wl, -gc-sections are used, gdb cannot be used for debugging. The gprof tool is also unavailable
————————————————
Copyright Notice: This article is an original article by CSDN blogger "Stone Shoko", follow the CC 4.0 BY-SA copyright agreement, please attach it for reprint The original source link and this statement.
Original link: https://blog.csdn.net/taixinlfx/java/article/details/17991249