arch/mips: Add support for loadable ELF modules - #19778
Merged
Merged
Conversation
Implement architecture-specific ELF header definitions and relocation handling for the MIPS architecture to enable loadable modules. Fixes apache#19178. Changes include: - Add `arch/mips/include/elf.h` with MIPS ELF relocation types and architecture-specific ELF data structures (`arch_elfdata_s`). - Implement `libs/libc/machine/mips/arch_elf.c` containing `up_checkarch`, `up_relocate`, and `up_relocateadd` functions handling `R_MIPS_NONE`, `R_MIPS_32`, `R_MIPS_26`, `R_MIPS_HI16`, and `R_MIPS_LO16` relocations. - Integrate MIPS machine-specific C library support in `libs/libc/machine/mips/Make.defs`. - Update `LDMODULEFLAGS` in `arch/mips/src/mips32/Toolchain.defs` to include the little-endian (`-EL`) flag. - Update `up_coherent_dcache` for proper cache synchronization on JZ4780. Signed-off-by: Lwazi Dube <lwazeh@gmail.com>
ldube
requested review from
Ouss4,
jerpelea and
xiaoxiang781216
as code owners
August 10, 2026 23:29
xiaoxiang781216
approved these changes
Aug 11, 2026
1 task
acassis
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement architecture-specific ELF header definitions and relocation handling for the MIPS architecture to enable loadable modules.
Fixes #19178.
Changes include:
arch/mips/include/elf.hwith MIPS ELF relocation types and architecture-specific ELF data structures (arch_elfdata_s).libs/libc/machine/mips/arch_elf.ccontainingup_checkarch,up_relocate, andup_relocateaddfunctions handlingR_MIPS_NONE,R_MIPS_32,R_MIPS_26,R_MIPS_HI16, andR_MIPS_LO16relocations.libs/libc/machine/mips/Make.defs.LDMODULEFLAGSinarch/mips/src/mips32/Toolchain.defsto include the little-endian (-EL) flag.up_coherent_dcachefor proper cache synchronization on JZ4780.Note: Please adhere to Contributing Guidelines.
Testing
Enable the Module Example and set /dev/sda as the Block driver device path
Build nuttx. (Build used to fail before this change)
Copy ./apps/bin/chardev formated USB stick (chardev is created when nuttx is built)
Plug stick into CI20 USB port
Boot the nuttx image on the CI20 and run "module" to test.