Skip to content

Commit b2114ea

Browse files
committed
llext: fix flag evaluation for section grouping
When deciding which sections to group together, only the low 3 section attribute bits are relevant, ignore the rest. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent 9a1f217 commit b2114ea

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/zephyr/llext/elf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ struct elf64_shdr {
212212
#define SHF_ALLOC 0x2 /**< Section is present in memory */
213213
#define SHF_EXECINSTR 0x4 /**< Section contains executable instructions */
214214

215+
#define SHF_BASIC_TYPE_MASK (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR)
216+
215217
/**
216218
* @brief Symbol table entry(32-bit)
217219
*/

subsys/llext/llext_load.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,10 @@ static int llext_map_sections(struct llext_loader *ldr, struct llext *ext)
253253
memcpy(region, shdr, sizeof(*region));
254254
} else {
255255
/* Make sure this section is compatible with the region */
256-
if (shdr->sh_flags != region->sh_flags) {
257-
LOG_ERR("Unsupported section flags for %s (region %d)",
256+
if ((shdr->sh_flags & SHF_BASIC_TYPE_MASK) !=
257+
(region->sh_flags & SHF_BASIC_TYPE_MASK)) {
258+
LOG_ERR("Unsupported section flags %#x / %#x for %s (region %d)",
259+
(uint32_t)shdr->sh_flags, (uint32_t)region->sh_flags,
258260
name, mem_idx);
259261
return -ENOEXEC;
260262
}

0 commit comments

Comments
 (0)