陆续写些关于新书《自己动手写CPU》的博客,本篇主要是讲解简单修改gem5的默认例子hello world
gem5默认的例子是hello world,在tests/test-progs/hello/src文件夹下,内容如下:
#include <stdio.h>
int main()
{
printf("Hello world!\n");
}
修改为如下:
#include <stdio.h>
int main()
{
printf("Hello world! GEM5\n");
}
也就是简单的修改了输出内容,本实验的主要目的是熟悉编译gem5测试程序的过程,所以只是做了一个简单修改。
使用如下语句编译,注意加上--static选项:
gcc --static hello.c -o hello
但是提示:
/usr/bin/ld: cannot find -lc
collect2: ld 返回 1
原因是编译时需要链接静态库,但是没有找到,可以使用如下命令检查是否安装:
rpm -ql glibc-static
如果没有安装,