#[doc(hidden)]
#[naked]
#[no_mangle]
#[cfg(not(test))]
pub unsafe extern "C" fn _start() -> ! {
llvm_asm!(
"
/* rsp is currently bottom of stack, make it top of stack */
addq $1, %rsp
/* put a nonsensical value in rbp so we fail fast if we touch it */
movq $$0xdeadbeef, %rbp
"
:
: "{rsp}" (&(STACK.stack))
"i" (STACK_SIZE)
: "rdi", "rsp", "rbp"
: "volatile"
);
llvm_asm!("call __sel4_start_init_boot_info" :::: "volatile");
llvm_asm!(
"
/* N.B. rsp MUST be aligned to a 16-byte boundary when main is called.
* Insert or remove padding here to make that happen.
*/
pushq $$0
/* Null terminate auxv */
pushq $$0
pushq $$0
/* Null terminate envp */
pushq $$0
/* add at least one environment string (why?) */
pushq $0
/* Null terminate argv */
pushq $$0
/* Give an argv[0] (why?) */
pushq $1
/* Give argc */
pushq $$1
/* No atexit */
movq $$0, %rdx
/* Now go to the 'main' stub that rustc generates */
call main
"
:
: "{rax}" (ENVIRONMENT_STRING as *const [u8] as *const u8),
"{rbx}" (PROG_NAME as *const [u8] as *const u8)
:
: "volatile"
);
core::intrinsics::unreachable()
}