Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 6.49 KB

File metadata and controls

111 lines (80 loc) · 6.49 KB

Languages: English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Français | Deutsch | Español | Italiano | Русский | العربية

← Documentation index · ← NeverC project

NeverC Examples

Complete, buildable examples demonstrating NeverC's cross-platform compilation capabilities. All examples cross-compile from any host OS — no target build environment required.


Available Examples

Windows

Example Description Key Features
Windows Kernel Driver Minimal WDM kernel driver Cross-compile .sys from macOS/Linux, auto-LTO, built-in linker, DbgPrint device I/O
Windows Driver + CET Kernel driver with Intel CET Shadow Stack CET-compatible kernel code, /guard:ehcont, Shadow Stack enforcement
Windows Driver + Float Kernel driver with floating-point/SIMD Safe FP in kernel mode, KeSaveExtendedProcessorState / KeRestoreExtendedProcessorState
Windows Ring3 EXE User-mode console app GetSystemInfo, process enum, VirtualAlloc/VirtualQuery
Windows Ring3 DLL User-mode DLL ReadProcessMemory, VirtualAllocEx, module enum, XOR helper

Linux

Example Description Key Features
Linux Hello World Minimal C program Cross-compile ELF from macOS/Windows, printf, string ops
Linux POSIX POSIX system programming pthreads, mmap, pipe, signal handling
Linux Static Fully-static binary -static linking, zero runtime dependencies, math functions
Linux Network TCP socket demo Client/server, socket API, loopback communication
Linux Math + zlib Math + compression Trigonometry, special functions, zlib compress/decompress, CRC32

macOS

Example Description Key Features
macOS Application Native Mach-O executable sysctl, uname, Mach host_info/task_info, process introspection
macOS Dynamic Library Native .dylib library Mach vm_read/vm_write, vm_alloc/vm_dealloc, task_info, XOR helper

Android

Example Description Key Features
Android ELF Native ARM64 binary for rooted devices Cross-compile to Android, dlopen/liblog, /proc info, root check
Android Shared Library Native ARM64 .so library Shared library, mmap RWX, XOR encryption, dlopen liblog

Android Kernel (.ko)

No kernel source tree required — NeverC compiles against the bundled minimal runtime. Single source targets GKI 5.10–6.12.

Example Description Key Features
Kernel Hello Minimal .ko module kallsyms bootstrap via kprobe, simplest insmod validation
Kernel Driver Template Dynamic symbol resolution template kallsyms_lookup_name, GKI-stable ABI, 5.10–6.12
Kernel Inline Interpose Inline interpose on do_faccessat BTI/PAC-safe patch, context interpose mode, PC-relative relocation
Kernel Syscall Interpose Syscall table / inline / context interpose sys_call_table swap, inline interpose, context interpose modes
Kernel Lowvis Module visibility management List/sysfs/proc visibility, credential wrappers, SELinux enforcement state
Kernel Full SDK Complete SDK integration Netlink IPC, interposes, credential wrappers, module visibility, SELinux policy control, VMA, file I/O
Kernel Chardev Character device + ioctl misc_register, ioctl dispatch, /proc seq_file
Kernel Netlink Bidirectional netlink IPC PING/VERSION/ECHO commands, nvk_nl_open/nvk_nl_reply
Kernel Probe Probe an arbitrary instruction neverc_krt_probe_register, full register context, priority chaining, skip/redirect
Kernel Multi-File Multi-file kernel module One NEVERC_KRT_BOOTSTRAP(), weak_odr shared state, split init/interpose/helper files

Quick Start

Every example follows the same pattern:

cd examples/<example-name>
neverc make

Override the compiler path if needed:

neverc make NEVERC=/path/to/neverc

Linux examples support architecture selection:

neverc make TARGET=aarch64-linux-gnu   # Build for ARM64
neverc make TARGET=x86_64-linux-gnu    # Build for x86_64 (default)

macOS examples support architecture selection:

neverc make TARGET=arm64-apple-macos     # Build for Apple Silicon (default)
neverc make TARGET=x86_64-apple-macos    # Build for Intel

Android examples target ARM64 by default:

cd examples/android-elf
neverc make            # Build
neverc make run        # Build + push to device + run via adb

Cross-Platform Highlights

  • Single toolchain: NeverC handles preprocessing, compilation, optimization (auto-LTO), and linking in one invocation
  • Bundled SDK: Windows SDK/WDK, Linux sysroot (Ubuntu 22.04), macOS sysroot (macOS 14), and Android sysroot (NDK r26c, API 21+) are bundled in runtime/ — zero external dependencies
  • Host-agnostic: Build from macOS (arm64/x86_64), Linux (x86_64/aarch64), or Windows with identical commands
  • Multi-target: Cross-compile to Windows PE (.sys/.exe/.dll), Linux ELF, macOS Mach-O (.dylib), and Android ELF from any host
  • Debug support: Pass -g for DWARF debug info; inspect with llvm-dwarfdump