diff --git a/binfmt/libelf/libelf_load.c b/binfmt/libelf/libelf_load.c index 2a6be23bc6..44986b8f5e 100644 --- a/binfmt/libelf/libelf_load.c +++ b/binfmt/libelf/libelf_load.c @@ -96,7 +96,11 @@ static void elf_elfsize(FAR struct elf_loadinfo_s *loadinfo) * able */ - if ((shdr->sh_flags & SHF_WRITE) != 0) + if ((shdr->sh_flags & SHF_WRITE) != 0 +#ifdef CONFIG_ARCH_HAVE_TEXT_HEAP_WORD_ALIGNED_READ + || (shdr->sh_flags & SHF_EXECINSTR) == 0 +#endif + ) { datasize = _ALIGN_UP(datasize, shdr->sh_addralign); datasize += ELF_ALIGNUP(shdr->sh_size); @@ -200,7 +204,11 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo) * able */ - if ((shdr->sh_flags & SHF_WRITE) != 0) + if ((shdr->sh_flags & SHF_WRITE) != 0 +#ifdef CONFIG_ARCH_HAVE_TEXT_HEAP_WORD_ALIGNED_READ + || (shdr->sh_flags & SHF_EXECINSTR) == 0 +#endif + ) { pptr = &data; } diff --git a/libs/libc/machine/xtensa/arch_elf.c b/libs/libc/machine/xtensa/arch_elf.c index b1dcf6abe1..3e7558b2de 100644 --- a/libs/libc/machine/xtensa/arch_elf.c +++ b/libs/libc/machine/xtensa/arch_elf.c @@ -29,6 +29,7 @@ #include #include +#include #include /**************************************************************************** @@ -200,7 +201,7 @@ int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym, break; case R_XTENSA_SLOT0_OP: - p = (unsigned char *)addr; + p = (unsigned char *)up_textheap_data_address((void *)addr); if (is_l32r(p)) { /* Xtensa ISA: diff --git a/libs/libc/modlib/modlib_load.c b/libs/libc/modlib/modlib_load.c index d6772d5cca..8e1200863f 100644 --- a/libs/libc/modlib/modlib_load.c +++ b/libs/libc/modlib/modlib_load.c @@ -112,7 +112,11 @@ static void modlib_elfsize(FAR struct mod_loadinfo_s *loadinfo) * able */ - if ((shdr->sh_flags & SHF_WRITE) != 0) + if ((shdr->sh_flags & SHF_WRITE) != 0 +#ifdef CONFIG_ARCH_HAVE_TEXT_HEAP_WORD_ALIGNED_READ + || (shdr->sh_flags & SHF_EXECINSTR) == 0 +#endif + ) { datasize = _ALIGN_UP(datasize, shdr->sh_addralign); datasize += ELF_ALIGNUP(shdr->sh_size); @@ -214,7 +218,11 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo) * able */ - if ((shdr->sh_flags & SHF_WRITE) != 0) + if ((shdr->sh_flags & SHF_WRITE) != 0 +#ifdef CONFIG_ARCH_HAVE_TEXT_HEAP_WORD_ALIGNED_READ + || (shdr->sh_flags & SHF_EXECINSTR) == 0 +#endif + ) { pptr = &data; }