gcc undefined reference to '__stack_chk_fail'【操作系统开发编译中遇到的问题】

本文介绍了在使用GCC编译器进行操作系统开发时遇到的一个常见错误:undefined reference to `__stack_chk_fail`。通过分析,解释了该错误产生的原因,并提供了一个简单的解决方案:在CFLAGS中添加-add-fno-stack-protector标志,以禁用GCC的部分后台检查功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

今天看一本os的书,照着写,然后在ubuntu下用gcc编译链接,出现错误

undefined reference to `__stack_chk_fail’


上网找了一下,解决方法是:

add -fno-stack-protector to your CFLAGS.


原因是:GCC likes to do a bunch of stuff behind the scenes. It’s great for application programming because all of the runtime support is already there, unfortunately in OS development you have to make the runtime support yourself. Using that flag tells GCC to not to do some of that stuff behind the scenes, so you don’t have to write the stuff until much later where you have an idea as to what you need and how to do it.


因为我写的是操作系统,所以好像应该是没有运行时的支持,GCC会做后台的检查,以后系统完善后,加上运行时支持就好了。

不知到这样理解对不对,有哪位高人知道的,告诉我一下,感激不尽。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值