[問題] GCC -fstack-protector-all 印出位置?
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux GCC
問題(Question):
最近想用 gcc -fstack-protector-all 的功能,來偵測 stack
被覆蓋。程式碼如文末所附,gcc -fstack-protector-all -g a.c
所編出的檔案,可以成功偵測到覆蓋,但沒有顯示出現問題的
function或位置。
*** stack smashing detected ***: <unknown> terminated
如果用 gdb 來載入 coredump 檔,是可以回推到其發生問題的
地方,但是覺得這樣有些不方便。
理論上印出位址應該是可行才對,不知是否有前輩知道是否辦
的到?
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <stdio.h>
void hello()
{
int i;
char buf[128];
for(i=0;i<1000;i++)
buf[i] = 0;
}
int main()
{
hello();
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.72.70.80
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1432213574.A.2ED.html
→
05/21 21:50, , 1F
05/21 21:50, 1F
推
05/21 22:45, , 2F
05/21 22:45, 2F
推
05/21 23:02, , 3F
05/21 23:02, 3F
→
05/21 23:04, , 4F
05/21 23:04, 4F
→
05/21 23:34, , 5F
05/21 23:34, 5F
→
05/21 23:34, , 6F
05/21 23:34, 6F