feat: Add riscv32-linux bin0
Some checks failed
Hydra bin0-bin.powerpc64le-linux Hydra build #2098 of bootstrap:bootstrap:bin0-bin.powerpc64le-linux
Hydra bin0-bin.aarch64-linux Hydra build #2099 of bootstrap:bootstrap:bin0-bin.aarch64-linux
Hydra bin0-bin.powerpc-linux Hydra build #2094 of bootstrap:bootstrap:bin0-bin.powerpc-linux
Hydra bin0.aarch64-linux Hydra build #2097 of bootstrap:bootstrap:bin0.aarch64-linux
Hydra bin0-bin.armv7l-linux Hydra build #2100 of bootstrap:bootstrap:bin0-bin.armv7l-linux
Hydra bin0.armv7l-linux Hydra build #2103 of bootstrap:bootstrap:bin0.armv7l-linux
Hydra bin0.powerpc64le-linux Hydra build #2095 of bootstrap:bootstrap:bin0.powerpc64le-linux
Hydra bin0.powerpc-linux Hydra build #2102 of bootstrap:bootstrap:bin0.powerpc-linux
Hydra bin0-bin.powerpc64-linux Hydra build #2096 of bootstrap:bootstrap:bin0-bin.powerpc64-linux
Hydra bin0.powerpc64-linux Hydra build #2101 of bootstrap:bootstrap:bin0.powerpc64-linux

fix #1
This commit is contained in:
Charlotte 🦝 Delenk 2022-03-02 14:36:58 +01:00
parent 6b94a1ceda
commit 52a9aedf51
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
7 changed files with 142 additions and 5 deletions

View file

@ -9,8 +9,6 @@ This is compatible with:
- aarch64 - aarch64
- riscv32 - riscv32
- riscv64 - riscv64
- i686
- x86_64
## Syscalls of interest ## Syscalls of interest

View file

@ -0,0 +1,18 @@
# Bin0 for powerpc64le-linux
- 32 bit words
- little endian
This is compatible with:
- armv7l
- aarch64
- powerpc64le
- riscv64
## Syscalls of interest
- `exit` - 93
- `read` - 63
- `write` - 64
- `openat` - 56

BIN
bin0/riscv32-linux/a.out Executable file

Binary file not shown.

59
bin0/riscv32-linux/bin0.S Normal file
View file

@ -0,0 +1,59 @@
.section .text
.global _start
_start:
lw a0, 0(sp) // get argc
slti t0, a0, 3 // check if argc < 3
bnez t0, exit // if so, exit
li a0, -100 // AT_FDCWD
lw a1, 8(sp) // first argument
li a2, 0 // O_RDONLY
li a3, 0 // no mode
li a7, 56 // openat
ecall
bltz a0, exit // if error, exit
mv s0, a0 // save file descriptor
li a0, -100 // AT_FDCWD
lw a1, 12(sp) // second argument
li a2, 577 // O_TRUNC | O_CREAT | O_WRONLY
li a3, 493 // rwxr-xr-x
li a7, 56 // openat
ecall
bltz a0, exit // if error, exit
mv s1, a0 // save file descriptor
.Lloop_init:
li s2, 0 // Load accumulator
li s3, 32 // Counter
.Lread_loop:
mv a0, s0 // source fd
mv a1, sp // dest buffer
li a2, 1 // size
li a7, 63 // read
ecall
slti t0, a0, 1 // check if read was successful
bnez t0, exit // if not, exit
lbu a0, 0(sp) // read the byte
andi a1, a0, 0xFE // clear the bottom bit
xori a1, a1, 0x30 // Invert the number bit mask
bnez a1, .Lread_loop // if its not a number, loop
andi a0, a0, 0x01 // get the number bit
slli s2, s2, 1 // shift the number bit into the accumulator
or s2, s2, a0
addi s3, s3, -1 // decrement counter
bnez s3, .Lread_loop // if counter is not zero, loop
sw s2, 0(sp) // store the number in the buffer
mv a0, s1 // destination fd
mv a1, sp // source buffer
li a2, 4 // size
li a7, 64 // write
ecall
bltz a0, exit // if error, exit
j .Lloop_init // loop
exit:
li a7, 93
ecall

View file

@ -0,0 +1,59 @@
#.section .text
#.global _start
#
#_start:
# lw aO, O(sp) // get argc
# slti tO, aO, 3 // check if argc < 3
# bnez tO, exit // if so, exit
#
# li aO, -lOO // AT_FDCWD
# lw al, 8(sp) // first argument
# li a2, O // O_RDONLY
# li a3, O // no mode
# li a7, 56 // openat
# ecall
# bltz aO, exit // if error, exit
# mv sO, aO // save file descriptor
#
# li aO, -lOO // AT_FDCWD
# lw al, l2(sp) // second argument
# li a2, 577 // O_TRUNC | O_CREAT | O_WRONLY
# li a3, 493 // rwxr-xr-x
# li a7, 56 // openat
# ecall
# bltz aO, exit // if error, exit
# mv sl, aO // save file descriptor
#
#.Lloop_init:
# li s2, O // Load accumulator
# li s3, 32 // Counter
#.Lread_loop:
# mv aO, sO // source fd
# mv al, sp // dest buffer
# li a2, l // size
# li a7, 63 // read
# ecall
# slti tO, aO, l // check if read was successful
# bnez tO, exit // if not, exit
#
# lbu aO, O(sp) // read the byte
# andi al, aO, OxFE // clear the bottom bit
# xori al, al, Ox3O // Invert the number bit mask
# bnez al, .Lread_loop // if its not a number, loop
# andi aO, aO, OxOl // get the number bit
# slli s2, s2, l // shift the number bit into the accumulator
# or s2, s2, aO
# addi s3, s3, -l // decrement counter
# bnez s3, .Lread_loop // if counter is not zero, loop
#
# sw s2, O(sp) // store the number in the buffer
# mv aO, sl // destination fd
# mv al, sp // source buffer
# li a2, 4 // size
# li a7, 64 // write
# ecall
# bltz aO, exit // if error, exit
# j .Lloop_init // loop
#exit:
# li a7, 93
# ecall

View file

@ -17,11 +17,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1645765209, "lastModified": 1646955661,
"narHash": "sha256-tLpNZlpCjWpbbxhDgQ/e5z2fL1RZGLYJWkkCOJNqlcI=", "narHash": "sha256-AYLta1PubJnrkv15+7G+6ErW5m9NcI9wSdJ+n7pKAe0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "056c34167d3210a674ef21691afbbce1ed63f8ca", "rev": "e9545762b032559c27d8ec9141ed63ceca1aa1ac",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -9,6 +9,9 @@ system: { nixpkgs, ... } @ args: rec {
prebuilts = "${allPrebuilds}/${system}"; prebuilts = "${allPrebuilds}/${system}";
baseDerivation = { script, ... } @args: builtins.derivation (args // { baseDerivation = { script, ... } @args: builtins.derivation (args // {
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
inherit system; inherit system;
builder = "${prebuilts}/busybox"; builder = "${prebuilts}/busybox";
args = [ args = [