Bump version to 0.3.0

This commit is contained in:
Zhang Junyang
2023-12-26 18:16:08 +08:00
committed by Tate, Hongliang Tian
parent 85d4cfdeb7
commit 302b547a0d
14 changed files with 32 additions and 32 deletions

View File

@ -33,7 +33,7 @@ fn get_payload(boot_params: &BootParams) -> &'static [u8] {
let hdr = &boot_params.hdr;
// The payload_offset field is not recorded in the relocation table, so we need to
// calculate the loaded offset manually.
let loaded_offset = x86::relocation::get_image_loaded_offset();
let loaded_offset = x86::get_image_loaded_offset();
let payload_offset = (loaded_offset + hdr.payload_offset as isize) as usize;
let payload_length = hdr.payload_length as usize;
// Safety: the payload_offset and payload_length is valid if we assume that the

View File

@ -6,7 +6,8 @@ use uefi::{
use linux_boot_params::BootParams;
use crate::x86::paging::{Ia32eFlags, PageNumber, PageTableCreator};
use super::paging::{Ia32eFlags, PageNumber, PageTableCreator};
use super::relocation::apply_rela_dyn_relocations;
#[export_name = "efi_stub_entry"]
extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable<Boot>) -> ! {
@ -47,7 +48,7 @@ fn efi_phase_boot(
unsafe { crate::console::init() };
// Safety: this is the right time to apply relocations.
unsafe { crate::x86::relocation::apply_rela_dyn_relocations() };
unsafe { apply_rela_dyn_relocations() };
uefi_services::println!("[EFI stub] Relocations applied.");

View File

@ -1,4 +1,6 @@
mod efi;
mod paging;
mod relocation;
use core::arch::{asm, global_asm};

View File

@ -1,15 +1,4 @@
// This is enforced in the linker script.
const START_OF_SETUP32_VA: usize = 0x100000;
/// The wrapper is a position-independent executable. We can get the loaded base
/// address from the symbol.
#[inline]
pub fn get_image_loaded_offset() -> isize {
extern "C" {
fn start_of_setup32();
}
start_of_setup32 as isize - START_OF_SETUP32_VA as isize
}
use crate::x86::get_image_loaded_offset;
struct Elf64Rela {
r_offset: u64,

View File

@ -17,8 +17,8 @@ extern "cdecl" fn trojan_entry(boot_params_ptr: u32) -> ! {
// println!("[setup] bzImage loaded at {:#x}", x86::relocation::get_image_loaded_offset());
unsafe {
print_str("[setup] bzImage loaded at ");
print_hex(crate::x86::relocation::get_image_loaded_offset() as u64);
print_str("[setup] bzImage loaded offset: ");
print_hex(crate::x86::get_image_loaded_offset() as u64);
print_str("\n");
}
@ -32,8 +32,6 @@ extern "cdecl" fn trojan_entry(boot_params_ptr: u32) -> ! {
unsafe { call_aster_entrypoint(ASTER_ENTRY_POINT, boot_params_ptr.try_into().unwrap()) };
}
pub const ASTER_ENTRY_POINT: u32 = 0x8001000;
unsafe fn call_aster_entrypoint(entrypoint: u32, boot_params_ptr: u32) -> ! {
asm!("mov esi, {}", in(reg) boot_params_ptr);
asm!("mov eax, {}", in(reg) entrypoint);

View File

@ -8,5 +8,15 @@ cfg_if::cfg_if! {
}
}
pub mod paging;
pub mod relocation;
// This is enforced in the linker script of the wrapper.
const START_OF_SETUP32_VA: usize = 0x100000;
/// The wrapper is a position-independent executable. We can get the loaded base
/// address from the symbol.
#[inline]
pub fn get_image_loaded_offset() -> isize {
extern "C" {
fn start_of_setup32();
}
start_of_setup32 as isize - START_OF_SETUP32_VA as isize
}