Swift和Stack防砸保护 [英] Swift and Stack smashing protection

查看:212
本文介绍了Swift和Stack防砸保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在纯快速应用程序中启用堆栈粉碎保护?

How to enable Stack Smashing Protection in pure swift application?

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

I did try to put "-fstack-protector-all" flag to Other C++ Flags under project build settings tab in xCode, but is seems that, this flag is unused or have no impact on builded application.

要验证版本,我使用的是otool -Iv AppBinary | grep stack.

To verifie build I'm using otool -Iv AppBinary | grep stack.

推荐答案

在Swift中,默认情况下启用堆栈粉碎,只需要在Objective-C应用程序的构建设置下添加"-fstack-protector-all"标志即可.

In Swift, Stack smashing is enabled by default one only need to add the "-fstack-protector-all" flag under build settings in objective-c applications.

如何检查是否启用了堆栈粉碎功能. 运行otool命令,并且stack_chk_guardstack_chk_fail的存在表示代码受堆栈粉碎保护.

How to check if stack smashing is enabled. Run the otool command and presence of stack_chk_guard and stack_chk_fail means the code is stack smashing protected.

$ 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

这篇关于Swift和Stack防砸保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆