ARM gcc에서 스택 검사

mhhong의 이미지

codesourcery 다음 버전을 사용하고 있습니다.
gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67)

스택 메모리 검사를 위해 -fstack-protector 옵션을 주었는데 동작을 하지 않네요.

X86 gcc에서는 잘 동작합니다.

컴파일러 직접 빌드 말고 해결법이 있을까요?

bushi의 이미지

[bushi@rose imgs]$ /opt/cross-host/arm-2009q3/bin/arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q3-67) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
[bushi@rose imgs]$
[bushi@rose imgs]$ cat x.c
#include <string.h>
int test_stackfault(void)
{
	char buf[16];
	memset(buf, 0xff, sizeof(buf)+1);
}
int main(int argc, char **argv)
{
	char buf[20];
	memset(buf, 0x00, sizeof(buf));
	return test_stackfault();
}
[bushi@rose imgs]$
[bushi@rose imgs]$ /opt/cross-host/arm-2009q3/bin/arm-none-linux-gnueabi-gcc -o  x x.c
[bushi@rose imgs]$ 
[bushi@rose imgs]$ ./x
세그멘테이션 오류 (core dumped)
[bushi@rose imgs]$ /opt/cross-host/arm-2009q3/bin/arm-none-linux-gnueabi-gcc -o  x x.c -fstack-protector
[bushi@rose imgs]$ 
[bushi@rose imgs]$ ./x
*** stack smashing detected ***: ./x terminated
...
...
...
mhhong의 이미지

헉! 감사합니다.