modlib: Implement sh_addralign handling

I've seen a module with 16 bytes .rodata alignment for xmm operations.
It was getting SEGV on sim/Linux because of the alignment issue.
The same module binary seems working fine after applying this patch.

Also, tested on sim/macOS and esp32 on qemu,
using a module with an artificially large alignment. (64 bytes)
This commit is contained in:
YAMAMOTO Takashi
2021-04-14 17:07:39 +09:00
committed by Xiang Xiao
parent 7813b4f88a
commit 51490bad55
5 changed files with 51 additions and 12 deletions
+3 -3
View File
@@ -730,15 +730,15 @@ void up_module_text_init(void);
#endif
/****************************************************************************
* Name: up_module_text_alloc
* Name: up_module_text_memalign
*
* Description:
* Allocate memory for module text.
* Allocate memory for module text with the specified alignment.
*
****************************************************************************/
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
FAR void *up_module_text_alloc(size_t size);
FAR void *up_module_text_memalign(size_t align, size_t size);
#endif
/****************************************************************************
+2
View File
@@ -198,6 +198,8 @@ struct mod_loadinfo_s
uintptr_t datastart; /* Start of.bss/.data memory in .text allocation */
size_t textsize; /* Size of the module .text memory allocation */
size_t datasize; /* Size of the module .bss/.data memory allocation */
size_t textalign; /* Necessary alignment of .text */
size_t dataalign; /* Necessary alignment of .bss/.text */
off_t filelen; /* Length of the entire module file */
Elf_Ehdr ehdr; /* Buffered module file header */
FAR Elf_Shdr *shdr; /* Buffered module section headers */