gcc -fstack protector 原理

zephyr s32k144

linux上见到过stack protector的call stack 打印知道它依赖编译器的支持, 没想到zephyr上也添加了支持

摘自gcc官网对这个编译选项的解释:

-fstack-protector

Emit extra code to check for buffer overflows, such as stack smashing attacks. 
This is done by adding a guard variable to functions with vulnerable objects. 
This includes functions that call alloca, and functions with buffers 
larger than 8 bytes. The guards are initialized when a function is 
entered and then checked when the function exits. If a guard check 
fails, an error message is printed and the program exits.

-fstack-protector-all

Like -fstack-protector except that all functions are protected.

zephyr上面该config的名字是CONFIG_STACK_CANARIES

该config的详细依赖与详细解释参考zephyr官网:

https://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_STACK_CANARIES.html?highlight=config_stack_canaries

打开这个config后制造一次踩栈实验

对比asm文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenhuxi_yu

感谢投币,继续输出

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值