Skip to content

Commit

Permalink
llext: fix flag evaluation for section grouping
Browse files Browse the repository at this point in the history
When deciding which sections to group together, only the low 3
section attribute bits are relevant, ignore the rest.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh committed Aug 29, 2024
1 parent 9a1f217 commit b2114ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/zephyr/llext/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ struct elf64_shdr {
#define SHF_ALLOC 0x2 /**< Section is present in memory */
#define SHF_EXECINSTR 0x4 /**< Section contains executable instructions */

#define SHF_BASIC_TYPE_MASK (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR)

/**
* @brief Symbol table entry(32-bit)
*/
Expand Down
6 changes: 4 additions & 2 deletions subsys/llext/llext_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ static int llext_map_sections(struct llext_loader *ldr, struct llext *ext)
memcpy(region, shdr, sizeof(*region));
} else {
/* Make sure this section is compatible with the region */
if (shdr->sh_flags != region->sh_flags) {
LOG_ERR("Unsupported section flags for %s (region %d)",
if ((shdr->sh_flags & SHF_BASIC_TYPE_MASK) !=
(region->sh_flags & SHF_BASIC_TYPE_MASK)) {
LOG_ERR("Unsupported section flags %#x / %#x for %s (region %d)",
(uint32_t)shdr->sh_flags, (uint32_t)region->sh_flags,
name, mem_idx);
return -ENOEXEC;
}
Expand Down

0 comments on commit b2114ea

Please sign in to comment.