Skip to content

Commit 411e131

Browse files
committed
llext: fix no-data case
If a module has .bss and no .data the sanity check will fail. Add a check for that case. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 0187fc5 commit 411e131

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/library_manager/llext_manager.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,12 @@ static int llext_manager_load_module(struct lib_manager_module *mctx)
227227
(uintptr_t)bss_addr >= (uintptr_t)va_base_data + data_size)) {
228228
size_t bss_align = MIN(PAGE_SZ, BIT(__builtin_ctz((uintptr_t)bss_addr)));
229229

230-
if ((uintptr_t)bss_addr + bss_size == (uintptr_t)va_base_data &&
231-
!((uintptr_t)bss_addr & (PAGE_SZ - 1))) {
232-
/* .bss directly in front of writable data and properly aligned, prepend */
230+
if ((!data_size || (uintptr_t)bss_addr + bss_size == (uintptr_t)va_base_data) &&
231+
bss_align >= PAGE_SZ) {
232+
/*
233+
* .bss is properly aligned and either there's no writable data,
234+
* or .bss is directly in front of writable data, prepend .bss
235+
*/
233236
va_base_data = bss_addr;
234237
data_size += bss_size;
235238
} else if ((uintptr_t)bss_addr == (uintptr_t)va_base_data +

0 commit comments

Comments
 (0)