ARMv7M ELF loader logo

ARMv7M ELF loader

Free

ARMv7-M ELF loader for bare-metal and RTOS environments

FreeFree tier
Type
Open Source

About ARMv7M ELF loader

ARMv7M ELF loader is an open-source library designed to load and execute ELF binaries on ARMv7-M (Thumb-2) architecture, including Cortex-M and Cortex-R processors in Thumb2 mode. It operates over bare-metal or RTOS environments without requiring an MMU or special OS support, only relying on aligned memory allocation for minimal memory overhead. The loader handles two relocation types (R_ARM_ABS32 and R_ARM_THB_JMP/CALL) and recognizes custom memory sections such as .sdram_data, .sdram_rodata, and .sdram_bss. It provides a simple API including load_elf(), jumpTo(), get_func(), get_obj(), and unload_elf(). Developed with GCC ARM embedded and tested with Linaro toolchains, it requires ELF files compiled with specific flags (-fno-common, -mword-relocation, -r, -nostartfiles).

Key Features

Loads ELF executables on ARMv7-M (Thumb-2) without MMU or special OS support
Minimal memory overhead: only required parts of file loaded in memory
Supports Cortex-M and Cortex-R in Thumb2 mode
API provides load_elf, jumpTo, get_func, get_obj, and unload_elf functions
Handles R_ARM_ABS32 and R_ARM_THB_JMP/CALL relocations
Recognizes custom memory sections: .sdram_data, .sdram_rodata, .sdram_bss
Works with GCC ARM embedded and Linaro arm-linux-gnueabihf toolchains
Open source with configurable file I/O macros for portability

Pros & Cons

Pros
  • Minimal memory overhead due to loading only required ELF parts
  • No MMU or special OS support required
  • Simple and well-documented API
  • Supports custom memory sections for flexible memory mapping
  • Open source with permissive license
  • Configurable I/O and memory management macros for portability
  • Works with common ARM GCC toolchains
Cons
  • Limited to ARMv7-M Thumb-2 architecture only
  • Requires specific ELF compilation flags (-fno-common, -mword-relocation, etc.)
  • Only handles two relocation types (R_ARM_ABS32 and R_ARM_THB_JMP/CALL)
  • No support for common sections; all non-init data must be in bss
  • Not a full-fledged operating system; loader only

Best For

Dynamic code loading on Cortex-M microcontrollersBare-metal and RTOS application development for ARMv7-MLoading and executing ELF binaries in embedded systemsPrototyping and testing ARM Thumb-2 code without full OSExecuting user-supplied code in sandboxed environments

FAQ

What architectures does the ARMv7M ELF loader support?
It supports ARMv7-M (Thumb-2) architecture, including Cortex-M and Cortex-R processors in Thumb2 mode.
Does it require an MMU or special OS support?
No, it does not require an MMU or special OS support. It only needs aligned memory allocation and works on bare-metal or RTOS environments.
What are the compilation requirements for ELF files?
Code must be compiled with -fno-common and -mword-relocation, linked with -r and -nostartfiles. No common sections allowed; only word relocations (R_ARM_ABS32 and R_ARM_THB_JMP/CALL) are handled.
How do I load and execute an ELF file?
Call load_elf() with the file path and symbol environment to obtain an ELFExec context. Then use jumpTo() to execute the entry point, or get_func()/get_obj() to retrieve function pointers or global variables. Finally, use unload_elf() to clean up.
Is this loader compatible with any toolchain?
It is developed with GCC ARM embedded (arm-none-eabi) and also tested with Linaro arm-linux-gnueabihf in freestanding mode.