就一个简单的 c 程序:
```c
#include <stdio.h>
int main()
{
printf("Hello, World\n");
}
```
使用如下命令编译:
```
riscv64-linux-gnu-gcc --static hello.c -o hello_riscv64
```
居然可以直接运行
```
> ./hello_riscv64
Hello, World
```
使用 qemu 也能运行:
```
> qemu-riscv64-static hello_riscv64
Hello, World
```
readelf 结果:
```
> readelf -h hello_riscv64
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: RISC-V
Version: 0x1
Entry point address: 0x1054c
Start of program headers: 64 (bytes into file)
Start of section headers: 501880 (bytes into file)
Flags: 0x5, RVC, double-float ABI
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 7
Size of section headers: 64 (bytes)
Number of section headers: 28
Section header string table index: 27
``` |
|