{{ message }}
Repository navigation
Conversation
Teach apelink to select EM_RISCV inputs when uname -m reports riscv64. This enables fat APE binaries containing a RISC-V ELF payload to assimilate and run on RISC-V Linux systems. Signed-off-by: Zhouqi Jiang <jiangzhouqi25@mails.ucas.ac.cn>
Teach ape to build and run its loader on riscv64 Linux. Add the RISC-V startup, launch, syscall, and frame macros, use the generic Linux syscall table, and let apelink select bundled RISC-V loaders. Signed-off-by: Zhouqi Jiang <jiangzhouqi25@mails.ucas.ac.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This adds a Linux RV64 APE loader and teaches apelink to select it when
uname -mreportsriscv64. The loader uses the Linux generic syscall ABI and currently targets static RV64IMAC/LP64 ELF executables.This is loader support only. It does not attempt to port Cosmopolitan libc or the compiler runtime to RISC-V (will be implemented in the future).
For a minimal test, save the following as
/tmp/hello-riscv64.S:It uses the Linux
writeandexitsyscalls directly and does not depend on libc. Compile it with:The explicit text address keeps the ELF load segments above the 2 MiB userspace limit enforced by apelink.
Build
apelinkand the three loaders with:The existing example ELFs can be used as the x86-64 and AArch64 payloads:
Running the resulting file on x86-64 prints
hello world. Running the same file on a Linux machine whereuname -mreportsriscv64prints:The RISC-V path was tested on real hardware, including repeated runs through the extracted loader cache. The existing x86-64 and AArch64 loader builds also continue to pass. (AArch64 execution was not tested on our hardware.)