From cbef04a6da6ced84e99b092a55867594a6f8d095 Mon Sep 17 00:00:00 2001 From: laidene <228526434@qq.com> Date: Mon, 15 Dec 2025 14:04:50 +0800 Subject: [PATCH] [components][libc][posix][libdl] Optimization: Redundant calculations in a for loop --- components/libc/posix/libdl/dlelf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/libc/posix/libdl/dlelf.c b/components/libc/posix/libdl/dlelf.c index 4fc89e5aaa6..24d82d73b4a 100644 --- a/components/libc/posix/libdl/dlelf.c +++ b/components/libc/posix/libdl/dlelf.c @@ -209,12 +209,12 @@ rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_pt } /* construct module symbol table */ + rt_uint8_t *shstrab; + shstrab = (rt_uint8_t *)module_ptr + + shdr[elf_module->e_shstrndx].sh_offset; for (index = 0; index < elf_module->e_shnum; index ++) { /* find .dynsym section */ - rt_uint8_t *shstrab; - shstrab = (rt_uint8_t *)module_ptr + - shdr[elf_module->e_shstrndx].sh_offset; if (rt_strcmp((const char *)(shstrab + shdr[index].sh_name), ELF_DYNSYM) == 0) break; }