feat: add powerpc bin0
This commit is contained in:
parent
5875797b18
commit
d5a4280390
12 changed files with 168 additions and 0 deletions
Binary file not shown.
|
@ -1,6 +1,7 @@
|
||||||
system: { self, nixpkgs, ... } @ args: with self.lib.${system}; with nixpkgs.lib; if lists.any (s: system == s) [
|
system: { self, nixpkgs, ... } @ args: with self.lib.${system}; with nixpkgs.lib; if lists.any (s: system == s) [
|
||||||
"armv7l-linux"
|
"armv7l-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
"powerpc-linux"
|
||||||
] then
|
] then
|
||||||
rec {
|
rec {
|
||||||
bin0-bin = baseDerivation {
|
bin0-bin = baseDerivation {
|
||||||
|
|
15
bin0/powerpc-linux/README.md
Normal file
15
bin0/powerpc-linux/README.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# Bin0 for powerpc-linux
|
||||||
|
|
||||||
|
- 32 bit words
|
||||||
|
- big endian
|
||||||
|
|
||||||
|
This is compatible with:
|
||||||
|
|
||||||
|
- powerpc64
|
||||||
|
|
||||||
|
## Syscalls of interest
|
||||||
|
|
||||||
|
- `exit` - 1
|
||||||
|
- `read` - 3
|
||||||
|
- `write` - 4
|
||||||
|
- `openat` - 286
|
BIN
bin0/powerpc-linux/bin0
Executable file
BIN
bin0/powerpc-linux/bin0
Executable file
Binary file not shown.
62
bin0/powerpc-linux/bin0.S
Normal file
62
bin0/powerpc-linux/bin0.S
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
.section .text
|
||||||
|
.global _start
|
||||||
|
|
||||||
|
_start:
|
||||||
|
lwz 3, 0(1) // get argc
|
||||||
|
cmpwi 3, 3 // check if argc is 3
|
||||||
|
blt exit // exit otherwise
|
||||||
|
|
||||||
|
li 3, -100 // AT_FDCWD
|
||||||
|
lwz 4, 8(1) // first argument
|
||||||
|
li 5, 0 // O_RDONLY
|
||||||
|
li 6, 0 // no mode
|
||||||
|
li 0, 286 // openat
|
||||||
|
sc
|
||||||
|
bso exit // exit otherwise
|
||||||
|
mr 12, 3 // save file descriptor
|
||||||
|
|
||||||
|
li 3, -100 // AT_FDCWD
|
||||||
|
lwz 4, 12(1) // second argument
|
||||||
|
li 5, 577 // O_TRUNC | O_CREAT | O_WRONLY
|
||||||
|
li 6, 493 // rwxr-xr-x
|
||||||
|
li 0, 286 // openat
|
||||||
|
sc
|
||||||
|
bso exit // exit otherwise
|
||||||
|
mr 13, 3 // save file descriptor
|
||||||
|
|
||||||
|
.Lloop_init:
|
||||||
|
li 14, 0 // accumulator
|
||||||
|
li 15, 32 // Counter
|
||||||
|
.Lread_loop:
|
||||||
|
mr 3, 12 // source fd
|
||||||
|
mr 4, 1 // destination buffer
|
||||||
|
li 5, 1 // size
|
||||||
|
li 0, 3 // read
|
||||||
|
sc
|
||||||
|
bso exit // exit otherwise
|
||||||
|
cmpwi 3, 0 // check if eof
|
||||||
|
beq exit
|
||||||
|
|
||||||
|
lbz 3, 0(1) // get byte
|
||||||
|
andi. 4, 3, 0xFE // clear bottom bit
|
||||||
|
cmpwi 4, 0x30 // check if byte is a number
|
||||||
|
bne .Lread_loop // loop if not
|
||||||
|
|
||||||
|
andi. 3, 3, 1 // get the bottom bit
|
||||||
|
rlwinm 14, 14, 1, 0, 30 // shift accumulator
|
||||||
|
or 14, 14, 3 // add bottom bit to accumulator
|
||||||
|
addi 15, 15, -1 // decrement counter
|
||||||
|
cmpwi 15, 0 // check if counter is 0
|
||||||
|
bne .Lread_loop // loop if not
|
||||||
|
|
||||||
|
stw 14, 0(1) // store accumulator
|
||||||
|
mr 3, 13 // dest fd
|
||||||
|
mr 4, 1 // source buffer
|
||||||
|
li 5, 4 // size
|
||||||
|
li 0, 4 // write
|
||||||
|
sc
|
||||||
|
bso exit // exit otherwise
|
||||||
|
b .Lloop_init // loop
|
||||||
|
exit:
|
||||||
|
li 0, 1 // exit
|
||||||
|
sc
|
85
bin0/powerpc-linux/bin0.bin0
Normal file
85
bin0/powerpc-linux/bin0.bin0
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
01111111 01000101 01001100 01000110 # ELF Magic
|
||||||
|
00000001 00000010 00000001 00000000 # 32 bit big endian elf
|
||||||
|
00000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000 # padding
|
||||||
|
0000000000000010 0000000000010100 # PPC ELF
|
||||||
|
00000000000000000000000000000001 # original version elf
|
||||||
|
00000000001000000000000001010100 # Program Entry position
|
||||||
|
00000000000000000000000000110100 # Program header table position
|
||||||
|
00000000000000000000000000000000 # Section Header table position
|
||||||
|
00000000000000000000000000000000 # Flags
|
||||||
|
0000000000110100 0000000000100000 # Header Size, Size of an entry in the program header table
|
||||||
|
0000000000000001 0000000000101000 # One program header, section header size
|
||||||
|
0000000000000000 0000000000000000 # no section headers, no section name section
|
||||||
|
|
||||||
|
00000000000000000000000000000001 # PT_LOAD
|
||||||
|
00000000000000000000000000000000 # Load from ZERO
|
||||||
|
00000000001000000000000000000000 # Load at 2MB
|
||||||
|
00000000001000000000000000000000 # Who cares about physical address
|
||||||
|
00000000000000000000000100011000 # size
|
||||||
|
00000000000000000000000100011000 # memory size
|
||||||
|
00000000000000000000000000000111 # rwx
|
||||||
|
00000000000000000000000000000100 # align 4 bytes
|
||||||
|
|
||||||
|
#.section .text
|
||||||
|
#.global _start
|
||||||
|
#
|
||||||
|
#_start:
|
||||||
|
100000 00011 00001 0000000000000000 # lwz 3, O(l) // get argc
|
||||||
|
001011 000 0 0 00011 0000000000000011 # cmpwi 3, 3 // check if argc is 3
|
||||||
|
010000 01100 00000 00000000101101 0 0 # blt exit // exit otherwise
|
||||||
|
#
|
||||||
|
001110 00011 00000 1111111110011100 # li 3, -lOO // AT_FDCWD
|
||||||
|
100000 00100 00001 0000000000001000 # lwz 4, 8(l) // first argument
|
||||||
|
001110 00101 00000 0000000000000000 # li 5, O // O_RDONLY
|
||||||
|
001110 00110 00000 0000000000000000 # li 6, O // no mode
|
||||||
|
001110 00000 00000 0000000100011110 # li O, 286 // openat
|
||||||
|
010001 00000 00000 0000 0000000 000 1 0 # sc
|
||||||
|
010000 01100 00011 00000000100110 0 0 # bso exit // exit otherwise
|
||||||
|
011111 00011 01100 00011 0110111100 0 # mr l2, 3 // save file descriptor
|
||||||
|
#
|
||||||
|
001110 00011 00000 1111111110011100 # li 3, -lOO // AT_FDCWD
|
||||||
|
100000 00100 00001 0000000000001100 # lwz 4, l2(l) // second argument
|
||||||
|
001110 00101 00000 0000001001000001 # li 5, 577 // O_TRUNC | O_CREAT | O_WRONLY
|
||||||
|
001110 00110 00000 0000000111101101 # li 6, 493 // rwxr-xr-x
|
||||||
|
001110 00000 00000 0000000100011110 # li O, 286 // openat
|
||||||
|
010001 00000 00000 0000 0000000 000 1 0 # sc
|
||||||
|
010000 01100 00011 00000000011110 0 0 # bso exit // exit otherwise
|
||||||
|
011111 00011 01101 00011 0110111100 0 # mr l3, 3 // save file descriptor
|
||||||
|
#
|
||||||
|
#.Lloop_init:
|
||||||
|
001110 01110 00000 0000000000000000 # li l4, O // accumulator
|
||||||
|
001110 01111 00000 0000000000100000 # li l5, 32 // Counter
|
||||||
|
#.Lread_loop:
|
||||||
|
011111 01100 00011 01100 0110111100 0 # mr 3, l2 // source fd
|
||||||
|
011111 00001 00100 00001 0110111100 0 # mr 4, l // destination buffer
|
||||||
|
001110 00101 00000 0000000000000001 # li 5, l // size
|
||||||
|
001110 00000 00000 0000000000000011 # li O, 3 // read
|
||||||
|
010001 00000 00000 0000 0000000 000 1 0 # sc
|
||||||
|
010000 01100 00011 00000000010101 0 0 # bso exit // exit otherwise
|
||||||
|
001011 000 0 0 00011 0000000000000000 # cmpwi 3, O // check if eof
|
||||||
|
010000 01100 00010 00000000010011 0 0 # beq exit
|
||||||
|
#
|
||||||
|
100010 00011 00001 0000000000000000 # lbz 3, O(l) // get byte
|
||||||
|
011100 00011 00100 0000000011111110 # andi. 4, 3, OxFE // clear bottom bit
|
||||||
|
001011 000 0 0 00100 0000000000110000 # cmpwi 4, Ox3O // check if byte is a number
|
||||||
|
010000 00100 00010 11111111110101 0 0 # bne .Lread_loop // loop if not
|
||||||
|
#
|
||||||
|
011100 00011 00011 0000000000000001 # andi. 3, 3, l // get the bottom bit
|
||||||
|
010101 01110 01110 00001 00000 11110 0 # rlwinm l4, l4, l, O, 3O // shift accumulator
|
||||||
|
011111 01110 01110 00011 0110111100 0 # or l4, l4, 3 // add bottom bit to accumulator
|
||||||
|
001110 01111 01111 1111111111111111 # addi l5, l5, -l // decrement counter
|
||||||
|
001011 000 0 0 01111 0000000000000000 # cmpwi l5, O // check if counter is O
|
||||||
|
010000 00100 00010 11111111101111 0 0 # bne .Lread_loop // loop if not
|
||||||
|
#
|
||||||
|
100100 01110 00001 0000000000000000 # stw l4, O(l) // store accumulator
|
||||||
|
011111 01101 00011 01101 0110111100 0 # mr 3, l3 // dest fd
|
||||||
|
011111 00001 00100 00001 0110111100 0 # mr 4, l // source buffer
|
||||||
|
001110 00101 00000 0000000000000100 # li 5, 4 // size
|
||||||
|
001110 00000 00000 0000000000000100 # li O, 4 // write
|
||||||
|
010001 00000 00000 0000 0000000 000 1 0 # sc
|
||||||
|
010000 01100 00011 00000000000010 0 0 # bso exit // exit otherwise
|
||||||
|
010010 11111111111111111110010100 # b .Lloop_init // loop
|
||||||
|
#exit:
|
||||||
|
001110 00000 00000 0000000000000001 # li O, l // exit
|
||||||
|
010001 00000 00000 0000 0000000 000 1 0 # sc
|
BIN
prebuilt/powerpc-linux/busybox
Executable file
BIN
prebuilt/powerpc-linux/busybox
Executable file
Binary file not shown.
1
prebuilt/powerpc-linux/cp
Symbolic link
1
prebuilt/powerpc-linux/cp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
1
prebuilt/powerpc-linux/dirname
Symbolic link
1
prebuilt/powerpc-linux/dirname
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
1
prebuilt/powerpc-linux/echo
Symbolic link
1
prebuilt/powerpc-linux/echo
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
1
prebuilt/powerpc-linux/mkdir
Symbolic link
1
prebuilt/powerpc-linux/mkdir
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
1
prebuilt/powerpc-linux/mv
Symbolic link
1
prebuilt/powerpc-linux/mv
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
busybox
|
Loading…
Reference in a new issue