Skip to content

Commit 38b390b

Browse files
compiler-errorsgitbot
authored and
gitbot
committed
Mark link_section attr with unsafe
1 parent 6ec3cd9 commit 38b390b

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

rtstartup/rsbegin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
5252
#[cfg(all(target_os = "windows", target_arch = "x86", target_env = "gnu"))]
5353
pub mod eh_frames {
5454
#[no_mangle]
55-
#[link_section = ".eh_frame"]
55+
#[unsafe(link_section = ".eh_frame")]
5656
// Marks beginning of the stack frame unwind info section
5757
pub static __EH_FRAME_BEGIN__: [u8; 0] = [];
5858

@@ -101,10 +101,10 @@ pub mod eh_frames {
101101
// end of the list. Since constructors are run in reverse order, this ensures that our
102102
// callbacks are the first and last ones executed.
103103

104-
#[link_section = ".ctors.65535"] // .ctors.* : C initialization callbacks
104+
#[unsafe(link_section = ".ctors.65535")] // .ctors.* : C initialization callbacks
105105
pub static P_INIT: unsafe extern "C" fn() = super::init;
106106

107-
#[link_section = ".dtors.65535"] // .dtors.* : C termination callbacks
107+
#[unsafe(link_section = ".dtors.65535")] // .dtors.* : C termination callbacks
108108
pub static P_UNINIT: unsafe extern "C" fn() = super::uninit;
109109
}
110110
}

rtstartup/rsend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ pub mod eh_frames {
3232
// Terminate the frame unwind info section with a 0 as a sentinel;
3333
// this would be the 'length' field in a real FDE.
3434
#[no_mangle]
35-
#[link_section = ".eh_frame"]
35+
#[unsafe(link_section = ".eh_frame")]
3636
pub static __EH_FRAME_END__: u32 = 0;
3737
}

std/src/sys/pal/unix/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ mod imp {
147147
/// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows.
148148
#[cfg(all(target_os = "linux", target_env = "gnu"))]
149149
#[used]
150-
#[link_section = ".init_array.00099"]
150+
#[unsafe(link_section = ".init_array.00099")]
151151
static ARGV_INIT_ARRAY: extern "C" fn(
152152
crate::os::raw::c_int,
153153
*const *const u8,

std/src/sys/pal/windows/compat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::sys::c;
3939
// See https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization?view=msvc-170
4040
#[cfg(target_vendor = "win7")]
4141
#[used]
42-
#[link_section = ".CRT$XCT"]
42+
#[unsafe(link_section = ".CRT$XCT")]
4343
static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init;
4444

4545
/// Preload some imported functions.

std/src/sys/thread_local/guard/windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn enable() {
7474
unsafe { ptr::from_ref(&CALLBACK).read_volatile() };
7575
}
7676

77-
#[link_section = ".CRT$XLB"]
77+
#[unsafe(link_section = ".CRT$XLB")]
7878
#[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section`
7979
pub static CALLBACK: unsafe extern "system" fn(*mut c_void, u32, *mut c_void) = tls_callback;
8080

0 commit comments

Comments
 (0)