This crate specifies nomem in the asm!(), and casts pointers to usize.
|
options(nomem, nostack, preserves_flags) |
|
quote! { .as_ptr() as usize }, |
The inline assembly docs specify
The assembly code does not read from or write to any memory accessible outside of the assembly code. This allows the compiler to cache the values of modified global variables in registers across execution of the assembly code since it knows that they are not read from or written to by it.
It's quite clear that reading from a pointer value when nomem is set is UB. The probe function would necessarily need to read the pointer when tracing.
Wouldn't it be more appropriate to use readonly?
Thanks
This crate specifies
nomemin theasm!(), and casts pointers tousize.usdt/usdt-impl/src/no-linker.rs
Line 112 in 4329591
usdt/usdt-impl/src/common.rs
Line 182 in 4329591
The inline assembly docs specify
It's quite clear that reading from a pointer value when
nomemis set is UB. The probe function would necessarily need to read the pointer when tracing.Wouldn't it be more appropriate to use
readonly?Thanks