为什么D_FORTIFY_SOURCE会使某些功能不受保护?

问题描述

我目前在Ubuntu 20.04.1上,尝试使用-D_FORTIFY_SOURCE标志构建apache apr 1.7.0。 但是,当我使用checksec扫描文件时,发现大多数功能仍然不受保护。

这是我的GCC 10.2配置行:

radius

这是checksec工具(剥离后)的输出,显示12个功能中有10个未受保护:

 CC=gcc-10 CFLAGS="-O3 -fstack-protector-all" CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure 

我也尝试过使用clang进行构建:

$ checksec --fortify-file=libapr-1.so
* FORTIFY_SOURCE support available (libc)    : Yes
* Binary compiled with FORTIFY_SOURCE support: Yes

 ------ EXECUTABLE-FILE ------- . -------- LIBC --------
 Fortifiable library functions | Checked function names
 -------------------------------------------------------
 gethostname                    | __gethostname_chk
 fdelt_chk                      | __fdelt_chk
 read                           | __read_chk
 getcwd                         | __getcwd_chk
 fprintf                        | __fprintf_chk
 memmove                        | __memmove_chk
 memset                         | __memset_chk
 memcpy_chk                     | __memcpy_chk
 memcpy                         | __memcpy_chk
 poll                           | __poll_chk
 strcpy                         | __strcpy_chk
 recvfrom                       | __recvfrom_chk

SUMMARY:

* Number of checked functions in libc                : 79
* Total number of library functions in the executable: 801
* Number of Fortifiable functions in the executable : 12
* Number of checked functions in the executable      : 2
* Number of unchecked functions in the executable    : 10

输出是14个不受保护的功能中的10个。

CC=clang CFLAGS="-O3 -fstack-protector-all" CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure 

我不确定这是一个实际问题还是只是预期的行为。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...