added elf loader
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
|
||||
A-machine is a simple and straightforward implementation of the RV32I specification with M (multiplication/division), A (atomic operations), and C (compressed instructions) extensions. It consists of two files:
|
||||
|
||||
- [amach.awk](amach.awk), the emulator core itself that supports .dec files,
|
||||
- and [amach](amach) shell script which is a two-liner that uses POSIX `od` to convert .bin files into .dec files on the fly and then passes them to the emulator core.
|
||||
- [amach.awk](amach.awk), the emulator core itself that supports both `.dec` files and RV32-compatible ELF executables,
|
||||
- and [amach](amach) shell script which is a wrapper that uses POSIX `od` to convert `.bin` or `.elf` files into `.dec` formats on the fly and then passes them to the emulator core.
|
||||
|
||||
Additionally, A-machine is shipped with a reference test suite that assumes that you have a full RISC-V toolchain installed under the `riscv64-linux-gnu-` prefix (adjustable in the `Makefile`). Just run `make run` to build and run all tests.
|
||||
|
||||
@@ -13,6 +13,8 @@ The project is to be considered highly experimental and not production-ready in
|
||||
|
||||
## Usage
|
||||
|
||||
### Raw Binary files (`.bin`)
|
||||
|
||||
First, decide where your program needs to be loaded in memory. The default LVA (loading virtual address) is 0x100b0. In most AWK implementations, you need to convert this value to decimal (the default is 65712).
|
||||
|
||||
Then, most probably, you'll want to use the provided wrapper:
|
||||
@@ -30,6 +32,18 @@ But in case you already have a program in the `.dec` format, you can pass it dir
|
||||
POSIXLY_CORRECT=1 awk -f amach.awk [-v LVA=...] -- path/to/program.dec
|
||||
```
|
||||
|
||||
### ELF Executables
|
||||
|
||||
`amach.awk` now also features an ELF file loader that auto-detects RV32-compatible ELF headers (32-bit, little-endian, RISC-V). If detected, it:
|
||||
* Maps the loadable segments (`PT_LOAD`) to their target virtual addresses in memory.
|
||||
* Zero-initializes any remaining space in those segments (e.g., `.bss`).
|
||||
* Overrides `LVA` to the entry point (`e_entry`) specified inside the ELF file automatically, meaning no manual `-v LVA=...` parameter is needed.
|
||||
|
||||
You can launch ELF files directly using the wrapper or via the same pipe pipeline:
|
||||
```sh
|
||||
./amach path/to/program.elf
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Currently, A-machine only supports the **unprivileged** RV32IMAC instruction set with an extended subset of POSIX/Linux-compatible `ecall` system calls (using standard `asm-generic` numbers):
|
||||
|
||||
Reference in New Issue
Block a user