Use an unaligned write for resolving libcall relocations (#6147)
This commit changes resolution of libcall relocations from writing a `usize` into a raw pointer to specifically performing an unaligned write. The addresses of libcalls to write to are not guaranteed to be aligned, so this could technically have caused issues on some platforms perhaps. This was discovered now that Rust nightly will panic on unaligned writes to pointers, and fuzzing ran into this case when compiled with a more recent Nightly build.
This commit is contained in:
@@ -299,7 +299,11 @@ impl CodeMemory {
|
||||
obj::LibCall::FmaF32 => libcalls::relocs::fmaf32 as usize,
|
||||
obj::LibCall::FmaF64 => libcalls::relocs::fmaf64 as usize,
|
||||
};
|
||||
*self.mmap.as_mut_ptr().add(offset).cast::<usize>() = libcall;
|
||||
self.mmap
|
||||
.as_mut_ptr()
|
||||
.add(offset)
|
||||
.cast::<usize>()
|
||||
.write_unaligned(libcall);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user