Skip to content

Commit 4b09c11

Browse files
committed
llext: disable ELF buffer reuse on MPU/MMU builds
This PR adds a new CONFIG_LLEXT_HW_MEMORY_CHECKS hidden option to the LLEXT Kconfig, which is enabled by default on builds where memory is managed by an MPU, MMU or RISC-V PMP, and which may impose additional alignment or access restrictions to the LLEXT memory regions. This is used to disable the optimization that allows reuse of the ELF buffer on such builds, since the ELF sections would certainly not be aligned properly. Signed-off-by: Luca Burelli <[email protected]>
1 parent 4f4b39c commit 4b09c11

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

subsys/llext/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ menuconfig LLEXT
1010

1111
if LLEXT
1212

13+
config LLEXT_HW_MEMORY_CHECKS
14+
bool
15+
default y if MPU || MMU || RISCV_PMP
16+
1317
choice LLEXT_BINARY_TYPE
1418
prompt "Binary object type for llext"
1519
default LLEXT_TYPE_ELF_OBJECT if ARM || ARM64

subsys/llext/llext_mem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static int llext_copy_region(struct llext_loader *ldr, struct llext *ext,
7070
ext->mem_size[mem_idx] = region->sh_size;
7171

7272
if (region->sh_type != SHT_NOBITS &&
73+
!IS_ENABLED(CONFIG_LLEXT_HW_MEMORY_CHECKS) &&
7374
IS_ENABLED(CONFIG_LLEXT_STORAGE_WRITABLE)) {
7475
/* Directly use data from the ELF buffer if peek() is supported */
7576
ext->mem[mem_idx] = llext_peek(ldr, region->sh_offset);

0 commit comments

Comments
 (0)