From f265d7c5bef3637e918e07a7a77bb01827f2cb15 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Sun, 24 Jun 2018 09:56:08 -0600 Subject: [PATCH] Fix linking issues with lang items --- src/crt0/src/lib.rs | 4 +++- src/lib.rs | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/crt0/src/lib.rs b/src/crt0/src/lib.rs index a2a90ecc..9de7f3c9 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 496b1e76..db4ed938 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); +} -- GitLab