lib.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #[macro_use]
  26. extern crate alloc;
  27. extern crate cbitset;
  28. extern crate core_io;
  29. extern crate goblin;
  30. #[macro_use]
  31. extern crate lazy_static;
  32. extern crate memchr;
  33. #[macro_use]
  34. extern crate memoffset;
  35. extern crate posix_regex;
  36. extern crate rand;
  37. #[cfg(target_os = "linux")]
  38. #[macro_use]
  39. extern crate sc;
  40. #[cfg(target_os = "redox")]
  41. extern crate syscall;
  42. #[cfg(target_os = "redox")]
  43. extern crate spin;
  44. #[macro_use]
  45. mod macros;
  46. pub mod c_str;
  47. pub mod c_vec;
  48. pub mod cxa;
  49. pub mod db;
  50. pub mod fs;
  51. pub mod header;
  52. pub mod io;
  53. pub mod ld_so;
  54. pub mod platform;
  55. pub mod start;
  56. pub mod sync;
  57. use crate::platform::{Allocator, Pal, Sys, NEWALLOCATOR};
  58. #[global_allocator]
  59. static ALLOCATOR: Allocator = NEWALLOCATOR;
  60. #[no_mangle]
  61. pub extern "C" fn relibc_panic(pi: &::core::panic::PanicInfo) -> ! {
  62. use core::fmt::Write;
  63. let mut w = platform::FileWriter(2);
  64. let _ = w.write_fmt(format_args!("RELIBC PANIC: {}\n", pi));
  65. Sys::exit(1);
  66. }
  67. #[cfg(not(test))]
  68. #[panic_handler]
  69. #[linkage = "weak"]
  70. #[no_mangle]
  71. pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
  72. relibc_panic(pi)
  73. }
  74. #[cfg(not(test))]
  75. #[lang = "eh_personality"]
  76. #[no_mangle]
  77. #[linkage = "weak"]
  78. pub extern "C" fn rust_eh_personality() {}
  79. #[cfg(not(test))]
  80. #[lang = "oom"]
  81. #[linkage = "weak"]
  82. #[no_mangle]
  83. pub extern "C" fn rust_oom(layout: ::core::alloc::Layout) -> ! {
  84. use core::fmt::Write;
  85. let mut w = platform::FileWriter(2);
  86. let _ = w.write_fmt(format_args!(
  87. "RELIBC OOM: {} bytes aligned to {} bytes\n",
  88. layout.size(),
  89. layout.align()
  90. ));
  91. Sys::exit(1);
  92. }
  93. #[cfg(not(test))]
  94. #[allow(non_snake_case)]
  95. #[linkage = "weak"]
  96. #[no_mangle]
  97. pub extern "C" fn _Unwind_Resume() -> ! {
  98. use core::fmt::Write;
  99. let mut w = platform::FileWriter(2);
  100. let _ = w.write_str("_Unwind_Resume\n");
  101. Sys::exit(1);
  102. }