diff --git a/src/crt0/src/lib.rs b/src/crt0/src/lib.rs index a2a90ecc697720293325c005bf3dbe6f34b47a16..9de7f3c9643066e91213c6d41c719de7e87ee0f2 100644 --- a/src/crt0/src/lib.rs +++ b/src/crt0/src/lib.rs @@ -2,6 +2,7 @@ #![no_std] #![feature(asm)] +#![feature(linkage)] #![feature(naked_functions)] #![feature(panic_implementation)] @@ -60,8 +61,9 @@ pub unsafe extern "C" fn _start_rust(sp: &'static Stack) -> ! { } #[panic_implementation] +#[linkage = "weak"] #[no_mangle] -pub extern "C" fn _start_panic(pi: &::core::panic::PanicInfo) -> ! { +pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! { use core::fmt::Write; let mut w = platform::FileWriter(2); diff --git a/src/lib.rs b/src/lib.rs index 496b1e767736067cb0599e40b5da84e67a6ebf9d..db4ed938025b033301f6fbfb6d94f4f3c97461f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![no_std] #![feature(lang_items)] +#![feature(linkage)] #![feature(panic_implementation)] //extern crate compiler_builtins; @@ -28,9 +29,11 @@ pub extern crate time; pub extern crate unistd; pub extern crate wctype; +#[cfg(not(test))] #[panic_implementation] +#[linkage = "weak"] #[no_mangle] -pub extern "C" fn relibc_panic(pi: &::core::panic::PanicInfo) -> ! { +pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! { use core::fmt::Write; let mut w = platform::FileWriter(2); @@ -39,9 +42,17 @@ pub extern "C" fn relibc_panic(pi: &::core::panic::PanicInfo) -> ! { platform::exit(1); } +#[cfg(not(test))] +#[lang = "eh_personality"] +#[no_mangle] +#[linkage = "weak"] +pub extern "C" fn rust_eh_personality() {} + +#[cfg(not(test))] #[lang = "oom"] +#[linkage = "weak"] #[no_mangle] -pub extern fn relibc_oom(layout: ::core::alloc::Layout) -> ! { +pub extern fn rust_oom(layout: ::core::alloc::Layout) -> ! { use core::fmt::Write; let mut w = platform::FileWriter(2); @@ -49,3 +60,16 @@ pub extern fn relibc_oom(layout: ::core::alloc::Layout) -> ! { platform::exit(1); } + +#[cfg(not(test))] +#[allow(non_snake_case)] +#[linkage = "weak"] +#[no_mangle] +pub extern "C" fn _Unwind_Resume() -> ! { + use core::fmt::Write; + + let mut w = platform::FileWriter(2); + let _ = w.write_str("_Unwind_Resume\n"); + + platform::exit(1); +}