ITADN

Properly address main binary globals when loading DSLs

#203Pull Requesttrustytrojan 创建于 2026-03-04
T
trustytrojancommented
The `.gitignore` and `.gitmodules` changes were for my convenience (I couldn't clone the repo without changing `.gitmodules`). If needed I can revert those changes. ## Summary **Problem Found:** The `R_ARM_ABS32`/`R_ARM_TARGET1` relocation handling in `dlfcn.c` was **not checking if symbols came from the main binary**. It unconditionally added the `loaded_mem` offset to all absolute address relocations, which caused globals from the main binary to be treated as library-relative addresses. **The Issue:** - When `dsltool` processes a DSL file with symbols from the main binary, it marks them with `DSL_SYMBOL_MAIN_BINARY` and stores the **absolute address** from the main binary in the symbol table - The original code didn't distinguish between: - Library-internal symbols (need relocation by adding `loaded_mem`) - Main binary symbols (already absolute, should NOT be adjusted) **The Fix:** I updated the `R_ARM_ABS32`/`R_ARM_TARGET1` handler to: 1. Look up the symbol being relocated 2. Check if it has the `DSL_SYMBOL_MAIN_BINARY` flag 3. If it's from the main binary, use the address directly 4. If it's internal to the library, add the `loaded_mem` offset (as before) This now matches the pattern already used by `R_ARM_THM_CALL`, `R_ARM_JUMP24`, and `R_ARM_CALL` relocations.
合并状态:未合并 关闭于 2026-03-07 1 条评论