编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法]【转】
转自: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”[解决办法]【转】的更多相关文章
- chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法[bubuko.com]
chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法,原文:http://bubuko.com/infodetail-328671.html 默认情况下如下图 Y轴并不是从0开始 ...
- 用xcode6.3编译早期工程时出现Undefined symbols for architecture x86_64错误的解决办法(转)
Xcode升级到5.1 新特性之一就是默认让所有App都通过64位编译器编译.原来在Xcode5.0.x的时候默认的Standard architectures只有(arm7,armv7s),到5.1 ...
- 新手,Visual Studio 2015 配置Boost库,如何编译和选择,遇到无法打开文件“libboost_thread-vc140-mt-gd-1_63.lib“的解决办法
1,到官网下载最新的boost,www.boost.org 这里我下载的1-63版本. 2,安装,解压后运行bootstrap.bat文件.稍等一小会就OK. 3,编译boost库.注意一定要使用VS ...
- MySQL更新时Error Code:1093和Error Code:1175的解决办法
Error Code: 1093. You can't specify target table 'ws_product' for update in FROM clause 这个是我们在使用upda ...
- 【iOS控制器跳转时,NavigationBar有阴影动画闪过的解决办法】
如题,push控制器时,由于默认的控制器view是黑色,push到这个控制器时,navigationBar(默认是透明效果)后面有一个黑色阴影一闪而过,解决办法将navigationBar设为图片填充 ...
- centos 6.5 启动时卡在进度条位置无法进入系统解决办法。
今天公司服务器因突然断电导致phddns 花生壳 启动失败,一直卡在启动进度条页面. 解决办法 1.按F5查看卡在什么位置, 2.查看解决方法:程序卡住的情况下,直接备份资料后,卸载程序重启就可以了. ...
- docx转doc时,防止公式被转成图片的解决办法
编辑社回复需要doc(Word 97-2003)格式的文档,可是将docx(Word 2007+)另存为doc格式时,发现公式被转成了图片.其实,最简单的办法就是,打个电话过去给编辑社:“大爷,拜托您 ...
- c# log4net安装时在AssemblyInfo中提示找不到log4net解决办法
在安装log4net时,按照安装手册需要在AssemblyInfo.cs里添加log4net的配置信息 [assembly: log4net.Config.XmlConfigurator(Config ...
- Win7下VS2008安装cocos2d-2.0-x-2.0.4模板时, 运行InstallWizardForVS2008.js文件执行失败的解决办法
今天在Win7环境下的VS2008中安装cocos2d-x模板的过程中,当点击InstallWizardForVS2008.js时,弹出" 没有文件扩展'.js'的脚本引擎&q ...
随机推荐
- DevOps is dirty work - CI drives you crazy
一直很想谈谈Continuous Integration(CI),持续集成. 就在不久前一次朋友聚会上,一个刚刚跳槽到一家创业公司的朋友跟我抱怨说他们没有CI,没有code review,要做点事太累 ...
- Random随机类(11选5彩票)BigInteger大数据类(华为面试题1000的阶乘)
先上Java Web图 为了简化叙述,只写Java代码,然后控制台输出 使用[Random类]取得随机数 import java.util.Random; public class Fir { pub ...
- elasticsearch之节点重启
Elasticsearch节点重启时背后发生的故事有哪些,应该注意哪些配置内容,本篇文章做一个简单的探讨. 节点离开 在elasticsearch集群中,假设NodeA因为种种原因退出集群,在Node ...
- SpringBoot list查询方法
SpringBoot中根据不同查询条件,获取list列表.@Componentpublic class QuerySpecifications {} (1)根据商户,查询商品全部列表 public S ...
- 掌握Thinkphp3.2.0----模型初步
1.为什么要学习框架?框架是什么? 简单的说就是为了简单,提高开发的效率.至于什么是框架(一种规范),现在的我还不是很理解,容后再议. 学习框架最重要的就是遵循,按照开发者的意图来使用该框架. 2.t ...
- Electronic oscillator
https://en.wikipedia.org/wiki/Electronic_oscillator An electronic oscillator is an electronic circui ...
- 页面上使用 Thymeleaf 的内联js不当造成了 java.lang.StackOverflowError: null 问题
由于在页面上内联js使用不当,从而在从 Controller 跳转到页面时发生了以下错误: java.lang.StackOverflowError: null at org.thymeleaf.ut ...
- 原生JS事件绑定方法以及jQuery绑定事件方法bind、live、on、delegate的区别
一.原生JS事件绑定方法: 1.通过HTML属性进行事件处理函数的绑定如: <a href="#" onclick="f()"> 2.通过JavaS ...
- CSS3媒体查询能检测到的特性小结
CSS3的Media Queries能够检测到的特性总结: 视口(viewport)解释地址:http://baike.baidu.com/view/1522985.htm width:视口宽度的检测 ...
- form 提交数组的一些trick
在给服务器传值时form利用 $.post( "/member/member/book/" + event_id, { tickets: tickets, csrf_ppw_tok ...