如何解决为什么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
CC=clang CFLAGS="-O3 -fstack-protector-all" CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure
我不确定这是一个实际问题还是只是预期的行为。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。