Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ksco/rvld
Learn how to write a minimal working linker from scratch
https://github.com/ksco/rvld
Last synced: 1 day ago
JSON representation
Learn how to write a minimal working linker from scratch
- Host: GitHub
- URL: https://github.com/ksco/rvld
- Owner: ksco
- License: agpl-3.0
- Created: 2022-10-24T05:41:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T09:33:29.000Z (7 months ago)
- Last Synced: 2024-08-02T07:02:07.037Z (3 months ago)
- Language: Go
- Homepage:
- Size: 71.3 KB
- Stars: 92
- Watchers: 6
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rvld
English | [中文版](README_cn.md)
rvld is a minimal linker implementation for the RV64GC architecture, mainly for educational purposes. rvld mostly copied the source code of [rui314/mold](https://github.com/rui314/mold), so it is a derivative work of mold, and is also distributed under the [GNU AGPL v3 LICENSE](LICENSE).
rvld can statically link a simple C program (such as the Hello world in the example below) and produce a runnable binary.
```bash
cat <
int main() {
printf("Hello, World.\n");
return 0;
}
EOF$CC -B. -s -static a.o -o out
qemu-riscv64 out# Hello, World.
```rvld is only about 2000 lines of Go code and has no external dependencies other than the standard library. Based on this project, PLCT Lab launched an open course [Implementing a Linker from Scratch](https://ksco.cc/rvld). The course is in Chinese.
## Note
rvld may not be suitable for higher version toolchains, please consider using Docker environment for easier reproduction.
```bash
docker run -u root --volume ~/Developer:/code -it golang:bullseye# Inside the docker container:
apt update
apt install -y gcc-10-riscv64-linux-gnu qemu-user
ln -sf /usr/bin/riscv64-linux-gnu-gcc-10 /usr/bin/riscv64-linux-gnu-gcc
```