gpt4 book ai didi

c - 使用 SimpleScalar 运行基本代码时出错

转载 作者:IT王子 更新时间:2023-10-29 00:38:56 25 4
gpt4 key购买 nike

我正在尝试使用 SimpleScalar 来运行非常基本的代码以进行测试。这是我正在运行的代码:

#include<stdio.h>

main()
{
int x = 0;
for ( x = 0; x < 1000000; x++ ) {


}
printf("Hello World \n");


}

这些是我用来使用 simple-sim 编译程序并将其运行到名为 results 的文件夹中的行。

gcc sstest.c -o sstest

./sim-safe -redir:sim results/hello.sim.out -redir:prog results/hello.prog.out sstest.

但是,程序输出为空,模拟器输出给出以下错误:

fatal: bad magic number in executable `sstest' (not an executable)

我在这个过程中做错了什么吗?非常感谢您的帮助。我还使用 Ubuntu 作为操作系统,使用 c 作为编程语言。

最佳答案

您的可执行“sstest”中的错误魔数(Magic Number) 错误消息可能表明您的二进制文件与 SimpleScaler 不兼容。

您显示的编译器脚本:gcc sstest.c -o sstest 用于创建普通二进制文件。没有任何应该导致编译失败或作为普通可执行文件运行的代码,但它不是使用 SimpleScaler 实用程序构建的。

来自 this SimpleScaler tutorial :

要创建 SimpleScaler 二进制文件,特别是使用 GCC 的 C 程序,您可以使用:

ssbig-na-sstrix-gcc -g -O -o foo foo.c -lm

从同一个链接,要在构建后运行该程序,您可以使用:

sim-safe [-sim opts] foo [-program opts]

这似乎遵循您在帖子中显示的形式:

./sim-safe -redir:sim results/hello.sim.out -redir:prog results/hello.prog.out sstest.

关于c - 使用 SimpleScalar 运行基本代码时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37163681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com