Nix: Testing a Single NixOS Module in CI

In this blog post, I explain how to test a single NixOS module in CI. By single NixOS module, I mean a module that provides some options and configurations, but itself is not a valid NixOS configuration. The use case is to have a common module (in a git repository) that you want to integrate in a full NixOS configuration, when you don’t have or want the full NixOS configuration at the same Read more…

Kernel/Boot: Cope with a Relocation by a Bootloader in 32-bit x86 Assembly Code

A kernel should be relocatable by bootloaders as this is the only guarantee that it doesn’t interfere with addresses already in use by the firmware. This is especially true for the legacy boot flow on x86, i.e., without UEFI. Update 2024-01-29: I just published a new blog post focusing more on the background. It might be worth a read for you! TL;DR Introduction There are multiple ways to make a kernel relocatable. One Read more…

How Does the “File Size is Smaller Than Mem Size” Optimization Work in GNU ld for the .bss Section?

This article explains how the GNU linker (GNU ld) can save disk space for symbols in the .bss section. TL;DR: If a section is of type SHT_NOBITS and if it is the last section in a LOAD segment, GNU ld uses this optimization. When you build software with a compiled language, such as C, certain symbols, which may originate in variable declarations, may be initialized to zero. An example are the following two Read more…

GNU ld: Linking .bss into .data to Ensure that Mem Size Equals File Size For Each LOAD Segment (.bss in a PROGBITS Section)

Update: I found another variant. I appended it to the end of the article. Original post: Some rudimentary ELF loaders require that p_memsz equals p_filesz for each LOAD segment in order to simplify the loading of the file. For example, the microkernels NOVA and Hedron have this restriction to bootstrap their roottasks (inital process). In this blog post, I’m going to provide a solution how this can be achieved when an ELF is Read more…

Symbolic Picture: .bss is part of .data section
Screenshot of the `paging-calculator` CLI utility

CLI Utility to Calculate Indices for Page Tables

I just want to drop a short notice that I created a small CLI utility that I think is helpful. paging-calculator helps you to calculate the indices for a given virtual address that are used for the physical address lookup at different page table levels. Paging is a mechanism that operating systems use for memory management. Check it out on crates.io or GitHub. You can install it with cargo install paging-calculator. It works Read more…

Configure acpid From BusyBox in a Custom initrd

I have a setup with a Linux Kernel and a custom initrd, hence, no full Linux distribution. The initrd is meant to be as minimal as it can be. As a consequence, even basic things such as power-off on power-button pressed must be configured manually. There is no init system available – instead, I have to provide the init system. The initrd contains utilities from busybox. In this blog post, I show you Read more…

acpid - Terminal Screenshot