2012年2月4日 星期六

gcc undefined reference to `__stack_chk_fail'

http://forum.osdev.org/viewtopic.php?f=1&t=19434

-fno-stack-protector

       -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.

NOTE: In Ubuntu 6.10 and later versions this option is enabled by
default for C, C++, ObjC, ObjC++, if neither -fno-stack-protector
nor -nostdlib are found.





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.

沒有留言:

張貼留言

使用 google 的 reCAPTCHA 驗證碼, 總算可以輕鬆留言了。

我實在受不了 spam 了, 又不想讓大家的眼睛花掉, 只好放棄匿名留言。這是沒辦法中的辦法了。留言的朋友需要有 google 帳號。