函数test_a和test_b在2个sections(.text._Z6test_av和.text._Z6test_bv)中: 去掉"-ffunction-sections -fdata-sections"参数编译,函数test_a和test_b在1个sections(.text)中: 4.2)libtest_2.so使用"-Wl,-gc-sections"参数,表示不链接未用的函数和符号 objdump -t libtest_2.so | grep test...
因此,GCC在编译时可以使用 -ffunction-sections 和 -fdata-sections 将每个函数或符号创建为一个sections,其中每个sections名与function或data名保持一致。而在链接阶段, -Wl,–gc-sections 指示链接器去掉不用的section(其中-wl, 表示后面的参数 -gc-sections 传递给链接器),这样就能减少最终的可执行程序的大小了...
All architectures but MIPS are using --gc-sections on final linking. This patch introduces that feature for MIPS to reduce the memory and flash footprint. Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Stefan Roese <sr@denx.de> ...
方法是在complier命令中增加-ffunction-sections,linker命令中增加-Wl,--gc-sections. -ffunction-sections:不用此参数时,.o里代码部分只有.text段;使用此参数,则会使每个函数单独成为一段,比如函数func1()成为.text.func1段,但对链接后代码大小没影响。 --gc-sections:这是avr-ld的参数,通过-Wl,由gcc把option...
希望能对从事包体积优化的同学有所帮助或启发。 1. 背景 2. so 文件格式分析 3. so 可优化内容分析...
因此,GCC在编译时可以使用 -ffunction-sections 和 -fdata-sections 将每个函数或符号创建为一个sections,其中每个sections名与function或data名保持一致。而在链接阶段, -gc-sections 指示链接器去掉不用的 section 这样就能减少最终的可执行程序的大小了。
如何让静态库中的可执行程序不调用的函数不链接进该可执行程序?(-ffunction-sections -Wl,--gc-sections) 2016-06-27 23:56 −如何让静态库中的可执行程序不调用的函数不链接进该可执行程序?(-ffunction-sections -Wl,--gc-sections) 关键词: -Wl,--gc-sections -ffunction-sections 链接 e... ...
据我所知,GCC文档中没有提到-rdynamic和--gc-sections选项的组合。应该有这样的警告:
--enable-new-dtags -o ../bin/rcc.obj/rcc.o .obj/main.o -L/home/charlie/qt-everywhere-opensource-src-5.5.0/qtbase/lib -lQt5Bootstrap -lpthread arm-linux-gnueabi-ld:无法识别的选项'-Wl,--gc-sections‘arm-linux-gnueabi-ld:使用--help选项获取用法信息Makefile:194:目标的配方' ../../...
> Can you figure out what functions are getting omitted > when you make this change? You can add "-Wl,--print-gc-sections" to LDFLAGS to print which sections the linker is removing. Andrew ___ freebsd-current@freebsd.org mailing listhttp://lists.freebsd.org/...