xiaojun zheng created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1585

Project:Branches: zhengxiaojun/rtems:fix_libdl_for_64bit to 
rtems/rtos/rtems:main
Author: xiaojun zheng

## Summary

libdl: Fix 32-bit address truncation to prepare 64-bit ELF support

Problem
The run-time loader (libdl) fails to load ELF objects on 64-bit targets. The 
loader's internal word type rtems_rtl_word is defined as uint32_t, and 
address-carrying fields such as rtems_rtl_unresolv_symbol::symvalue are typed 
as Elf_Word. Elf_Word is 32-bit in both the ELF32 and ELF64 formats, so 64-bit 
addresses are silently truncated to 32 bits, which eventually leads to 
corrupted relocations and load failures.

Solution
This MR retypes the word and symbol value handling to follow the ELF class 
address size. The changes are split into three commits, each of which is a 
no-op on 32-bit targets:

    libdl: Change rtems_rtl_word to uintptr_t — Widen the loader's internal 
word type so it matches the machine word size. No functional change on 32-bit 
targets.
    libdl: Use Elf_Addr for symbol values in the ELF loader — Change the symbol 
value handling in rtl-elf.c and the relocation handler prototypes in rtl-elf.h 
from Elf_Word to Elf_Addr. Relocation types are not addresses and keep the 
Elf_Word type.
    libdl: Use Elf_Addr for symbol values in arch relocation files — Mechanical 
signature update across all rtl-mdreloc-*.c files to match the new prototypes. 
No relocation logic is modified.

Testing

    ELF objects load successfully on aarch64 (tested on an RK3576-based board).

Notes

    This series does not claim full 64-bit ELF loading support. ELF64 parsing 
(e.g. Elf64_Shdr handling in rtl-elf.c) and the aarch64 relocation logic are 
subject to follow-up work.
    The MIPS64 relocation layout differs from ELF32 (three relocation types are 
packed in r_info) and requires a dedicated adaptation, which is out of scope 
here.

See #5816.

## Generative AI
None

<!-- If you have used AI please use the "AI Contribution" template otherwise 
leave this blank see our fulls statement at 
https://www.rtems.org/generative-ai/-->


<!-- Default settings, if it is a dropdown it will set after submission -->

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1585
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-bou4hjsq3iu8cec0jfruu5xjo-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to