Skip to content

Commit d8b6be9

Browse files
committed
Use .init_array section on glibc
1 parent 9d6ff15 commit d8b6be9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/libstd/sys/unix/args.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ mod imp {
7878
ARGV = argv;
7979
}
8080

81+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
82+
#[used]
83+
#[link_section = ".init_array"]
84+
static ARGV_INIT_ARRAY: extern "C" fn(
85+
crate::os::raw::c_int,
86+
*const *const u8,
87+
*const *const u8,
88+
) = {
89+
extern "C" fn init_wrapper(
90+
argc: crate::os::raw::c_int,
91+
argv: *const *const u8,
92+
_envp: *const *const u8,
93+
) {
94+
unsafe {
95+
init(argc as isize, argv);
96+
}
97+
}
98+
init_wrapper
99+
};
100+
81101
pub unsafe fn cleanup() {
82102
let _guard = LOCK.lock();
83103
ARGC = 0;

0 commit comments

Comments
 (0)