@@ -116,8 +116,7 @@ static int llext_manager_load_data_from_storage(const struct llext *ext,
116116 return ret ;
117117}
118118
119- static int llext_manager_load_module (const struct llext * ext , const struct llext_buf_loader * ebl ,
120- const struct lib_manager_module * mctx )
119+ static int llext_manager_load_module (const struct lib_manager_module * mctx )
121120{
122121 /* Executable code (.text) */
123122 void __sparse_cache * va_base_text = (void __sparse_cache * )
@@ -144,13 +143,15 @@ static int llext_manager_load_module(const struct llext *ext, const struct llext
144143 if (bss_size &&
145144 ((uintptr_t )bss_addr + bss_size <= (uintptr_t )va_base_data ||
146145 (uintptr_t )bss_addr >= (uintptr_t )va_base_data + data_size )) {
146+ size_t bss_align = MIN (PAGE_SZ , BIT (__builtin_ctz ((uintptr_t )bss_addr )));
147+
147148 if ((uintptr_t )bss_addr + bss_size == (uintptr_t )va_base_data &&
148149 !((uintptr_t )bss_addr & (PAGE_SZ - 1 ))) {
149150 /* .bss directly in front of writable data and properly aligned, prepend */
150151 va_base_data = bss_addr ;
151152 data_size += bss_size ;
152153 } else if ((uintptr_t )bss_addr == (uintptr_t )va_base_data +
153- ALIGN_UP (data_size , ebl -> loader . sects [ LLEXT_MEM_BSS ]. sh_addralign )) {
154+ ALIGN_UP (data_size , bss_align )) {
154155 /* .bss directly behind writable data, append */
155156 data_size += bss_size ;
156157 } else {
@@ -161,6 +162,8 @@ static int llext_manager_load_module(const struct llext *ext, const struct llext
161162 }
162163 }
163164
165+ const struct llext * ext = mctx -> llext ;
166+
164167 /* Copy Code */
165168 ret = llext_manager_load_data_from_storage (ext , va_base_text , ext -> mem [LLEXT_MEM_TEXT ],
166169 text_size , SYS_MM_MEM_PERM_EXEC );
@@ -341,8 +344,7 @@ static unsigned int llext_manager_mod_find(const struct lib_manager_mod_ctx *ctx
341344}
342345
343346static int llext_manager_link_single (uint32_t module_id , const struct sof_man_fw_desc * desc ,
344- struct lib_manager_mod_ctx * ctx , struct llext_buf_loader * ebl ,
345- const void * * buildinfo ,
347+ struct lib_manager_mod_ctx * ctx , const void * * buildinfo ,
346348 const struct sof_man_module_manifest * * mod_manifest )
347349{
348350 struct sof_man_module * mod_array = (struct sof_man_module * )((uint8_t * )desc +
@@ -404,17 +406,15 @@ static int llext_manager_link_single(uint32_t module_id, const struct sof_man_fw
404406 PAGE_SZ );
405407
406408 uintptr_t dram_base = (uintptr_t )desc - SOF_MAN_ELF_TEXT_OFFSET ;
407-
408- * ebl = (struct llext_buf_loader )LLEXT_BUF_LOADER ((uint8_t * )dram_base + mod_offset ,
409- mod_size );
409+ struct llext_buf_loader ebl = LLEXT_BUF_LOADER ((uint8_t * )dram_base + mod_offset , mod_size );
410410
411411 /*
412412 * LLEXT linking is only needed once for all the "drivers" in the
413413 * module. This calls llext_load(), which also takes references to any
414414 * dependencies, sets up sections and retrieves buildinfo and
415415 * mod_manifest
416416 */
417- ret = llext_manager_link (ebl , mod_array [entry_index - inst_idx ].name , mctx ,
417+ ret = llext_manager_link (& ebl , mod_array [entry_index - inst_idx ].name , mctx ,
418418 buildinfo , mod_manifest );
419419 if (ret < 0 ) {
420420 tr_err (& lib_manager_tr , "linking failed: %d" , ret );
@@ -457,10 +457,9 @@ uintptr_t llext_manager_allocate_module(const struct comp_ipc_config *ipc_config
457457 /* Array of all "module drivers" (manifests) in the library */
458458 const struct sof_man_module_manifest * mod_manifest ;
459459 const struct sof_module_api_build_info * buildinfo = NULL ;
460- struct llext_buf_loader ebl ;
461460
462461 /* "module file" index in the ctx->mod array */
463- int mod_ctx_idx = llext_manager_link_single (module_id , desc , ctx , & ebl ,
462+ int mod_ctx_idx = llext_manager_link_single (module_id , desc , ctx ,
464463 (const void * * )& buildinfo , & mod_manifest );
465464
466465 if (mod_ctx_idx < 0 )
@@ -477,7 +476,7 @@ uintptr_t llext_manager_allocate_module(const struct comp_ipc_config *ipc_config
477476 }
478477
479478 /* Map executable code and data */
480- int ret = llext_manager_load_module (mctx -> llext , & ebl , mctx );
479+ int ret = llext_manager_load_module (mctx );
481480
482481 if (ret < 0 )
483482 return 0 ;
0 commit comments