zz http://blog.csdn.net/white_eyes/article/details/7168062
Ubuntu下面的GCC默認開啓了Stack Smashing Protector,如果想在這個系統中學習緩衝區溢出的原理,在編譯時要加上fno-stack-protector選項,否則運行時會出現*** stack smashing detected ***: xxx terminated,而不是期望的Segmentation fault。同時還需要加上允許棧執行的選項。
gcc -fno-stack-protector -z execstack -ggdb -o xxx xxx.c
-mpreferred-stack-boundary=2可用於指定邊界對齊字節數