summaryrefslogtreecommitdiff
path: root/components/libc/posix/libdl
AgeCommit message (Collapse)Author
2026-04-14[libc][libdl] Fix dlopen() failing to find already-loaded modulesCopilot
2026-03-12components: libc: fix reset static variable unsolved in ↵kenneth.liu
dlmodule_load_shared_object [Problem Description] In the dlmodule_load_shared_object function, if a module loading fails once due to an unresolved symbol, all subsequent attempts to load any module will fail. The system becomes unable to load modules correctly until a reboot. [Problem Analysis] The root cause is that the variable unsolved is defined as static. Static variables retain their value between function calls. If a relocation error occurs, unsolved is set to RT_TRUE. However, when the function returns with an error, the value of unsolved is not reset. Consequently, on the next function call, unsolved remains RT_TRUE from the previous execution. This causes the check if (unsolved) to trigger immediately (or after the loop), forcing the function to return an error regardless of whether the current module is valid or not. [Solution] Reset the unsolved variable to RT_FALSE before returning the error code -RT_ERROR. This ensures the variable is in a clean state for the next function call, preventing state leakage between invocations. Signed-off-by: Liu Gui <[email protected]>
2025-12-18[components][libc][posix][libdl] Optimization: Redundant calculations in a ↵laidene
for loop
2025-11-16Reorganize Group names in build system for clarity and IDE integration #10923Copilot
2025-02-22components: libc: fix pointer-to-integer cast warnings and address truncationkenneth.liu
[Problem Description] 1. When enabling RT_USING_MODULE=y, compilation warnings occur: dlelf.c:386:27: warning: cast from pointer to integer of different size dlelf.c:398:25: warning: cast from pointer to integer of different size dlelf.c:408:24: warning: cast from pointer to integer of different size 2. On RV64 architectures (e.g. Sophgo SG2042 with RISC-V Sv39 and 40-bit physical addressing), dlsym may fail when accessing addresses beyond 32-bit range. [Root Cause] In dlmodule_load_relocated_object() and dlmodule_symbol_find(), pointer is cast to rt_uint32_t which truncates: | rt_ubase_t rodata_addr = (rt_uint32_t)ptr; This causes: - Warnings on 64-bit systems (pointer width > 32-bit) - Actual address truncation on RV64 when physical address exceeds 32-bit [Solution] Replace rt_uint32_t with architecture-adaptive rt_ubase_t: | rt_ubase_t rodata_addr = (rt_ubase_t)ptr; The rt_ubase_t is defined in include/rttypes.h as: | #ifdef ARCH_CPU_64BIT | typedef rt_uint64_t rt_ubase_t; | #else | typedef rt_uint32_t rt_ubase_t; | #endif This ensures correct width casting for both 32/64-bit architectures. Signed-off-by: Liu Gui <[email protected]>
2025-02-20components: libc: fix array overflow in rt_object name assignmentkenneth.liu
[Problem Description] When assigning name to rt_object, strncpy() uses size equal to RT_NAME_MAX, which causes missing null-terminator and overflows into adjacent 'type' field. This corruption leads to unexpected system behavior. [Problem Analysis] The rt_object structure defines: | char name[RT_NAME_MAX] | -> buffer | rt_uint8_t type | -> adjacent field Original code calculates size as: size = end - first + 1; if (size > RT_NAME_MAX) size = RT_NAME_MAX; When size equals RT_NAME_MAX, strncpy() will copy exactly RT_NAME_MAX bytes without adding terminating '\0', causing two issues: 1. name buffer is not null-terminated 2. The implicit null-byte writes beyond name[] into type field [Solution] Change boundary check from: if (size > RT_NAME_MAX) size = RT_NAME_MAX; to: if (size >= RT_NAME_MAX) size = RT_NAME_MAX - 1; This ensures: 1. Always leaves space for null-terminator 2. Prevents overflow into type field 3. Maintains maximum valid name length (RT_NAME_MAX-1 + '\0') Signed-off-by: Liu Gui <[email protected]>
2024-11-13[libc] add comments for libdl APIs.ligr
2024-06-26fix Compilation error in "driver.c", "completion_up.c", "syslog.c" and ↵Rui
"dlmodule.c". (#9093)
2024-05-01[kernel] add rt_thread_close()Shell
* [thread] Add rt_thread_close() This patch introduces a new function `rt_thread_close()` to enhances the usability and maintainability by providing a dedicated mechanism for closing threads. - A new function `rt_thread_close()` is added to the API, providing a standardized approach for closing threads. - The `rt_thread_close()` function removes a thread from the thread queue, updates its status to indicate closure, and performs the thread timer detaching which is a embedded timer in thread object. - Additionally, the `rt_thread_detach()` function is modified to utilize `rt_thread_close()` internally, streamlining the thread detachment process. Signed-off-by: Shell <[email protected]>
2024-02-23🎯 Sync smart & scheduler codes (#8537)Shell
Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2023-07-09[debug] remove RT_DEBUG_xxxMeco Man
remove RT_DEBUG_THREAD RT_DEBUG_SCHEDULER RT_DEBUG_IPC RT_DEBUG_TIMER RT_DEBUG_IRQ RT_DEBUG_MEM RT_DEBUG_SLAB RT_DEBUG_MEMHEAP
2023-06-29[include][dbg]update: no longer use RT_DEBUG_LOG in rtdebug.h (#7750)Shicheng Chu
2023-04-04[kernel] 将rt_thread结构体改为显式继承rt_object (#7131)Shicheng Chu
2022-06-09[Scons] ↵Meco Man
将GCC判断条件改为列表方式,方便后续增加新的编译工具链
2022-05-09[fix] fix dlmodule compile 'SEEK_END' undeclared eror (#5909)陈迎春
2022-02-17[dmodule] 补充头文件 (#5602)Man, Jianting (Meco)
* add references * [dmodule] add <fcntl.h>
2022-01-24[posix][io]整理posix/io文件夹 (#5539)Man, Jianting (Meco)
* [posix][io]整理posix/io文件夹 - 将select.c移入到poll文件夹 - 将libc.c移入到tty文件夹,isatty函数归并到libc.c中, termios并入tty文件夹中 - 整理Sconscript Signed-off-by: Meco Man <[email protected]> * [libc][newlib]调整文件夹结构
2022-01-20[libdl] move libdl to posix folder (#5523)Man, Jianting (Meco)