编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法]【转】
2016-12-23 17:06
323 查看
转自:http://blog.chinaunix.net/uid-26847859-id-3297170.html
原文地址:编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法] 作者:cjunsking
写驱动程序,编译驱动模块时,出现
“make[1]: Entering directory `/usr/src/linux-headers-2.6.32-5-amd64'
/usr/src/linux-headers-2.6.32-5-common/arch/x86/Makefile:81: stack protector enabled but no compiler support” - stack protector启用,但编译器不支持
解决方法1: (除去栈保护支持)
1. 修改 /usr/src/linux-header-xxx/目录下的文件.config,找到CONFIG_CC_STACKPROTECTOR,注释掉
2. 同样的办法修改/usr/src/linux-header-xxx/include/config/auto.conf
解决方法2: (保留栈保护功能)
在/usr/src/linux-headers-2.6.32-5-common/arch/x86/Makefile中有
ifdef CONFIG_CC_STACKPROTECTOR
cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(biarch)),y)
stackp-y := -fstack-protector
KBUILD_CFLAGS += $(stackp-y)
else
$(warning stack protector enabled but no compiler support)
endif
endif
判断编译器是否支持stack-protector的是/usr/src/linux-headers-2.6.32-5-common/scripts/gcc-x86_$(BITS)-has-stack-protector.sh文件(针对32/64位机器,有不同的文件)
点击(此处)折叠或打开
#!/bin/sh
echo "" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
if [ "$?" -eq "0" ] ; then
echo y
else
echo n
fi
这个文件中判断gcc是否支持fstack-protector的方法是,查看""生成的支持栈保护的汇编码中是否含有"%gs"。大家可以通过实验来观察区别,而这个文件中的判断与实际的相反。故将这两个文件中的y和n互换位置即可。
实验: Debian6.0.5/Linux 2.6.32-5-amd64/gcc 4.4.5
源代码: (test_stack_protector.c)
int foo(void) { char X[200]; return 3; }
编译结果:
(1) gcc -S -fstack-protector -o stack test_stack_protector.c
stack:
------------------------------------------------------------
.file"test_stack_protector.c"
.text
.globl foo
.typefoo, @function
foo:
pushl %ebp
movl %esp, %ebp
subl $216, %esp
movl %gs:20, %eax
movl %eax, -12(%ebp)
xorl %eax, %eax
movl $3, %eax
movl -12(%ebp), %edx
xorl %gs:20, %edx
je .L3
call __stack_chk_fail
.L3:
leave
ret
.sizefoo, .-foo
.ident"GCC: (Debian 4.4.5-8) 4.4.5"
.section.note.GNU-stack,"",@progbits
(2) gcc -S -fno-stack-protector -o nostack test_stack_protector.c
nostack:
------------------------------------------------------------
.file"test_stack_protector.c"
.text
.globl foo
.typefoo, @function
foo:
pushl %ebp
movl %esp, %ebp
subl $208, %esp
movl $3, %eax
leave
ret
.sizefoo, .-foo
.ident"GCC: (Debian 4.4.5-8) 4.4.5"
.section.note.GNU-stack,"",@progbits
原文地址:编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法] 作者:cjunsking
写驱动程序,编译驱动模块时,出现
“make[1]: Entering directory `/usr/src/linux-headers-2.6.32-5-amd64'
/usr/src/linux-headers-2.6.32-5-common/arch/x86/Makefile:81: stack protector enabled but no compiler support” - stack protector启用,但编译器不支持
解决方法1: (除去栈保护支持)
1. 修改 /usr/src/linux-header-xxx/目录下的文件.config,找到CONFIG_CC_STACKPROTECTOR,注释掉
2. 同样的办法修改/usr/src/linux-header-xxx/include/config/auto.conf
解决方法2: (保留栈保护功能)
在/usr/src/linux-headers-2.6.32-5-common/arch/x86/Makefile中有
ifdef CONFIG_CC_STACKPROTECTOR
cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(biarch)),y)
stackp-y := -fstack-protector
KBUILD_CFLAGS += $(stackp-y)
else
$(warning stack protector enabled but no compiler support)
endif
endif
判断编译器是否支持stack-protector的是/usr/src/linux-headers-2.6.32-5-common/scripts/gcc-x86_$(BITS)-has-stack-protector.sh文件(针对32/64位机器,有不同的文件)
点击(此处)折叠或打开
#!/bin/sh
echo "" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
if [ "$?" -eq "0" ] ; then
echo y
else
echo n
fi
这个文件中判断gcc是否支持fstack-protector的方法是,查看""生成的支持栈保护的汇编码中是否含有"%gs"。大家可以通过实验来观察区别,而这个文件中的判断与实际的相反。故将这两个文件中的y和n互换位置即可。
实验: Debian6.0.5/Linux 2.6.32-5-amd64/gcc 4.4.5
源代码: (test_stack_protector.c)
int foo(void) { char X[200]; return 3; }
编译结果:
(1) gcc -S -fstack-protector -o stack test_stack_protector.c
stack:
------------------------------------------------------------
.file"test_stack_protector.c"
.text
.globl foo
.typefoo, @function
foo:
pushl %ebp
movl %esp, %ebp
subl $216, %esp
movl %gs:20, %eax
movl %eax, -12(%ebp)
xorl %eax, %eax
movl $3, %eax
movl -12(%ebp), %edx
xorl %gs:20, %edx
je .L3
call __stack_chk_fail
.L3:
leave
ret
.sizefoo, .-foo
.ident"GCC: (Debian 4.4.5-8) 4.4.5"
.section.note.GNU-stack,"",@progbits
(2) gcc -S -fno-stack-protector -o nostack test_stack_protector.c
nostack:
------------------------------------------------------------
.file"test_stack_protector.c"
.text
.globl foo
.typefoo, @function
foo:
pushl %ebp
movl %esp, %ebp
subl $208, %esp
movl $3, %eax
leave
ret
.sizefoo, .-foo
.ident"GCC: (Debian 4.4.5-8) 4.4.5"
.section.note.GNU-stack,"",@progbits
相关文章推荐
- 编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法]
- mac编译apache时出现 checking whether the C compiler works... no 的解决办法
- 源码编译出现的问题cmake 提示C compiler was not found和Cxx complier was not found解决办法
- linux系统安装php时编译php5.5.0出现“set --enable-opcache=no ”错误的解决办法
- Ubuntu 下编译出现-Werror=unused-but-set-variable的解决办法
- Qt5编译时出现<QtGui/QApplication> ---> No such file or directory错误解决办法
- 编译时出现set but not used [-Werror=unused-but-set-variable]问题的解决办法
- Xcode7.3编译unity导出工程出现no simulator只能选择devices解决办法
- Keil编译出现“Error: L6406W: No space in execution regions with .ANY selector match Section"的解决办法
- coc 4000 os2d-x-2.2中编译cocos2d-win32.vc2010.sln出现:C1083 pthread.h No such file or director错误的解决办法
- 使用px4编译代码时出现“no module names site”错误的解决办法
- 关于android开发中编译时出现“No Launcher activity found!”的解决办法
- 编译时出现set but not used [-Werror=unused-but-set-variable]问题的解决办法
- Java链接Redis时出现 “ERR Client sent AUTH, but no password is set” 异常的原因及解决办法
- VS2008编译DirectX SDK 2004 summer版的Sound例子程序出现的libcp.lib找不到的问题的解决办法
- Cacti安装nginx状态监控时出现No such file or directory错误的解决办法
- wince6.0 编译报错:"error C2220: warning treated as error - no 'object' file generated"的解决办法
- [Trouble Shoot]Maven编译中出现的对范型的不支持和解决办法
- 我把一个VC6的工程转换为VS2008的工程后,编译总是出现找不到而且不能升级vc90.pdb文件的问题,error C2471--解决办法
- UNIX/Linux下运行脚本文件出现bad interpreter:No such file or directory的原因和解决办法