# neonatox/neonatox-rldispatcher architecture

> Architecture diagram of the GitHub repository neonatox/neonatox-rldispatcher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/neonatox/neonatox-rldispatcher
- Repository: https://github.com/neonatox/neonatox-rldispatcher

## Overview

nrld is a freestanding x86-64 ELF dispatcher that lets glibc applications run on musl hosts using an isolated glibc sysroot. The main workflow detects the target, prepares its libraries and environment, then launches a patched copy through the real glibc loader; AppImages have an extraction and discovery branch. The preload proxy handles runtime path and ABI isolation. README claims support for these capabilities; source excerpts are partial, so some subsystem links rely on the README rather than sampled implementation details.

Main entry points: [`nrld.c`](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c) (ELF detection), [`appimages.c`](https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c) (AppImage extraction), [`proxy_readlink.c`](https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c) (Preload proxy), [`nrld.conf`](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.conf) (nrld settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dispatch["Dispatch and launch"]
  node_target["Target ELF<br/>[nrld.c]"]
  node_detect["ELF detection<br/>[nrld.c]"]
  node_patched_copy["Patched executable<br/>[nrld.c]"]
  node_glibc_loader["glibc dynamic loader"]
  node_app_process(("glibc application"))
end

subgraph group_resolution["Image and library resolution"]
  node_appimage["AppImage extraction<br/>[appimages.c]"]
  node_appimage_bin["Internal binary<br/>[appimages.c]"]
  node_lib_discovery["Library discovery<br/>[appimages.c]"]
  node_needed_guard["NEEDED guard<br/>[nrld.c]"]
  node_absolute_patch["NEEDED path patch<br/>[nrld.c]"]
  node_glibc_sysroot[("glibc sysroot")]
end

subgraph group_isolation["Runtime isolation"]
  node_proxy["Preload proxy<br/>[proxy_readlink.c]"]
  node_readlink_fix["Executable readlink<br/>[proxy_readlink.c]"]
  node_dlopen_guard["Strict dlopen guard<br/>[proxy_readlink.c]"]
end

subgraph group_configuration["Runtime configuration"]
  node_config["nrld settings<br/>[nrld.conf]"]
  node_environment["Loader environment<br/>[nrld.c]"]
end

node_user(("User or host"))

node_user -->|"selects"| node_target
node_user -->|"invokes"| node_detect
node_detect -->|"extracts when needed"| node_appimage
node_appimage -->|"locates"| node_appimage_bin
node_appimage -->|"collects directories"| node_lib_discovery
node_detect -->|"checks dependencies"| node_needed_guard
node_needed_guard -->|"resolves within"| node_glibc_sysroot
node_detect -->|"searches missing libraries"| node_lib_discovery
node_detect -->|"patches absolute dependencies"| node_absolute_patch
node_absolute_patch -->|"checks basename"| node_glibc_sysroot
node_config -->|"configures"| node_environment
node_detect -->|"prepares"| node_environment
node_environment -->|"sets launch paths"| node_patched_copy
node_detect -->|"creates and executes"| node_patched_copy
node_patched_copy -->|"sets PT_INTERP"| node_glibc_loader
node_glibc_loader -->|"loads libraries from"| node_glibc_sysroot
node_glibc_loader -->|"starts"| node_app_process
node_environment -->|"preloads"| node_proxy
node_proxy -->|"intercepts"| node_readlink_fix
node_proxy -->|"enforces strict mode"| node_dlopen_guard
node_dlopen_guard -->|"checks library paths"| node_glibc_sysroot

click node_target "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c"
click node_detect "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c"
click node_appimage "https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c"
click node_appimage_bin "https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c"
click node_lib_discovery "https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c"
click node_needed_guard "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c"
click node_absolute_patch "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c"
click node_config "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.conf"
click node_environment "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c"
click node_patched_copy "https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c"
click node_proxy "https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c"
click node_readlink_fix "https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c"
click node_dlopen_guard "https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_target,node_detect,node_patched_copy,node_glibc_loader,node_app_process,node_user toneBlue
class node_appimage,node_appimage_bin,node_lib_discovery,node_needed_guard,node_absolute_patch,node_glibc_sysroot toneAmber
class node_proxy,node_readlink_fix,node_dlopen_guard toneMint
class node_config,node_environment toneRose
```

## Components

### Dispatch and launch

- [Target ELF](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c): `nrld.c`
- [ELF detection](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c): `nrld.c`
- [Patched executable](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c): `nrld.c`
- **glibc dynamic loader**
- **glibc application**

### Image and library resolution

- [AppImage extraction](https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c): `appimages.c`
- [Internal binary](https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c): `appimages.c`
- [Library discovery](https://github.com/neonatox/neonatox-rldispatcher/blob/main/appimages.c): `appimages.c`
- [NEEDED guard](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c): `nrld.c`
- [NEEDED path patch](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c): `nrld.c`
- **glibc sysroot**

### Runtime isolation

- [Preload proxy](https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c): `proxy_readlink.c`
- [Executable readlink](https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c): `proxy_readlink.c`
- [Strict dlopen guard](https://github.com/neonatox/neonatox-rldispatcher/blob/main/proxy_readlink.c): `proxy_readlink.c`

### Runtime configuration

- [nrld settings](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.conf): `nrld.conf`
- [Loader environment](https://github.com/neonatox/neonatox-rldispatcher/blob/main/nrld.c): `nrld.c`

### Other components

- **User or host**

## Connections

- User or host → Target ELF: selects (evidence: `README.md`)
- User or host → ELF detection: invokes (evidence: `README.md`)
- ELF detection → AppImage extraction: extracts when needed (evidence: `README.md`)
- AppImage extraction → Internal binary: locates (evidence: `appimages.c`)
- AppImage extraction → Library discovery: collects directories (evidence: `appimages.c`)
- ELF detection → NEEDED guard: checks dependencies (evidence: `README.md`)
- NEEDED guard → glibc sysroot: resolves within (evidence: `README.md`)
- ELF detection → Library discovery: searches missing libraries (evidence: `README.md`)
- ELF detection → NEEDED path patch: patches absolute dependencies (evidence: `README.md`)
- NEEDED path patch → glibc sysroot: checks basename (evidence: `README.md`)
- nrld settings → Loader environment: configures (evidence: `README.md`)
- ELF detection → Loader environment: prepares (evidence: `README.md`)
- Loader environment → Patched executable: sets launch paths (evidence: `README.md`)
- ELF detection → Patched executable: creates and executes (evidence: `README.md`)
- Patched executable → glibc dynamic loader: sets PT_INTERP (evidence: `README.md`)
- glibc dynamic loader → glibc sysroot: loads libraries from (evidence: `README.md`)
- glibc dynamic loader → glibc application: starts (evidence: `README.md`)
- Loader environment → Preload proxy: preloads (evidence: `README.md`)
- Preload proxy → Executable readlink: intercepts (evidence: `proxy_readlink.c`)
- Preload proxy → Strict dlopen guard: enforces strict mode (evidence: `proxy_readlink.c`)
- Strict dlopen guard → glibc sysroot: checks library paths (evidence: `proxy_readlink.c`)
