diff options
| author | Bernard Xiong <[email protected]> | 2020-01-07 08:10:15 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-01-07 08:10:15 +0800 |
| commit | f5ae4d2fc3a6968c1168d953262802a7ccbbccfd (patch) | |
| tree | 3f51b2f35fd6cfff8334c40b00b9a9557482522e | |
| parent | 1f8c3e5e56965425066f8f78f9ffecee289249e0 (diff) | |
| parent | aa27c3f986ded8cb1b7ea3adc216cf6f7732093d (diff) | |
Merge pull request #3310 from tonyzheng-rockchip/fix-dlmodule
Fix dlmodule
| -rw-r--r-- | components/libc/libdl/dlelf.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/components/libc/libdl/dlelf.c b/components/libc/libdl/dlelf.c index 1265ffcb07..55ef0d8951 100644 --- a/components/libc/libdl/dlelf.c +++ b/components/libc/libdl/dlelf.c @@ -226,6 +226,40 @@ rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_pt length); count ++; } + + /* get priority & stack size params*/ + rt_uint32_t flag = 0; + rt_uint16_t priority; + rt_uint32_t stacksize; + for (i = 0; i < shdr[index].sh_size / sizeof(Elf32_Sym); i++) + { + if (((flag & 0x01) == 0) && + (rt_strcmp((const char *)(strtab + symtab[i].st_name), "dlmodule_thread_priority") == 0)) + { + flag |= 0x01; + priority = *(rt_uint16_t*)(module->mem_space + symtab[i].st_value - module->vstart_addr); + if (priority < RT_THREAD_PRIORITY_MAX) + { + module->priority = priority; + } + } + + if (((flag & 0x02) == 0) && + (rt_strcmp((const char *)(strtab + symtab[i].st_name), "dlmodule_thread_stacksize") == 0)) + { + flag |= 0x02; + stacksize = *(rt_uint32_t*)(module->mem_space + symtab[i].st_value - module->vstart_addr); + if ((stacksize < 2048) || (stacksize > 1024 * 32)) + { + module->stack_size = stacksize; + } + } + + if ((flag & 0x03) == 0x03) + { + break; + } + } } return RT_EOK; |
