gcc -ffunction-sections -fdata-sections

本文介绍如何通过使用-ffunction-sections和-fdata-sections来优化编译配置,从而有效地去除未使用的函数和数据,实现程序体积的减小及提高加载速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

-ffunction-sections -fdata-sections用于去除不使用的函数和数据
spvsoc@spvsoc-vm:~/4G_8006/vsoc_posix_env$ make clean ;make make clean -C src make[1]: 进入目录“/home/spvsoc/4G_8006/vsoc_posix_env/src” ENV_DIR = /home/spvsoc/lite-user-runtime-env rm -f *.o libposix.a rm -f .depend make[1]: 离开目录“/home/spvsoc/4G_8006/vsoc_posix_env/src” make clean -C test make[1]: 进入目录“/home/spvsoc/4G_8006/vsoc_posix_env/test” ENV_DIR = /home/spvsoc/lite-user-runtime-env rm -fv test rm -fv *.o rm -fv *.spimg make[1]: 离开目录“/home/spvsoc/4G_8006/vsoc_posix_env/test” rm posix -rf make install -C src make[1]: 进入目录“/home/spvsoc/4G_8006/vsoc_posix_env/src” ENV_DIR = /home/spvsoc/lite-user-runtime-env /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c dns_server.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c exit.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c memset.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c network.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c raw.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c strncasecmp.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c timerfd.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c vfs.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -g -Wall -Os -fno-asynchronous-unwind-tables -mcpu=cortex-m3 -mthumb -nostdinc -nostdlib -ffreestanding -ffunction-sections -fdata-sections -fPIE -fno-builtin-function -Werror=implicit -flto -I ./ -I include/ -I /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/13.2.1/include -c vfs_device.c /home/spvsoc/lite-user-runtime-env/toolschain/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc-ar rcs libposix.a dns_server.o exit.o memset.o network.o raw.o strncasecmp.o timerfd.o vfs.o vfs_device.o rm …/posix -rf mkdir …/posix cp include …/posix -rf mkdir …/posix/lib cp libposix.a …/posix/lib make[1]: 离开目录“/home/spvsoc/4G_8006/vsoc_posix_env/src” make -C test make[1]: 进入目录“/home/spvsoc/4G_8006/vsoc_posix_env/test” ENV_DIR = /home/spvsoc/lite-user-runtime-env Starting Kconfig menuconfig… kconfig-mconf Kconfig --output /home/spvsoc/4G_8006/vsoc_posix_env/test/.config *** End of the configuration. *** Execute ‘make’ to start the build or try ‘make help’. make generate_header make[2]: 进入目录“/home/spvsoc/4G_8006/vsoc_posix_env/test” ENV_DIR = /home/spvsoc/lite-user-runtime-env Generating autoconf.h from .config… KCONFIG_AUTOHEADER=“/home/spvsoc/4G_8006/vsoc_posix_env/test/autoconf.h” /usr/bin/kconfig-conf --silentoldconfig /home/spvsoc/4G_8006/vsoc_posix_env/test/Kconfig /home/spvsoc/4G_8006/vsoc_posix_env/test/.config *** Error during update of the configuration. make[2]: *** [Makefile:74:generate_header] 错误 1 make[2]: 离开目录“/home/spvsoc/4G_8006/vsoc_posix_env/test” make[1]: *** [Makefile:70:menuconfig] 错误 2 make[1]: 离开目录“/home/spvsoc/4G_8006/vsoc_posix_env/test” make: *** [Makefile:3:all] 错误 2 我74行是KCONFIG_AUTOHEADER="$(KCONFIG_AUTOHEADER)" \ 75行$(KCONFIG_TOOL) --silentoldconfig $(CURDIR)/Kconfig $(KCONFIG_CONFIG) 70行$(MAKE) generate_header
最新发布
08-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值