System calls v0.1.0

Source
The raw system-call entry points and the call numbers they take.

SysMmap

// x86-64
pub const SysMmap: uint64 = 9;

// AArch64
pub const SysMmap: uint64 = 222;

mmap(2)'s system-call number.

Source

SysGetPid

// x86-64
pub const SysGetPid: uint64 = 39;

// AArch64
pub const SysGetPid: uint64 = 172;

getpid(2)'s system-call number.

Source

Syscall0

pub func Syscall0(number: uint64) -> int64

Executes a raw Linux system call without arguments.

Source

Parameters

NameTypeDescription
numberuint64the system call to make

Returns: the kernel's raw result

Syscall6

pub func Syscall6(
    number: uint64,
    arg0: uint64,
    arg1: uint64,
    arg2: uint64,
    arg3: uint64,
    arg4: uint64,
    arg5: uint64
) -> int64

Executes a raw Linux system call with six arguments.

Source

Parameters

NameTypeDescription
numberuint64the system call to make
arg0uint64the call's first argument
arg1uint64the call's second argument
arg2uint64the call's third argument
arg3uint64the call's fourth argument
arg4uint64the call's fifth argument
arg5uint64the call's sixth argument

Returns: the kernel's raw result

SignExtendFd

pub func SignExtendFd(fd: int32) -> uint64

Widens a file descriptor to the register width a system call takes it in. fd is read by value; the widened value is returned by copy. Sign extension is what matters: -1 has to arrive as all ones rather than as a small positive number, which is how mmap is told it has no backing descriptor. Cannot fail. Runs in constant time and allocates nothing.

Source

Parameters

NameTypeDescription
fdint32the descriptor to widen

Returns: it sign-extended, so a negative one stays negative