gpt4 book ai didi

ios - Swift 和 Stack 粉碎保护

转载 作者:IT王子 更新时间:2023-10-29 05:51:33 26 4
gpt4 key购买 nike

如何在纯 swift 应用程序中启用 Stack Smashing Protection?

我确实尝试在 xCode 的项目build设置选项卡下将“-fstack-protector-all”标志放入其他 C++ 标志,但似乎该标志未使用或对构建的应用程序没有影响。

为了验证构建,我正在使用 otool -Iv AppBinary | grep 堆栈

最佳答案

在 Swift 中,Stack smashing 默认启用,只需要在 objective-c 应用程序的build设置下添加“-fstack-protector-all”标志。

如何检查堆栈粉碎是否启用。运行 otool 命令并出现 stack_chk_guardstack_chk_fail 表示代码受堆栈粉碎保护。

$ otool -Iv <appname>|grep stack
0x0013dfg 520 ___stack_chk_fail
0x001d009 521 ___stack_chk_guard
0x001fd345 520 ___stack_chk_fail
0x000000010087efd 513 ___stack_chk_fail
0x0000000100098hf3 514 ___stack_chk_guard
0x00000001000897gfr 513 ___stack_chk_fail

关于ios - Swift 和 Stack 粉碎保护,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38564924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com