mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
rust: module: add static pointer to {init,cleanup}_module()
Add the equivalent of the `___ADDRESSABLE()` annotation in the
`module_{init,exit}` macros to the Rust `module!` macro.
Without this, `objtool` would complain if enabled for Rust (under IBT
builds), e.g.:
samples/rust/rust_print.o: warning: objtool: cleanup_module(): not an indirect call target
samples/rust/rust_print.o: warning: objtool: init_module(): not an indirect call target
Tested-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20240725183325.122827-2-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
876346536c
commit
289088d546
1 changed files with 12 additions and 0 deletions
|
|
@ -256,6 +256,12 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||||
unsafe {{ __init() }}
|
unsafe {{ __init() }}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
#[cfg(MODULE)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[used]
|
||||||
|
#[link_section = \".init.data\"]
|
||||||
|
static __UNIQUE_ID___addressable_init_module: unsafe extern \"C\" fn() -> i32 = init_module;
|
||||||
|
|
||||||
#[cfg(MODULE)]
|
#[cfg(MODULE)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
@ -269,6 +275,12 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
|
||||||
unsafe {{ __exit() }}
|
unsafe {{ __exit() }}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
#[cfg(MODULE)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[used]
|
||||||
|
#[link_section = \".exit.data\"]
|
||||||
|
static __UNIQUE_ID___addressable_cleanup_module: extern \"C\" fn() = cleanup_module;
|
||||||
|
|
||||||
// Built-in modules are initialized through an initcall pointer
|
// Built-in modules are initialized through an initcall pointer
|
||||||
// and the identifiers need to be unique.
|
// and the identifiers need to be unique.
|
||||||
#[cfg(not(MODULE))]
|
#[cfg(not(MODULE))]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue