Syscaller
A no-std Rust library providing direct system call interfaces for Linux x86_64 systems with hand-optimized assembly implementations and procedural macros for type-safe syscall wrapper generation.
Features
- Direct Assembly: Hand-written x86_64 syscall implementations (0-6 arguments)
- Type Safety: Procedural macros for generating safe wrappers from C signatures
- No-std Compatible: Minimal dependencies for embedded/kernel development
- Zero Dependencies: Core library has no external dependencies
Target Audience
- Kernel developers requiring direct syscall access
- Systems programmers bypassing libc overhead
- Security researchers analyzing syscall behavior
Quick Start
Add to your Cargo.toml:
[]
= { = "0.1", = ["macro"] }
Direct Assembly Usage
syscaller defines 7 basic, low-level functions that allow to invoke a Linux syscall with 0 to 6 arguments
(syscall0(...) to syscall6(...)).
Their signatures are syscallX(syscallId: usize, args...: usize).
use *;
let written = unsafe ; // write syscall
Macro Usage
The wrap_syscall proc-macro allow convenient conversion between C-like functions and syscallX calls.
Syntax
wrap_syscall!
Example
The following :
wrap_syscall!
Will generate this :
pub unsafe
pub unsafe
You can then use this more convenient function :
const HELLO: &str = "Hello, world!";
unsafe ;
Architecture
Core Library (syscaller)
The core library provides hand-written x86_64 assembly implementations:
syscall0throughsyscall6- Support 0-6 arguments- Follows System V ABI calling conventions
#![no_std]compatible with zero dependencies- Optimized for minimal overhead
Procedural Macro (syscaller-wrap-macro)
The macro crate provides type-safe wrapper generation:
- Parses C-like function signatures
- Generates Rust wrapper functions with proper types
- Handles type conversions (pointers, integers, etc.)
- Comprehensive error handling for malformed signatures
Safety
⚠️ This library provides direct access to system calls without safety guarantees.
- All functions are marked
unsafeas they can cause undefined behavior - Caller must ensure syscall numbers and arguments are valid
- Improper usage can crash your program or system
- Intended for advanced systems programming where direct control is needed
Platform Support
Currently supports:
- Linux x86_64
Planned support:
- Linux ARM64
- Linux x86
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.