Skip to content

Commit 0f8f4b6

Browse files
committed
rust: use .init_array instead of .ctors in init_static_sync
When KASAN is enabled, it creates an entry in the `.init_array` section, for example: ``` RELOCATION RECORDS FOR [.init_array]: OFFSET TYPE VALUE 00000000 R_ARM_TARGET1 asan.module_ctor ``` When this is compiled into a loadable module that also contains a `.ctors` section, the kernel fails to load it, for example: ``` [ 27.699160] rust_sync: has both .ctors and .init_array. insmod: can't insert 'rust_sync.ko': invalid parameter ``` Using `.init_array` for static synchronisation primitives avoids this error. Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
1 parent 29fd422 commit 0f8f4b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rust/kernel/sync/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ macro_rules! init_static_sync {
120120
$(
121121
$(#[$outer])*
122122
$v static $id: $t = {
123-
#[link_section = ".ctors"]
123+
#[link_section = ".init_array"]
124124
#[used]
125125
static TMP: extern "C" fn() = {
126126
extern "C" fn constructor() {

0 commit comments

Comments
 (0)