From 1fae0a8d8228995cd54bd70a36473f7e662ebaac Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 27 Feb 2025 02:08:21 +0100 Subject: [PATCH] asm version --- .gitignore | 1 + create.sh | 9 +++++---- myinit/Makefile | 3 +++ myinit/justreboot.S | 10 ++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 myinit/Makefile create mode 100644 myinit/justreboot.S diff --git a/.gitignore b/.gitignore index d3b8d86..e3de845 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /initrd/ /initrd.img +/myinit/init diff --git a/create.sh b/create.sh index 8e656db..c2e32a1 100755 --- a/create.sh +++ b/create.sh @@ -4,11 +4,12 @@ set -eu -mkdir "initrd" -cp "./init" "initrd/" +pushd myinit +make +popd -busybox="$(which busybox)" -cp "$busybox" "initrd/busybox" +mkdir "initrd" +cp "./myinit/init" "initrd/" pushd "./initrd" find . | cpio -o -H newc > ../initrd.img diff --git a/myinit/Makefile b/myinit/Makefile new file mode 100644 index 0000000..bb98cc9 --- /dev/null +++ b/myinit/Makefile @@ -0,0 +1,3 @@ +init: justreboot.S + musl-gcc -nostdlib --static justreboot.S -o init + strip init diff --git a/myinit/justreboot.S b/myinit/justreboot.S new file mode 100644 index 0000000..a859dff --- /dev/null +++ b/myinit/justreboot.S @@ -0,0 +1,10 @@ +#include + +.globl _start + +_start: + movq $__NR_reboot, %rax; + movq $0xfee1dead, %rdi; + movq $0x05121996, %rsi; + movq $0x4321fedc, %rdx; + syscall;