How martinribelotta/elfloader works
And Label Main Components
• Core ELF Loader Module:
• Main ELF loading engine (loader.c/loader.h).
• Exported API functions: load_elf, jumpTo, get_func, get_obj, and unload_elf.
• Configuration & Abstraction Layer:
• File handling macros (LOADER_OPEN_FOR_RD, LOADER_READ, LOADER_SEEK_FROM_START, etc.).
• Memory management macros (LOADER_ALIGN_ALLOC, LOADER_FREE, etc.).
• Code execution macro (LOADER_JUMP_TO) and debugging utilities (DBG, ERR, MSG).
• ARM Support Module:
• ARM layer which includes the CMSIS directory, startup files (startup_ARMCM4.S), and the fault handling (fault.c).
• This module is critical as it underpins proper initialization and execution in the ARM embedded context.
• Application/Demo Modules:
• These modules serve as usage examples that interact with the ELF Loader Core.
• Linker Scripts & Build Configuration:
• Although not a runtime module, include a section for ldscripts (gcc.ld, mem.ld, etc.) which influence memory layout and linking.
• Mention the Makefiles present in various folders as part of the build process.
Relationships and Data Flow
• Interactions from the Loader Core to the Configuration & Abstraction Layer:
• That file I/O and memory allocation functions are decoupled via macros, abstracting the hardware-specific details.
• Dependency of the Loader Core on the ARM Support Module:
• Link the Loader Core with the ARM-specific startup and CMSIS code that ensure proper execution in a bare-metal environment.
• Optionally, denote that the linker scripts guide how different sections (such as .sdram_data, .sdram_rodata, .sdram_bss) are handled during the load process.
Architectural Patterns and Design Principles
• Modular Design:
• The core loader functionality is separated from configuration, hardware, and demo applications.
• Abstraction of Low-level Operations:
• Through macros and configuration definitions, file I/O, memory management, and code jumping are abstracted to work with various environments.
• Separation of Concerns:
• Distinct modules for execution (core loader), hardware initialization (ARM CMSIS, startup), and demonstration/testing (applications) are clearly shown.