diff --git a/src/arch/aarch64/link.ld b/src/arch/aarch64/link.ld index bb7151be..dd642317 100644 --- a/src/arch/aarch64/link.ld +++ b/src/arch/aarch64/link.ld @@ -15,7 +15,7 @@ PHDRS SECTIONS { . = phys; - loader_start = .; + __executable_start = .; .text : { *(.text) *(.text.*) @@ -45,5 +45,5 @@ SECTIONS . += 16K; /* | growth */ /* | direction */ __boot_core_stack_end_exclusive = .; /* | */ - loader_end = .; + _end = .; } diff --git a/src/arch/aarch64/mod.rs b/src/arch/aarch64/mod.rs index be1834ef..188eb80b 100644 --- a/src/arch/aarch64/mod.rs +++ b/src/arch/aarch64/mod.rs @@ -22,7 +22,7 @@ use crate::arch::paging::*; use crate::os::CONSOLE; unsafe extern "C" { - static mut loader_end: u8; + static mut _end: u8; static mut l0_pgtable: u64; static mut l1_pgtable: u64; static mut l2_pgtable: u64; @@ -48,7 +48,7 @@ const PT_MEM_CD: u64 = 0x70F; const PT_SELF: u64 = 1 << 55; pub unsafe fn get_memory(_memory_size: u64) -> u64 { - (ptr::addr_of_mut!(loader_end).expose_provenance() as u64).align_up(LargePageSize::SIZE as u64) + (ptr::addr_of_mut!(_end).expose_provenance() as u64).align_up(LargePageSize::SIZE as u64) } pub fn find_kernel() -> &'static [u8] { @@ -148,7 +148,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! { } pgt_slice[1] = uart_address as u64 + PT_MEM_CD; - // map kernel to loader_start and stack below the kernel + // map kernel to __executable_start and stack below the kernel let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l2k_pgtable), 512) }; for i in pgt_slice.iter_mut() { *i = 0; diff --git a/src/arch/riscv64/link.ld b/src/arch/riscv64/link.ld index 5905b5fb..8d3f17bc 100644 --- a/src/arch/riscv64/link.ld +++ b/src/arch/riscv64/link.ld @@ -1,5 +1,5 @@ SECTIONS { - loader_start = ADDR (.text.start); + __executable_start = ADDR (.text.start); .text.start 0x80200000 : { *(.text._start) } .text : { *(.text.*) } @@ -7,5 +7,5 @@ SECTIONS { .data : { *(.data.*) } .bss : { *(.bss.*) } - loader_end = .; + _end = .; } diff --git a/src/arch/x86_64/platform/linux/entry.s b/src/arch/x86_64/platform/linux/entry.s index a16a9cca..756a6c97 100644 --- a/src/arch/x86_64/platform/linux/entry.s +++ b/src/arch/x86_64/platform/linux/entry.s @@ -3,8 +3,8 @@ .code64 -.extern loader_start # defined in linker script -.extern loader_end +.extern __executable_start # defined in linker script +.extern _end # Move entry point at the beginning of the elf file .section .mboot, "a" diff --git a/src/arch/x86_64/platform/linux/link.ld b/src/arch/x86_64/platform/linux/link.ld index d3286580..44a4325b 100644 --- a/src/arch/x86_64/platform/linux/link.ld +++ b/src/arch/x86_64/platform/linux/link.ld @@ -4,7 +4,7 @@ phys = 0x000000100000; SECTIONS { - loader_start = phys; + __executable_start = phys; .mboot phys : AT(ADDR(.mboot)) { *(.mboot) } @@ -24,5 +24,5 @@ SECTIONS *(.bss) *(.bss.*) } - loader_end = .; + _end = .; } diff --git a/src/arch/x86_64/platform/linux/mod.rs b/src/arch/x86_64/platform/linux/mod.rs index fe5e5968..b5463213 100644 --- a/src/arch/x86_64/platform/linux/mod.rs +++ b/src/arch/x86_64/platform/linux/mod.rs @@ -19,7 +19,7 @@ use crate::arch::x86_64::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, page_tables}; use crate::fdt::Fdt; unsafe extern "C" { - static mut loader_end: u8; + static mut _end: u8; } mod entry { @@ -41,9 +41,7 @@ unsafe extern "C" fn rust_start(boot_params: *mut BootParams) -> ! { crate::log::init(); BOOT_PARAMS.store(boot_params, Ordering::Relaxed); - let free_addr = ptr::addr_of!(loader_end) - .addr() - .align_up(Size2MiB::SIZE as usize); + let free_addr = ptr::addr_of!(_end).addr().align_up(Size2MiB::SIZE as usize); // Memory after the highest end address is unused and available for the physical memory manager. info!("Intializing PhysAlloc with {free_addr:#x}"); PhysAlloc::init(free_addr); @@ -85,9 +83,9 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! { let boot_params_ref = unsafe { BootParams::get() }; // determine boot stack address - let stack = (ptr::addr_of!(loader_end).addr() + Size4KiB::SIZE as usize) - .align_up(Size4KiB::SIZE as usize); - let stack = ptr::addr_of_mut!(loader_end).with_addr(stack); + let stack = + (ptr::addr_of!(_end).addr() + Size4KiB::SIZE as usize).align_up(Size4KiB::SIZE as usize); + let stack = ptr::addr_of_mut!(_end).with_addr(stack); // clear stack unsafe { write_bytes(stack, 0, KERNEL_STACK_SIZE.try_into().unwrap()); diff --git a/src/arch/x86_64/platform/multiboot/entry.s b/src/arch/x86_64/platform/multiboot/entry.s index 10320596..3fcab471 100644 --- a/src/arch/x86_64/platform/multiboot/entry.s +++ b/src/arch/x86_64/platform/multiboot/entry.s @@ -5,8 +5,8 @@ .code32 -.extern loader_start # defined in linker script -.extern loader_end +.extern __executable_start # defined in linker script +.extern _end # We use a special name to map this section at the begin of our kernel # => Multiboot expects its magic number at the beginning of the kernel. diff --git a/src/arch/x86_64/platform/multiboot/link.ld b/src/arch/x86_64/platform/multiboot/link.ld index 45b2d800..d43238bb 100644 --- a/src/arch/x86_64/platform/multiboot/link.ld +++ b/src/arch/x86_64/platform/multiboot/link.ld @@ -5,7 +5,7 @@ phys = 0x000000100000; SECTIONS { - loader_start = phys; + __executable_start = phys; .mboot phys : AT(ADDR(.mboot)) { KEEP(*(.mboot)) } @@ -25,5 +25,5 @@ SECTIONS *(.bss) *(.bss.*) } - loader_end = .; + _end = .; } diff --git a/src/arch/x86_64/platform/multiboot/mod.rs b/src/arch/x86_64/platform/multiboot/mod.rs index 0db5e78f..b570a0d9 100644 --- a/src/arch/x86_64/platform/multiboot/mod.rs +++ b/src/arch/x86_64/platform/multiboot/mod.rs @@ -19,7 +19,7 @@ use crate::arch::x86_64::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, page_tables}; use crate::fdt::Fdt; unsafe extern "C" { - static mut loader_end: u8; + static mut _end: u8; } #[allow(bad_asm_style)] @@ -148,9 +148,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! { let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() }; // determine boot stack address - let mut new_stack = ptr::addr_of!(loader_end) - .addr() - .align_up(Size4KiB::SIZE as usize); + let mut new_stack = ptr::addr_of!(_end).addr().align_up(Size4KiB::SIZE as usize); if new_stack + KERNEL_STACK_SIZE as usize > mb_info.addr() { new_stack = (mb_info.addr() + mem::size_of::>()) @@ -166,7 +164,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! { } } - let stack = ptr::addr_of_mut!(loader_end).with_addr(new_stack); + let stack = ptr::addr_of_mut!(_end).with_addr(new_stack); // clear stack unsafe { diff --git a/src/os/none/mod.rs b/src/os/none/mod.rs index 7d311b24..2eda78fd 100644 --- a/src/os/none/mod.rs +++ b/src/os/none/mod.rs @@ -12,15 +12,15 @@ pub use self::console::CONSOLE; use crate::arch; unsafe extern "C" { - static loader_end: u8; - static loader_start: u8; + static _end: u8; + static __executable_start: u8; } /// Entry Point of the BIOS Loader /// (called from entry.asm or entry.rs) pub(crate) unsafe extern "C" fn loader_main() -> ! { unsafe { - info!("Loader: [{:p} - {:p}]", &loader_start, &loader_end); + info!("Loader: [{:p} - {:p}]", &__executable_start, &_end); } let kernel = arch::find_kernel();