aboutsummaryrefslogtreecommitdiff
path: root/src/lib/rethooks.zig
blob: e81125abb7ebe0876b2a8c5571558c0e79aaebcc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

pub fn terminate() linksection(".rethooks") callconv(.Naked) noreturn {
    // Syscall #100001 is "open".
    // Use the "/process/self/terminate" hook to terminate the thread.
    asm volatile (
        \\ mv a0, a2
        \\ mv a1, a3
        \\ mv t0, a0
        \\ li a7, 100001
        \\ ecall
        :
        : [path_c] "{t0}" ("/process/self/terminate\x00".ptr),
        : "a0", "a2", "a3", "a7"
    );
}