You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Report error when using naked functions with arguments
As mentioned in issue: rust-lang#42779
a naked function with arguments will cause LLVM to generate some
prologue code for the arguments. This goes against the idea of a naked
function and can cause difficult to diagnose bugs.
The current situation is wrong and leaves users exposed to nasty bugs.
There are two possible solutions:
1. Not allow any naked functions to have arguments. This is the method
taken by this patch.
2. Modify LLVM to not generate any prologue code for naked functions.
This seems like a more controversial change as it will impact all
LLVM users and I am not sure how other languages will handle this.
It seems unlikely that there are many naked functions that don't call
inline assembly as the first or only code in the function. In which case
the inline assembly can assess the registers used to pass arguments
still allowing arguments to be passed to naked functions.
Rust shouldn't be calling naked functions [1] so this is unlikely to be
a major concern.
1: https://github.com/rust-lang/rfcs/blob/master/text/1201-naked-fns.md
"Because the calling convention of a naked function is not guaranteed
to match any calling convention the compiler is compatible with, calls
to naked functions from within Rust code are forbidden unless the function
is also declared with a well-defined ABI."
Signed-off-by: Alistair Francis <[email protected]>
0 commit comments