mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 08:53:29 +00:00
Update image and Rust toolchain
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
97323f612b
commit
12d01ca1e4
@ -12,5 +12,5 @@ serde = { version = "1.0.192", features = ["derive"] }
|
||||
xmas-elf = "0.9.1"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["trojan64"]
|
||||
trojan64 = []
|
||||
|
@ -158,7 +158,7 @@ fn build_trojan_with_arch(source_dir: &Path, out_dir: &Path, arch: &TrojanBuildA
|
||||
let out_dir = std::fs::canonicalize(out_dir).unwrap();
|
||||
|
||||
// Relocations are fewer in release mode. But with release mode it crashes.
|
||||
let profile = "debug";
|
||||
let profile = "release";
|
||||
|
||||
let cargo = std::env::var("CARGO").unwrap();
|
||||
let mut cmd = std::process::Command::new(cargo);
|
||||
|
@ -120,5 +120,12 @@ fn efi_phase_runtime(
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use crate::console::{print_hex, print_str};
|
||||
print_str("[EFI stub] Entering Jinux entrypoint at ");
|
||||
print_hex(super::JINUX_ENTRY_POINT as u64);
|
||||
print_str("\n");
|
||||
}
|
||||
|
||||
unsafe { super::call_jinux_entrypoint(super::JINUX_ENTRY_POINT, boot_params_ptr as u64) }
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ global_asm!(include_str!("setup.S"));
|
||||
|
||||
use crate::console::{print_hex, print_str};
|
||||
|
||||
pub const JINUX_ENTRY_POINT: u32 = 0x8001000;
|
||||
|
||||
#[export_name = "_trojan_entry_32"]
|
||||
extern "cdecl" fn trojan_entry(boot_params_ptr: u32) -> ! {
|
||||
// Safety: this init function is only called once.
|
||||
@ -27,12 +29,7 @@ extern "cdecl" fn trojan_entry(boot_params_ptr: u32) -> ! {
|
||||
crate::loader::load_elf(payload);
|
||||
|
||||
// Safety: the entrypoint and the ptr is valid.
|
||||
unsafe {
|
||||
call_jinux_entrypoint(
|
||||
super::JINUX_ENTRY_POINT,
|
||||
boot_params_ptr.try_into().unwrap(),
|
||||
)
|
||||
};
|
||||
unsafe { call_jinux_entrypoint(JINUX_ENTRY_POINT, boot_params_ptr.try_into().unwrap()) };
|
||||
}
|
||||
|
||||
pub const ASTER_ENTRY_POINT: u32 = 0x8001000;
|
||||
|
@ -1,10 +1,8 @@
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "x86_64")] {
|
||||
mod amd64_efi;
|
||||
pub use amd64_efi::*;
|
||||
} else if #[cfg(target_arch = "x86")] {
|
||||
mod legacy_i386;
|
||||
pub use legacy_i386::*;
|
||||
} else {
|
||||
compile_error!("Unsupported target_arch");
|
||||
}
|
||||
|
@ -28,10 +28,21 @@ fn get_rela_array() -> &'static [Elf64Rela] {
|
||||
let end = __rela_dyn_end as *const Elf64Rela;
|
||||
// FIXME: 2023/11/29
|
||||
// There should be a Rust compiler bug that makes the calculation of len incorrect.
|
||||
// The current implementation only works in debug mode.
|
||||
// To do it in release mode, a workaround is to use inline asm. But that crashes
|
||||
// in debug mode. QaQ
|
||||
let len = unsafe { end.offset_from(start) } as usize;
|
||||
// The most sound implementation only works in debug mode.
|
||||
// let len = unsafe { end.offset_from(start) } as usize;
|
||||
// The inline asm solution is a workaround.
|
||||
let len = unsafe {
|
||||
let len: usize;
|
||||
core::arch::asm!("
|
||||
mov {len}, {end}
|
||||
sub {len}, {start}
|
||||
",
|
||||
len = out(reg) len,
|
||||
end = in(reg) end,
|
||||
start = in(reg) start,
|
||||
);
|
||||
len / core::mem::size_of::<Elf64Rela>() as usize
|
||||
};
|
||||
#[cfg(feature = "debug_print")]
|
||||
unsafe {
|
||||
use crate::console::{print_hex, print_str};
|
||||
|
Reference in New Issue
Block a user