Skip to content

Commit c807ff3

Browse files
committed
Create entry points for unwind frame registry in libstd.
1 parent def917a commit c807ff3

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/libstd/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ pub mod __rand {
400400
pub use rand::{thread_rng, ThreadRng, Rng};
401401
}
402402

403+
// Rust runtime's startup objects depend on these symbols, so they must be public.
404+
// Since sys_common isn't public, we have to re-export them here explicitly.
405+
#[doc(hidden)]
406+
#[unstable(feature = "eh_frame_registry", issue = "0")]
407+
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
408+
pub mod __frame_registry {
409+
pub use sys_common::unwind::imp::eh_frame_registry::*;
410+
}
411+
403412
// Include a number of private modules that exist solely to provide
404413
// the rustdoc documentation for primitive types. Using `include!`
405414
// because rustdoc only looks for these modules at the crate level.

src/libstd/sys/common/libunwind.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ extern {}
128128
#[link(name = "c++abi")]
129129
extern {}
130130

131+
#[cfg(all(target_os = "windows", target_env="gnu"))]
132+
#[link(name = "gcc_eh")]
133+
extern {}
134+
131135
extern "C" {
132136
// iOS on armv7 uses SjLj exceptions and requires to link
133137
// against corresponding routine (..._SjLj_...)

src/libstd/sys/common/unwind/gcc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,24 @@ pub mod eabi {
238238
unsafe extern fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! {
239239
uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception);
240240
}
241+
242+
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
243+
pub mod eh_frame_registry {
244+
#[link(name = "gcc_eh")]
245+
extern {
246+
fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8);
247+
fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8);
248+
}
249+
#[cfg(not(test))]
250+
#[no_mangle]
251+
pub unsafe extern fn rust_eh_register_frames(eh_frame_begin: *const u8,
252+
object: *mut u8) {
253+
__register_frame_info(eh_frame_begin, object);
254+
}
255+
#[cfg(not(test))]
256+
#[no_mangle]
257+
pub unsafe extern fn rust_eh_unregister_frames(eh_frame_begin: *const u8,
258+
object: *mut u8) {
259+
__deregister_frame_info(eh_frame_begin, object);
260+
}
261+
}

0 commit comments

Comments
 (0)