From: Ralph Ronnquist Date: Mon, 28 Mar 2022 23:37:13 +0000 (+1100) Subject: bbonev squeeze X-Git-Tag: deb_0.1.2~1 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=325fc118fc6a2ad914947cc4ab9464ca5cf94815;p=rrq%2Foverlay-boot.git bbonev squeeze --- diff --git a/asm/reaper.asm b/asm/reaper.asm index 0086a8f..c5dee49 100644 --- a/asm/reaper.asm +++ b/asm/reaper.asm @@ -6,41 +6,32 @@ format elf64 executable entry main - ;; A data segment - segment readable writable +;;; Using mixed Data and Code segment for size squeeze - ;; sigset_t set -- bit mask for sigprocmask -set: dq -1 ; all bits set - -;;; siginfo_t status -- all ignored -status: rept 16 { dq 0 } -status$end: - -;;; A code segment - segment readable executable + segment readable writable executable ;;; Main entry point main: ;; if (getpid() != 1) exit 1; - mov rax, qword 39 + xor rax, rax + mov al, 39 + ; rax=39 syscall - cmp rax, 1 - je pid_1 - - ;; exit(1) - mov rdi, qword 1 - mov rax, qword 60 - syscall ; exit program + + dec rax + jnz exit ; exit(1) ;; Continue here for pid 1 only pid_1: ;; Block all signals ;; sigprocmask(SIG_BLOCK, &set, 0); - xor rdi, rdi ; SIG_BLOCK = 0 + ; rax is already 0 + mov rdi, rax ; SIG_BLOCK = 0 lea rsi, [set] ; *set - xor rdx, rdx ; 0 - xor r10, r10 ; 0 - mov rax, qword 14 ; sys_rt_sigprocmask + mov rdx, rax ; 0 + mov r10, rax ; 0 + mov al, 14 ; sys_rt_sigprocmask + ; rax=14, rdi=0, rsi=[set], rdx=0, r10=0 syscall ;; loop waiting for children, and reading their exit status @@ -48,26 +39,37 @@ reaper: ;; first clear status area again cld xor rax, rax - lea rsi, [status$end] lea rdi, [status] -clear: stosq - cmp rdi,rsi - jl clear + mov rdx, rdi + mov rcx, rax + mov cl, status$end-status + rep stosq ;; waitid( idtype, id, *status, options ) - xor rdi, rdi ; idtype_t idtype = P_ALL = 0 - xor rsi, rsi ; int id = 0 - lea rdx, [status] ; siginfo_t* = &status - mov r10, 4 ; int options = WEXITED = 4 - mov rax, 247 ; waitid + mov rdi, rax ; idtype_t idtype = P_ALL = 0 + mov rsi, rax ; int id = 0 + ;rdx = [status] ; siginfo_t* = &status + mov al, 4 ; int options = WEXITED = 4 + mov r10, rax + mov al, 247 ; waitid + ; rax=247, rdi=0, rsi=0, rdx=[status], r10=4 syscall - cmp rax,-10 ; -10 = ECHILD (no child processes) - jne reaper - + add rax, 10 ; -10 = ECHILD (no child processes) + jnz reaper + +exit: ; exit(1) + xor rax, rax mov rdi, rax - mov rax, qword 60 - syscall ; exit program + inc rdi + mov al, 60 + syscall ; exit(1) program -;;; The rest of memory is not executable - segment readable writable + ;; sigset_t set -- bit mask for sigprocmask +set: + dq -1 ; all bits set + +;;; siginfo_t status -- all ignored +status: + rept 16 { dq ? } +status$end: