- relink: drive host_ref emission from the relocation table so GOT slots whose
l32rload the linear scan fails to decode still get patched. A missed slot was left at its link-time value and faulted on first call.
First release. elf_overlay is an ISA-abstracted ELF overlay runtime for
embedded systems. It runs alongside an ELF loader (for example Espressif's
elf_loader) and pages overlay bodies in and out of executable RAM, patching
compiler-emitted literals in place once the resident addresses are known. The
runtime makes no assumptions about the operating system or RTOS; a small
platform port layer (port.h) is all a new host needs. Created by NellowTCS and
maintained by NellowTCS and Ashtf under the TalismanDesign organization.
- Load and unload overlay blobs (
elf_overlay_load/elf_overlay_unload) and page overlay bodies on demand through position-independent enter / leave stubs (elf_overlay_enter/elf_overlay_leave). - Manage executable RAM with a fixed-size frame pool and per-frame reference
counting:
enter()increments andleave()decrements, and a frame whose count is above zero is never evicted. - Patch compiler-emitted literals in place within the
.textimage at page-in time, leaving the PC-relative loads themselves (l32r/auipc) untouched. - Translate canonical virtual addresses to resident addresses through a section
map (
elf_overlay_set_section_map/elf_overlay_resolve), and patch resident application code to reach paged functions through their stubs (elf_overlay_apply_redirects). - Resolve host references through a caller-supplied symbol resolver
(
elf_overlay_set_symbol_resolver), aborting with a clear message on an unresolved host symbol. - Use fixed-size tables throughout, so there is no heap churn during page-in.
The frame count, frame size, and section-map capacity are compile-time
constants in
include/elf_overlay/config.h, each overridable with a-Dflag.
- Define the ELFO v1 blob format: magic
ELFO, a 46-byte packed header carrying the format version and an ISA tag, followed by overlay, stub, redirect, patch, stub-patch, and host-ref tables, a string table, the stub block, and the verbatim overlay bodies. - Define the intermediate RELK format (magic
RELK) produced by the relinker and consumed by the emitter.
- Route all ISA-specific work through
elf_overlay_isa_ops_t(include/elf_overlay/isa.h). A new ISA is added by implementing the ops table and callingelf_overlay_isa_register(). - Ship two backends: Xtensa
l32rPC-relative literal patching (verified against the Xtensa ISA reference) and RISC-VauipcPC-relative literal patching. ARM is reserved for future work.
elf_overlay_relinkreads an ELF32 executable, scans.textfor ISA-specific patch sites, builds a literal pool, classifies relocations, and writes a RELK intermediate.elf_overlay_emitpacks a RELK intermediate into an ELFO blob ready for the runtime loader. The packing engine lives in the library so the tools stay thin; both tools are compiled C with no scripting runtime.
- Provide an integration layer that copies
esp_elf_tsection addresses into the overlay section map (elf_overlay_esp_elf_set_section_map), applies redirect sites in resident memory (elf_overlay_esp_elf_apply_redirects), and resolves host references throughesp_elf_find_symbol()(elf_overlay_esp_elf_install_symbol_resolver). - Implement the ESP-IDF port of
port.h:heap_caps_mallocwithMALLOC_CAP_EXEC,ESP_LOG*, the stdio VFS, andesp_cache_msyncfor PSRAM overlay regions on ESP32-S3. The port fails to compile with a clear message when the executable heap is unavailable, since the runtime jumps into the memory it allocates.
- Package the library for PlatformIO (
library.json) and ESP-IDF (idf_component.ymlplus theESP_PLATFORMbranch of the rootCMakeLists.txt), pullingelf_loaderfrom the component registry. - Ship host unit and integration tests run under CTest, a Xtensa fixture
round-trip (
examples/host_pipeline), and a minimal ESP-IDF consumer project (examples/esp_idf_component), all exercised by CI. - Add the CI workflow: host build with
-Werror, AddressSanitizer and UBSan,clang-formatenforcement, fixture round-trip verification, and an ESP32-S3 component build.