转自: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中有

  1. ifdef CONFIG_CC_STACKPROTECTOR
  2. cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
  3. ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(biarch)),y)
  4. stackp-y := -fstack-protector
  5. KBUILD_CFLAGS += $(stackp-y)
  6. else
  7. $(warning stack protector enabled but no compiler support)
  8. endif
  9. endif

判断编译器是否支持stack-protector的是/usr/src/linux-headers-2.6.32-5-common/scripts/gcc-x86_$(BITS)-has-stack-protector.sh文件(针对32/64位机器,有不同的文件)

点击(此处)折叠或打开

  1. #!/bin/sh
  2. echo "" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
  3. if [ "$?" -eq "0" ] ; then
  4. echo y
  5. else
  6. echo n
  7. 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:

------------------------------------------------------------

  1. .file"test_stack_protector.c"
  2. .text
  3. .globl foo
  4. .typefoo, @function
  5. foo:
  6. pushl %ebp
  7. movl %esp, %ebp
  8. subl $216, %esp
  9. movl %gs:20, %eax
  10. movl %eax, -12(%ebp)
  11. xorl %eax, %eax
  12. movl $3, %eax
  13. movl -12(%ebp), %edx
  14. xorl %gs:20, %edx
  15. je .L3
  16. call __stack_chk_fail
  17. .L3:
  18. leave
  19. ret
  20. .sizefoo, .-foo
  21. .ident"GCC: (Debian 4.4.5-8) 4.4.5"
  22. .section.note.GNU-stack,"",@progbits

(2)   gcc -S -fno-stack-protector -o nostack test_stack_protector.c

nostack:

------------------------------------------------------------

    1. .file"test_stack_protector.c"
    2. .text
    3. .globl foo
    4. .typefoo, @function
    5. foo:
    6. pushl %ebp
    7. movl %esp, %ebp
    8. subl $208, %esp
    9. movl $3, %eax
    10. leave
    11. ret
    12. .sizefoo, .-foo
    13. .ident"GCC: (Debian 4.4.5-8) 4.4.5"
    14. .section.note.GNU-stack,"",@progbits

编译驱动模块时,出现“stack protector enabled but no compiler support”[解决办法]【转】的更多相关文章

  1. chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法[bubuko.com]

    chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法,原文:http://bubuko.com/infodetail-328671.html 默认情况下如下图 Y轴并不是从0开始 ...

  2. 用xcode6.3编译早期工程时出现Undefined symbols for architecture x86_64错误的解决办法(转)

    Xcode升级到5.1 新特性之一就是默认让所有App都通过64位编译器编译.原来在Xcode5.0.x的时候默认的Standard architectures只有(arm7,armv7s),到5.1 ...

  3. 新手,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 ...

  4. MySQL更新时Error Code:1093和Error Code:1175的解决办法

    Error Code: 1093. You can't specify target table 'ws_product' for update in FROM clause 这个是我们在使用upda ...

  5. 【iOS控制器跳转时,NavigationBar有阴影动画闪过的解决办法】

    如题,push控制器时,由于默认的控制器view是黑色,push到这个控制器时,navigationBar(默认是透明效果)后面有一个黑色阴影一闪而过,解决办法将navigationBar设为图片填充 ...

  6. centos 6.5 启动时卡在进度条位置无法进入系统解决办法。

    今天公司服务器因突然断电导致phddns 花生壳 启动失败,一直卡在启动进度条页面. 解决办法 1.按F5查看卡在什么位置, 2.查看解决方法:程序卡住的情况下,直接备份资料后,卸载程序重启就可以了. ...

  7. docx转doc时,防止公式被转成图片的解决办法

    编辑社回复需要doc(Word 97-2003)格式的文档,可是将docx(Word 2007+)另存为doc格式时,发现公式被转成了图片.其实,最简单的办法就是,打个电话过去给编辑社:“大爷,拜托您 ...

  8. c# log4net安装时在AssemblyInfo中提示找不到log4net解决办法

    在安装log4net时,按照安装手册需要在AssemblyInfo.cs里添加log4net的配置信息 [assembly: log4net.Config.XmlConfigurator(Config ...

  9. Win7下VS2008安装cocos2d-2.0-x-2.0.4模板时, 运行InstallWizardForVS2008.js文件执行失败的解决办法

         今天在Win7环境下的VS2008中安装cocos2d-x模板的过程中,当点击InstallWizardForVS2008.js时,弹出" 没有文件扩展'.js'的脚本引擎&q ...

随机推荐

  1. 使用staruml学习画类图

    //这是startuml 把uml 转换成的java代码: public class Circle implements Ishape { private double _radius; public ...

  2. 折腾一两天,终于学会使用grunt压缩合并混淆JS脚本,小激动,特意记录一下+spm一点意外收获

    很长时间没有更新博客了,实在是太忙啦...0.0 ,以下的东西纯粹是记录,不是我原创,放到收藏夹还担心不够,这个以后常用,想来想去,还是放到这里吧,,丢不了..最后一句废话,网上搜集也好原创也罢,能解 ...

  3. Mybatis学习记录

    参考资料: <深入理解mybatis原理> MyBatis的架构设计以及实例分析

  4. Apache服务器性能监控

    Apache服务器性能监控 1.使用自带mod_status模块监控 1)加载mod_status.so 模块 在httpd.conf中打开LoadModule status_module modul ...

  5. Thread-Safe Resource Manager

    http://php.net/manual/en/internals2.memory.tsrm.php When PHP is built with Thread Safety enabled, th ...

  6. Linq分组

    1.lin语句 int[] nums = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0, 3 }; DataTable table = new DataTable("Numb ...

  7. 【java基础学习】网络编程

    网络编程 InetAddress tcp udp

  8. 配置opencv时计算机显示丢失opencv_world300d.dll如何解决

    在自己安装路径里找到opencv_world300d.dll文件: 然后把opencv_world300d.dll文件复制到C://Windows/System32里:

  9. JavaScript数据类型 typeof, null, 和 undefined

    JavaScript 数据类型 在 JavaScript 中有 5 种不同的数据类型: string number boolean object function 3 种对象类型: Object Da ...

  10. 前台获取Dropdownlist选中的text

    $("#ddltest").find("option:selected").text()