Skip to content

Commit c110329

Browse files
committed
Remove custom frame info registration on i686-pc-windows-gnu
The indirection is no longer needed since we always link to libgcc even when the panic_abort runtime is used. Instead we can just call the libgcc functions directly.
1 parent 5ff0876 commit c110329

File tree

4 files changed

+14
-51
lines changed

4 files changed

+14
-51
lines changed

library/panic_abort/src/lib.rs

-9
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,4 @@ pub mod personalities {
123123
#[allow(non_upper_case_globals)]
124124
#[cfg(target_os = "emscripten")]
125125
static rust_eh_catch_typeinfo: [usize; 2] = [0; 2];
126-
127-
// These two are called by our startup objects on i686-pc-windows-gnu, but
128-
// they don't need to do anything so the bodies are nops.
129-
#[rustc_std_internal_symbol]
130-
#[cfg(all(target_os = "windows", target_env = "gnu", target_arch = "x86"))]
131-
pub extern "C" fn rust_eh_register_frames() {}
132-
#[rustc_std_internal_symbol]
133-
#[cfg(all(target_os = "windows", target_env = "gnu", target_arch = "x86"))]
134-
pub extern "C" fn rust_eh_unregister_frames() {}
135126
}

library/panic_unwind/src/gcc.rs

-34
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,3 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
8787
// M O Z \0 R U S T -- vendor, language
8888
0x4d4f5a_00_52555354
8989
}
90-
91-
// Frame unwind info registration
92-
//
93-
// Each module's image contains a frame unwind info section (usually
94-
// ".eh_frame"). When a module is loaded/unloaded into the process, the
95-
// unwinder must be informed about the location of this section in memory. The
96-
// methods of achieving that vary by the platform. On some (e.g., Linux), the
97-
// unwinder can discover unwind info sections on its own (by dynamically
98-
// enumerating currently loaded modules via the dl_iterate_phdr() API and
99-
// finding their ".eh_frame" sections); Others, like Windows, require modules
100-
// to actively register their unwind info sections via unwinder API.
101-
//
102-
// This module defines two symbols which are referenced and called from
103-
// rsbegin.rs to register our information with the GCC runtime. The
104-
// implementation of stack unwinding is (for now) deferred to libgcc_eh, however
105-
// Rust crates use these Rust-specific entry points to avoid potential clashes
106-
// with any GCC runtime.
107-
#[cfg(all(target_os = "windows", target_arch = "x86", target_env = "gnu"))]
108-
pub mod eh_frame_registry {
109-
extern "C" {
110-
fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8);
111-
fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8);
112-
}
113-
114-
#[rustc_std_internal_symbol]
115-
pub unsafe extern "C" fn rust_eh_register_frames(eh_frame_begin: *const u8, object: *mut u8) {
116-
__register_frame_info(eh_frame_begin, object);
117-
}
118-
119-
#[rustc_std_internal_symbol]
120-
pub unsafe extern "C" fn rust_eh_unregister_frames(eh_frame_begin: *const u8, object: *mut u8) {
121-
__deregister_frame_info(eh_frame_begin, object);
122-
}
123-
}

library/panic_unwind/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ cfg_if::cfg_if! {
5252
all(target_family = "unix", not(target_os = "espidf")),
5353
all(target_vendor = "fortanix", target_env = "sgx"),
5454
))] {
55-
// Rust runtime's startup objects depend on these symbols, so make them public.
56-
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
57-
pub use real_imp::eh_frame_registry::*;
5855
#[path = "gcc.rs"]
5956
mod real_imp;
6057
} else {

library/rtstartup/rsbegin.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
3535
drop_in_place(to_drop);
3636
}
3737

38+
// Frame unwind info registration
39+
//
40+
// Each module's image contains a frame unwind info section (usually
41+
// ".eh_frame"). When a module is loaded/unloaded into the process, the
42+
// unwinder must be informed about the location of this section in memory. The
43+
// methods of achieving that vary by the platform. On some (e.g., Linux), the
44+
// unwinder can discover unwind info sections on its own (by dynamically
45+
// enumerating currently loaded modules via the dl_iterate_phdr() API and
46+
// finding their ".eh_frame" sections); Others, like Windows, require modules
47+
// to actively register their unwind info sections via unwinder API.
3848
#[cfg(all(target_os = "windows", target_arch = "x86", target_env = "gnu"))]
3949
pub mod eh_frames {
4050
#[no_mangle]
@@ -62,20 +72,19 @@ pub mod eh_frames {
6272
}
6373

6474
// Unwind info registration/deregistration routines.
65-
// See the docs of libpanic_unwind.
6675
extern "C" {
67-
fn rust_eh_register_frames(eh_frame_begin: *const u8, object: *mut u8);
68-
fn rust_eh_unregister_frames(eh_frame_begin: *const u8, object: *mut u8);
76+
fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8);
77+
fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8);
6978
}
7079

7180
unsafe extern "C" fn init() {
7281
// register unwind info on module startup
73-
rust_eh_register_frames(&__EH_FRAME_BEGIN__ as *const u8, &mut OBJ as *mut _ as *mut u8);
82+
__register_frame_info(&__EH_FRAME_BEGIN__ as *const u8, &mut OBJ as *mut _ as *mut u8);
7483
}
7584

7685
unsafe extern "C" fn uninit() {
7786
// unregister on shutdown
78-
rust_eh_unregister_frames(&__EH_FRAME_BEGIN__ as *const u8, &mut OBJ as *mut _ as *mut u8);
87+
__deregister_frame_info(&__EH_FRAME_BEGIN__ as *const u8, &mut OBJ as *mut _ as *mut u8);
7988
}
8089

8190
// MinGW-specific init/uninit routine registration

0 commit comments

Comments
 (0)