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

来源:互联网 发布:域名认证失败 编辑:程序博客网 时间:2024/06/01 07:11

 

今天看一本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会做后台的检查,以后系统完善后,加上运行时支持就好了。

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