Skip to content

Justification around nomem specifier #494

Description

@conradludgate

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions