use elf as ext
This commit is contained in:
parent
4e591092db
commit
b4dbce76cf
9 changed files with 31 additions and 61 deletions
28
README.md
28
README.md
|
@ -11,28 +11,14 @@
|
|||
|
||||
如果你有 RISC-V 真机,可以采用真机运行,否则可以考虑模拟运行。两者行为应当是一致的。
|
||||
|
||||
### 真机运行
|
||||
|
||||
编译运行程序,src 为本语言源代码。可以编译 demo 或 test 文件夹下的实例。
|
||||
|
||||
```sh
|
||||
$ sh run-native.sh <src>
|
||||
```
|
||||
|
||||
自举编译器,输出的文件位于 build 文件夹中。
|
||||
|
||||
```sh
|
||||
$ sh boot-native.sh
|
||||
```
|
||||
|
||||
### 模拟运行
|
||||
|
||||
安装以下依赖
|
||||
如果是模拟运行,则需要安装以下依赖:
|
||||
|
||||
```sh
|
||||
sudo apt install gcc-12-riscv64-linux-gnu qemu-user qemu-system-misc
|
||||
```
|
||||
|
||||
如果是真机运行,则可以跳过这一步。
|
||||
|
||||
编译运行程序,src 为本语言源代码。可以编译 demo 或 test 文件夹下的实例。
|
||||
|
||||
```sh
|
||||
|
@ -52,10 +38,10 @@ $ sh boot.sh
|
|||
|
||||
| 源代码 | 编译器 | 汇编 | 可执行 | 代号 | 命名 |
|
||||
| ------ | --------- | ------- | --------- | ---- | ---------------------- |
|
||||
| boot.c | gcc | | gcc.out | G | 自制编译器 |
|
||||
| boot.c | gcc.out | boot1.s | boot1.out | B1 | 自举自制编译器 |
|
||||
| boot.c | boot1.out | boot2.s | boot2.out | B2 | 自举自举自制编译器 |
|
||||
| boot.c | boot2.out | boot3.s | | B3 | 验证自举自举自制编译器 |
|
||||
| boot.c | gcc | | gcc.elf | G | 自制编译器 |
|
||||
| boot.c | gcc.elf | boot1.s | boot1.elf | B1 | 自举自制编译器 |
|
||||
| boot.c | boot1.elf | boot2.s | boot2.elf | B2 | 自举自举自制编译器 |
|
||||
| boot.c | boot2.elf | boot3.s | | B3 | 验证自举自举自制编译器 |
|
||||
|
||||
除了第一次编译全程由 gcc 完成之外,另外三次编译从源码到汇编由本编译器完成,从汇编到可执行文件由 gcc 完成。从汇编到可执行文件时需要将 glibc 链接进去,这对于 gcc 来说是默认的行为。
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue