1 #![no_std] 2 #![allow(non_camel_case_types)] 3 #![allow(non_upper_case_globals)] 4 #![allow(unused_variables)] 5 #![feature(allocator_api)] 6 #![feature(asm)] 7 #![feature(box_into_pin)] 8 #![feature(c_variadic)] 9 #![feature(const_btree_new)] 10 #![feature(const_raw_ptr_deref)] 11 #![feature(core_intrinsics)] 12 #![feature(global_asm)] 13 #![feature(lang_items)] 14 #![feature(linkage)] 15 #![feature(llvm_asm)] 16 #![feature(maybe_uninit_extra)] 17 #![feature(stmt_expr_attributes)] 18 #![feature(str_internals)] 19 #![feature(thread_local)] 20 #![allow(clippy::cast_lossless)] 21 #![allow(clippy::cast_ptr_alignment)] 22 #![allow(clippy::derive_hash_xor_eq)] 23 #![allow(clippy::eval_order_dependence)] 24 #![allow(clippy::mut_from_ref)] 25 26 #[macro_use] 27 extern crate alloc; 28 extern crate cbitset; 29 extern crate core_io; 30 extern crate goblin; 31 #[macro_use] 32 extern crate lazy_static; 33 extern crate memchr; 34 #[macro_use] 35 extern crate memoffset; 36 extern crate posix_regex; 37 extern crate rand; 38 39 #[cfg(target_os = "linux")] 40 #[macro_use] 41 extern crate sc; 42 43 #[cfg(target_os = "redox")] 44 extern crate syscall; 45 46 #[cfg(target_os = "redox")] 47 extern crate spin; 48 49 #[macro_use] 50 mod macros; 51 pub mod c_str; 52 pub mod c_vec; 53 pub mod cxa; 54 pub mod db; 55 pub mod fs; 56 pub mod header; 57 pub mod io; 58 pub mod ld_so; 59 pub mod platform; 60 pub mod start; 61 pub mod sync; 62 63 use crate::platform::{Allocator, Pal, Sys, NEWALLOCATOR}; 64 65 #[global_allocator] 66 static ALLOCATOR: Allocator = NEWALLOCATOR; 67 68 #[no_mangle] 69 pub extern "C" fn relibc_panic(pi: &::core::panic::PanicInfo) -> ! { 70 use core::fmt::Write; 71 72 let mut w = platform::FileWriter(2); 73 let _ = w.write_fmt(format_args!("RELIBC PANIC: {}\n", pi)); 74 75 Sys::exit(1); 76 } 77 78 #[cfg(not(test))] 79 #[panic_handler] 80 #[linkage = "weak"] 81 #[no_mangle] 82 pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! { 83 relibc_panic(pi) 84 } 85 86 #[cfg(not(test))] 87 #[lang = "eh_personality"] 88 #[no_mangle] 89 #[linkage = "weak"] 90 pub extern "C" fn rust_eh_personality() {} 91 92 #[cfg(not(test))] 93 #[lang = "oom"] 94 #[linkage = "weak"] 95 #[no_mangle] 96 pub extern "C" fn rust_oom(layout: ::core::alloc::Layout) -> ! { 97 use core::fmt::Write; 98 99 let mut w = platform::FileWriter(2); 100 let _ = w.write_fmt(format_args!( 101 "RELIBC OOM: {} bytes aligned to {} bytes\n", 102 layout.size(), 103 layout.align() 104 )); 105 106 Sys::exit(1); 107 } 108 109 #[cfg(not(test))] 110 #[allow(non_snake_case)] 111 #[linkage = "weak"] 112 #[no_mangle] 113 pub extern "C" fn _Unwind_Resume() -> ! { 114 use core::fmt::Write; 115 116 let mut w = platform::FileWriter(2); 117 let _ = w.write_str("_Unwind_Resume\n"); 118 119 Sys::exit(1); 120 } 121