c - fbounds 检查不起作用,有替代品吗?

标签 c makefile bounds-checker

我试图让 fbounds 检查工作,但没有成功。我收到以下错误:

/tmp/cczxKZzn.s: Assembler messages:

/tmp/cczxKZzn.s:48: Error: invalid instruction suffix for `push'

/tmp/cc9xD8T3.s:125: Error: invalid instruction suffix for `pop'

虽然我的 makefile 看起来像这样(使用简单的 makefile 一切都可以正确编译):

all: error check

error: error.c
    /usr/local/gcc-4.0.2/bin/gcc -fbounds-checking -g -Wall -pedantic $< -o $@

.PHONY: clean check

clean:
    -rm error

check:  error
    ./error

由于该代码与汇编程序无关,所以我不知道该怎么办。汇编器问题是我在有关该主题的 Google 搜索中唯一能看到的问题。

<小时/>

您能否提出其他解决方案,例如检查是否在数组之外? 如(这是我的错误.c):

#include <stdio.h>
#include <stdlib.h>
int main()
{
  int a[1][10];
  a[0][11]=42;
  return 0;
}
<小时/>

编辑。会不会是版本不兼容; gcc 4.4+ 已安装,我正在使用稍微修改过的 gcc 4.0.2 的路径来执行此操作?

最佳答案

Since that code has nothing to do with assembler, I don't know what to do. Assembler problems are the only ones I can see in my google search on that topic.

看起来您调用了错误的汇编器 - 32 位汇编器,试图编译 64 位目标代码。检查您的路径和标志。

更新:我从未研究过 gcc 到底是如何调用其组件的。我仍然不太清楚。不管怎样,它看起来并不像我相信的那样依赖于 PATH,而是依赖于它的 ./configure 设置(--prefix、--build 等)。

我的,有 --prefix=/usr , --build=x86_64-suse-linux, --program-suffix=-4.6 , looks for its components in (with respect to the directory where the gcc` 二进制文件位于: - ../lib64/gcc/x86_64-suse-linux/4.6 - ../lib64/gcc/ - ../lib64/gcc/x86_64-suse-linux/4.6/../../../../x86_64-suse-linux/bin/x86_64-suse-linux/4.6/ - ../lib64/gcc/x86_64-suse-linux/4.6/../../../../x86_64-suse-linux/bin/

(用 strace 检查)。

如果其中一个目录中存在来自另一个 gcc 的二进制文件,它将被调用,而不是“正确”的目录。

尝试使用 gcc -v 检查(或使用 strace )查看哪个 as正在运行。

关于c - fbounds 检查不起作用,有替代品吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12081809/

相关文章:

c++ - 帮助生成文件 : No rule to make target

makefile - Autoconf 和 makefile

c++ - BoundsChecker 和 Purify 等 64 位工具

c++ - 虚拟析构函数如何工作?

julia - Julia 中的 @inbounds 传播规则

c - 编写仅使用循环来计算可能组合的代码

C:扫描输入逻辑错误

c - 如何使用 gsasl gssapi 对 Active Directory 进行身份验证?

c - 线程调度C

bash - 生成文件 `echo -n' 不工作