A small, validation-first ELF64 parser for the EriX project, written in Rust.
Find a file
Erik Inkinen 21b9140c24
All checks were successful
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 9s
Accept GNU OSABI for static service ELFs
2026-05-23 02:14:06 +03:00
.github Tighten CI markdown policy 2026-05-22 15:10:20 +03:00
docs Tighten CI markdown policy 2026-05-22 15:10:20 +03:00
src Accept GNU OSABI for static service ELFs 2026-05-23 02:14:06 +03:00
.editorconfig Initial commit 2026-02-26 09:19:12 +01:00
.gitignore Ignore local .ci workspace 2026-04-15 21:52:50 +03:00
.markdownlint-cli2.yaml Tighten CI markdown policy 2026-05-22 15:10:20 +03:00
ARCHITECTURE.md Accept GNU OSABI for static service ELFs 2026-05-23 02:14:06 +03:00
Cargo.toml Add Phase 4 static ELF load plans 2026-05-22 18:22:48 +03:00
CODE_OF_CONDUCT.md Tighten CI markdown policy 2026-05-22 15:10:20 +03:00
CONTRIBUTING.md Tighten CI markdown policy 2026-05-22 15:10:20 +03:00
LICENSE Initial commit 2026-02-26 09:19:12 +01:00
README.md Accept GNU OSABI for static service ELFs 2026-05-23 02:14:06 +03:00
ROADMAP.md Accept GNU OSABI for static service ELFs 2026-05-23 02:14:06 +03:00
rustfmt.toml lib-elf: drop unstable rustfmt options for stable toolchains 2026-03-23 10:19:54 +02:00
SECURITY.md Tighten CI markdown policy 2026-05-22 15:10:20 +03:00

lib-elf

lib-elf is a small, validation-first ELF64 parser for the EriX project, written in Rust.

EriX is a clean-room, capability-based microkernel operating system written entirely in Rust.

Technical requirements are tracked in the EriX requirements, conventions, and project documentation.

See:

  • docs for design documents, specifications, and development plans.
  • Related architecture repositories for kernel, services, libraries, drivers, and integration tooling.

Purpose of This Repository

This repository implements the EriX ELF library. Its purpose in EriX is to provide reusable ELF primitives and contracts to EriX components.

Functionally, it exposes the ELF APIs, validation tests, and documentation used by dependent repositories. The repository keeps the implementation, interface contracts, tests, and documentation for that behavior in one reviewable ownership boundary.

The maintained responsibilities are:

  • expose the lib-elf crate API for ELF behavior used by dependent components
  • keep data formats, constants, and validation helpers documented and tested
  • provide no-alloc static executable load-plan validation for early loaders
  • preserve clean-room, no-external-crate implementation boundaries
  • maintain compatibility expectations for downstream repositories

Clean-Room Policy

EriX follows a strict clean-room philosophy:

  • No external source code may be copied.
  • No external Rust crates are allowed.
  • No code generation tools that embed third-party code.
  • All code must be authored within the project.

Violations will result in rejection of the contribution.

License

All EriX repositories are licensed under the ISC License.

Development Model

EriX development is modular, deterministic, reproducible, authority-explicit, security-first, and self-hosting oriented.

This repository follows the project roadmap and the validation rules documented in its own roadmap.

Example (intended usage)

use lib_elf::{build_static_load_plan_into, StaticLoadPlanPolicy, StaticLoadSegment};

fn inspect(bytes: &[u8]) -> Result<(), lib_elf::Error> {
    let mut segments = [StaticLoadSegment::empty(); 16];
    let plan = build_static_load_plan_into(
        bytes,
        StaticLoadPlanPolicy::erix_phase4(),
        &mut segments,
    )?;
    assert!(plan.entry >= plan.image_start && plan.entry < plan.image_end);
    Ok(())
}

The default alloc feature also exposes the Elf64 and LoadSegment iterator API for consumers that can allocate. Early system components can disable default features and use build_static_load_plan_into with caller-provided segment storage.

Phase 4.7 closure uses this no-alloc load-plan API in loaderd to validate disk-backed static bootstrap fixtures before procd materializes the process image. Dynamic linking, relocations, and dependency-object policy remain Phase 5.4 work and are not hidden behind this parser API.

The static executable ABI accepts ELF64 little-endian ET_EXEC files tagged with either System V OSABI or the GNU/Linux OSABI byte emitted by some no-std service link steps. This is a parser compatibility rule only; it does not add dynamic linking or ambient loader authority.

Testing strategy

This repo prefers deterministic, authored tests:

  • Hand-authored fixtures (small ELF binaries built as part of the workspace or encoded as byte arrays).
  • Negative tests for each validation rule (bad magic, truncated headers, out-of-bounds segments, overflow cases, etc.).
  • Optional internal mutation harnesses (randomized byte flips) as a smoke test, without relying on external fuzzing infrastructure.

Repository layout

  • src/

    • lib.rs — public API surface
    • error.rs — error types
    • elf64/ — internal parsing/validation modules
  • tests/

    • conformance and regression tests
  • docs/

    • api-intent.md (if/when needed)

Governance Principles

lib-elf governance is scoped to reusable ELF contracts shared by dependent repositories.

The scoped governance rules are:

  • It must expose narrow, documented APIs rather than component-specific policy.
  • It keeps wire formats, constants, parsers, and validation helpers deterministic and testable.
  • It preserves clean-room implementation boundaries and does not introduce external crate dependencies.
  • Breaking API or format changes require coordinated updates in every dependent repository.

Library Boundaries

  • lib-elf carries no runtime authority by itself; authority is held by callers that use the library.
  • The crate must not hide ambient I/O, allocation policy, or service discovery behind helper APIs.

Contact

Development occurs in EriX organization and discussions happen in issues and design documents.

No decisions are considered valid without documented rationale.

Maintainers can be reached via email: admin@erikinkinen.fi.