objtool/rust: add one more `noreturn` Rust function
Miguel Ojeda
maintainerPATCH 1/1 objtool/rust: add one more `noreturn` Rust function
When the pointer formatting series [1] is applied and KUnit tests are enabled, objtool would report an error with any of our supported Rust versions. For instance, with Rust 1.97.1:
rust/kernel.o: error: objtool: _R..._4core3fmt7Pointer3fmtB7_() falls through to next function _R..._4core7convert5AsRefNtB5_4BStrE6as_ref()
Or, with Rust 1.85.0:
rust/kernel.o: error: objtool: _R..._4core3fmt7Pointer3fmtB7_()
falls through to next function _R..._4core3ffi5c_str4CStrENtNtBS_3fmt7Display3fmtB7_()
This happens due to calls to the noreturn symbol:
core::str::slice_error_fail
Thus add the mangled one to the list so that objtool knows it is actually noreturn.
See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -195,6 +195,7 @@ static bool is_rust_noreturn(const struct symbol *func)return str_ends_with (func->name,"_4core3num20from_str_radix_panic" ) ||str_ends_with (func->name,"_4core3num22from_ascii_radix_panic" ) ||str_ends_with (func->name,"_4core3num28from_ascii_bytes_radix_panic" ) || +str_ends_with (func->name,"_4core3str16slice_error_fail" ) ||str_ends_with (func->name,"_4core5sliceSp15copy_from_slice17len_mismatch_fail" ) ||str_ends_with (func->name,"_4core6option13expect_failed" ) || str_ends_with(func->name, "_4core6option13unwrap_failed") ||
base-commit: dc01dfb37b34beeefcfe1c3055364d41a4070c7e
Signature · 1 line
2.55.0
Quoted 4 lines · Miguel Ojeda
When the pointer formatting series [1] is applied and KUnit tests are enabled,
objtoolwould report an error with any of our supported Rust versions. For instance, with Rust 1.97.1:
With the version that I applied of that series, this was not strictly needed anymore.
Cheers,
Miguel
Gary Guo
reviewerQuoted 8 lines · Miguel Ojeda
Quoted 4 lines · Miguel Ojeda
When the pointer formatting series [1] is applied and KUnit tests are enabled,
objtoolwould report an error with any of our supported Rust versions. For instance, with Rust 1.97.1:With the version that I applied of that series, this was not strictly needed anymore.
I am seeing this function causing issue on my 1.85.1 -Os build, although the error message is different this time:
rust/kernel.o: warning: objtool: _RNvXs2_NtNtCsaNryh1j6xD7_4core3str6traitseINtNtNtB9_3ops5index5IndexINtNtBJ_5range9RangeFromjEE5indexCsldbe0TGTmNx_6kernel+0x1d: stack state mismatch: cfa1=4+8 cfa2=4+16
Disassembly shows that the function call before the warning location is a call to _4core3str16slice_error_fail, and objtool thought it can return (which will end up with a unbalanced stack if it does return).
Applying the patch fixes the issue.
Best,
Gary
Quoted 11 lines · Gary Guo
I am seeing this function causing issue on my 1.85.1 -Os build, although the error message is different this time:
rust/kernel.o: warning: objtool:_RNvXs2_NtNtCsaNryh1j6xD7_4core3str6traitseINtNtNtB9_3ops5index5IndexINtNtBJ_5range9RangeFromjEE5indexCsldbe0TGTmNx_6kernel+0x1d: stack state mismatch: cfa1=4+8 cfa2=4+16Disassembly shows that the function call before the warning location is a call to
_4core3str16slice_error_fail, and objtool thought it can return (which will end up with a unbalanced stack if it does return).Applying the patch fixes the issue.
Thanks Gary, then I will pick it up.
Cheers,
Miguel
Miguel Ojeda
AppliedQuoted 23 lines · Miguel Ojeda
When the pointer formatting series [1] is applied and KUnit tests are enabled,
objtoolwould report an error with any of our supported Rust versions. For instance, with Rust 1.97.1:
rust/kernel.o: error: objtool: _R..._4core3fmt7Pointer3fmtB7_() falls through to next function _R..._4core7convert5AsRefNtB5_4BStrE6as_ref()Or, with Rust 1.85.0:
rust/kernel.o: error: objtool: _R..._4core3fmt7Pointer3fmtB7_()
falls through to next function _R..._4core3ffi5c_str4CStrENtNtBS_3fmt7Display3fmtB7_()This happens due to calls to the
noreturnsymbol:
core::str::slice_error_failThus add the mangled one to the list so that
objtoolknows it is actuallynoreturn.See commit
56d680dd23c3("objtool/rust: listnoreturnRust functions") for more details.
Quoted 6 lines
Cc Josh Poimboeuf <[email protected]>Cc Peter Zijlstra <[email protected]>Reported-by Alice Ryhl <[email protected]>Signed-off-by Miguel Ojeda <[email protected]>
Applied to rust-fixes -- thanks!
[ While the series [1] mentioned above was not applied in a way
that triggered this, Gary found another case [2]:
I am seeing this function causing issue on my 1.85.1 -Os
build, although the
error message is different this time:
rust/kernel.o: warning: objtool:
_R..._5range9RangeFromjEE5indexCsldbe0TGTmNx_6kernel+0x1d:
stack state mismatch: cfa1=4+8 cfa2=4+16
Disassembly shows that the function call before the warning location is a call to _4core3str16slice_error_fail, and objtool thought it can return (which will end up with a unbalanced stack if it does return).
Thus apply it. - Miguel ]
Cc: [email protected] # Needed in 6.12.y and later (Rust is
pinned in older LTSs).
Cheers,
Miguel