Skip to content

Commit

Permalink
Use const operand in the ARM branch
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Dec 27, 2024
1 parent 49a0c3f commit 807534e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/backends/linux_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
// Based on `rustix` and `linux-raw-sys` code.
cfg_if! {
if #[cfg(target_arch = "arm")] {
const __NR_getrandom: u32 = 384;
// In thumb-mode, r7 is the frame pointer and is not permitted to be used in
// an inline asm operand, so we have to use a different register and copy it
// into r7 inside the inline asm.
Expand All @@ -21,9 +22,10 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
// bother with it.
core::arch::asm!(
"mov {tmp}, r7",
"mov r7, #384", // __NR_getrandom = 384
"mov r7, {nr}",
"svc 0",
"mov r7, {tmp}",
nr = const __NR_getrandom,
tmp = out(reg) _,
inlateout("r0") buf => r0,
in("r1") buflen,
Expand Down

0 comments on commit 807534e

Please sign in to comment.