Commit 6aff4f5
authored
Add powerpc64 and mips32 architecture support (#170)
* Add powerpc64 and mips32 architecture support
Add startup code for powerpc64le (ELFv2 ABI) and mipsel (O32 ABI) targets,
enabling no_std programs to run on these architectures.
PowerPC64 (powerpc64.rs):
- _start sets up r2 (TOC pointer) using r12 before calling entry
- trap() uses the `trap` instruction
- Full thread support scaffolding (clone, thread pointer, TLS)
- Relocation support for PIC binaries
MIPS32 (mips32.rs):
- __start entry point (MIPS convention, not _start)
- 8-byte stack alignment with 16-byte O32 save area
- trap() uses the `break` instruction
- Thread support using rdhwr for thread pointer
- Syscall convention: $v0=syscall#, $a0-$a3=args, $a3=error flag
Both architectures:
- Implement origin-start feature for program startup
- Support optimize_for_size feature
- Follow existing origin patterns from other architectures
Tested with QEMU user-mode emulation (qemu-ppc64le-static, qemu-mipsel-static).
Note: QEMU ppc64le has a bug with argv setup for non-glibc binaries, but
the startup code itself is correct and works on real hardware.
* Fix rustfmt: remove extra blank line in mips32.rs
That blank line was apparently living rent-free between __start and trap.
* Fix misleading comment about MIPS entry points
We only define __start, not both. The comment was aspirational fiction.
* Simplify mprotect syscall: remove unused r0 output
The syscall return value was just sitting there looking decortaive.
We only need the error flag from $a3.
Note: MIPS cross-compilation is not available on this dev machine,
letting CI handle the actual build verification.
* Use symbolic constant for __NR_set_thread_area
Magic numbers... Now using the proper constant from linux_raw_sys
like civilized folk.
* Fail explicitly for unsupported clone flags on MIPS
O32 ABI requires child_tid (5th arg) on stack, which we don't do.
Check for CLONE_CHILD_CLEARTID/SETTID upfront and return EOPNOTSUPP.
* Trim verbose clone() comment in powerpc64.rs
MIPS got the concise treatment, PPC64 was feeling left out.
* Document which architectures aren't tested in CI
Added a note about arm, powerpc64, and mips32 not being in CI,
along with the reasons why (missing rust-std, crate support gaps,
and a branch that got lost in the shuffle).1 parent 17031bc commit 6aff4f5
4 files changed
Lines changed: 796 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
36 | 50 | | |
37 | 51 | | |
38 | 52 | | |
| |||
0 commit comments