Skip to content

Commit

Permalink
Mark link_section attr with unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Feb 9, 2025
1 parent a26e97b commit 9c486a7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions library/rtstartup/rsbegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
#[cfg(all(target_os = "windows", target_arch = "x86", target_env = "gnu"))]
pub mod eh_frames {
#[no_mangle]
#[link_section = ".eh_frame"]
#[unsafe(link_section = ".eh_frame")]
// Marks beginning of the stack frame unwind info section
pub static __EH_FRAME_BEGIN__: [u8; 0] = [];

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

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

#[link_section = ".dtors.65535"] // .dtors.* : C termination callbacks
#[unsafe(link_section = ".dtors.65535")] // .dtors.* : C termination callbacks
pub static P_UNINIT: unsafe extern "C" fn() = super::uninit;
}
}
2 changes: 1 addition & 1 deletion library/rtstartup/rsend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ pub mod eh_frames {
// Terminate the frame unwind info section with a 0 as a sentinel;
// this would be the 'length' field in a real FDE.
#[no_mangle]
#[link_section = ".eh_frame"]
#[unsafe(link_section = ".eh_frame")]
pub static __EH_FRAME_END__: u32 = 0;
}
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/unix/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod imp {
/// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows.
#[cfg(all(target_os = "linux", target_env = "gnu"))]
#[used]
#[link_section = ".init_array.00099"]
#[unsafe(link_section = ".init_array.00099")]
static ARGV_INIT_ARRAY: extern "C" fn(
crate::os::raw::c_int,
*const *const u8,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use crate::sys::c;
// See https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization?view=msvc-170
#[cfg(target_vendor = "win7")]
#[used]
#[link_section = ".CRT$XCT"]
#[unsafe(link_section = ".CRT$XCT")]
static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init;

/// Preload some imported functions.
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/thread_local/guard/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn enable() {
unsafe { ptr::from_ref(&CALLBACK).read_volatile() };
}

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

Expand Down

0 comments on commit 9c486a7

Please sign in to comment.