Skip to content

Commit f5ae4d2

Browse files
authored
Merge pull request #3310 from tonyzheng-rockchip/fix-dlmodule
Fix dlmodule
2 parents 1f8c3e5 + aa27c3f commit f5ae4d2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

components/libc/libdl/dlelf.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,40 @@ rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_pt
226226
length);
227227
count ++;
228228
}
229+
230+
/* get priority & stack size params*/
231+
rt_uint32_t flag = 0;
232+
rt_uint16_t priority;
233+
rt_uint32_t stacksize;
234+
for (i = 0; i < shdr[index].sh_size / sizeof(Elf32_Sym); i++)
235+
{
236+
if (((flag & 0x01) == 0) &&
237+
(rt_strcmp((const char *)(strtab + symtab[i].st_name), "dlmodule_thread_priority") == 0))
238+
{
239+
flag |= 0x01;
240+
priority = *(rt_uint16_t*)(module->mem_space + symtab[i].st_value - module->vstart_addr);
241+
if (priority < RT_THREAD_PRIORITY_MAX)
242+
{
243+
module->priority = priority;
244+
}
245+
}
246+
247+
if (((flag & 0x02) == 0) &&
248+
(rt_strcmp((const char *)(strtab + symtab[i].st_name), "dlmodule_thread_stacksize") == 0))
249+
{
250+
flag |= 0x02;
251+
stacksize = *(rt_uint32_t*)(module->mem_space + symtab[i].st_value - module->vstart_addr);
252+
if ((stacksize < 2048) || (stacksize > 1024 * 32))
253+
{
254+
module->stack_size = stacksize;
255+
}
256+
}
257+
258+
if ((flag & 0x03) == 0x03)
259+
{
260+
break;
261+
}
262+
}
229263
}
230264

231265
return RT_EOK;

0 commit comments

Comments
 (0)