ld_so: remove unsafe transmute in mmap_and_copy

Refactors casting the `raw` address as a byte array to use idiomatic
Rust APIs instead of the unsafe call to `transmute`.
This commit is contained in:
elle
2025-09-07 20:04:28 +00:00
parent 7e0c6a91e0
commit 09015a218e
+1 -1
View File
@@ -618,7 +618,7 @@ impl DSO {
let (ph, _) = dynamic.unwrap();
let vaddr = ph.p_vaddr(endian) as usize;
let bytes: [u8; size_of::<Dyn>() / 2] =
unsafe { core::mem::transmute((&_r_debug) as *const RTLDDebug as usize) };
((&raw const _r_debug).cast::<*const RTLDDebug>() as usize).to_ne_bytes();
let start = if is_pie_enabled(elf) {
vaddr + i * size_of::<Dyn>() + size_of::<Dyn>() / 2
} else {