ARMとRISC-Vでも実行出来る様に

This commit is contained in:
2025-12-15 16:44:57 +09:00
parent 3b5dc8f534
commit 98b54d9861
2 changed files with 109 additions and 16 deletions

View File

@@ -1,13 +1,28 @@
此れはlibcなしの「こんにちは、世界」のデモです。\
Linux、FreeBSD、OpenBSD、NetBSD、及びmacOSで実行出来ますが、IntelやAMD CPUが必須に成ります。
此れはlibcなしの「こんにちは、世界」のデモです。
This is a libc-less "hello, world" demo.\
It runs on Linux, FreeBSD, OpenBSD, NetBSD, and macOS, but requires an Intel or AMD CPU.
This is a libc-less "hello, world" demo.
## 対応 | Support
| OS | CPU | 対応 | テスト済み |
|---------|---------|------|------------|
| Linux | x86-64 | | |
| Linux | AArch64 | | |
| Linux | RISC-V | | |
| FreeBSD | x86-64 | | |
| OpenBSD | x86-64 | ✕ | ✕ |
| NetBSD | x86-64 | | ✕ |
| macOS | x86-64 | | ✕ |
| macOS | AArch64 | | ✕ |
| Windows | x86-64 | ✕ | ✕ |
| Windows | AArch64 | ✕ | ✕ |
## 使い方 | How to use
### x86-64
```sh
$ cc -nostdlib -static -masm=intel -o main main.c
$ ls -thal main
-rwxr-xr-x 1 suwako suwako 1.6K 12月 15 15:57 main
-rwxr-xr-x 1 suwako suwako 1.5K 12月 15 15:57 main
$ file main
main: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, not stripped
$ objdump -M intel -d main
@@ -29,4 +44,36 @@ Disassembly of section .text:
201213: 0f 05 syscall
201215: 5d pop rbp
201216: c3 ret
$ ./main
こんにちは、世界!
```
### AArch64、RISC-V
```sh
$ cc -nostdlib -static -o main main.c
$ ls -thal main
-rwxrwxr-x 1 suwako suwako 5.5K 12月 15 16:54 main
$ file main
main: ELF 64-bit LSB executable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), statically linked, BuildID[sha1]=, not stripped
$ objdump -d main
main: file format elf64-littleriscv
Disassembly of section .text:
000000000001017c <_start>:
1017c: 00001797 auipc a5,0x1
10180: e8478793 addi a5,a5,-380 # 11000 <msg>
10184: 04000893 li a7,64
10188: 4505 li a0,1
1018a: 85be mv a1,a5
1018c: 4671 li a2,28
1018e: 00000073 ecall
10192: 05d00893 li a7,93
10196: 4501 li a0,0
10198: 00000073 ecall
1019c: 0001 nop
$ ./main
こんにちは、世界!
```