Skip to content

Commit 249c3a0

Browse files
fujitaojeda
authored andcommitted
rust: module: place cleanup_module() in .exit.text section
Place cleanup_module() in .exit.text section. Currently, cleanup_module() is likely placed in the .text section. It's inconsistent with the layout of C modules, where cleanup_module() is placed in .exit.text. [ Boqun asked for an example of how the section changed to be put in the log. Tomonori provided the following examples: C module: $ objdump -t ~/build/x86/drivers/block/loop.o|grep clean 0000000000000000 l O .exit.data 0000000000000008 __UNIQUE_ID___addressable_cleanup_module412 0000000000000000 g F .exit.text 000000000000009c cleanup_module Rust module without this patch: $ objdump -t ~/build/x86/samples/rust/rust_minimal.o|grep clean 00000000000002b0 g F .text 00000000000000c6 cleanup_module 0000000000000000 g O .exit.data 0000000000000008 _R...___UNIQUE_ID___addressable_cleanup_module Rust module with this patch: $ objdump -t ~/build/x86/samples/rust/rust_minimal.o|grep clean 0000000000000000 g F .exit.text 00000000000000c6 cleanup_module 0000000000000000 g O .exit.data 0000000000000008 _R...___UNIQUE_ID___addressable_cleanup_module - Miguel ] Signed-off-by: FUJITA Tomonori <[email protected]> Acked-by: Jarkko Sakkinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent bb941ea commit 249c3a0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

rust/macros/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
278278
#[cfg(MODULE)]
279279
#[doc(hidden)]
280280
#[no_mangle]
281+
#[link_section = \".exit.text\"]
281282
pub extern \"C\" fn cleanup_module() {{
282283
// SAFETY:
283284
// - This function is inaccessible to the outside due to the double

0 commit comments

Comments
 (0)