do not edit — generated by btf.
git.druid.rocksindexdruid520kaboomsrc/kernel/elf_asm.s

src/kernel/elf_asm.s


/*
 * nsc has no function pointers, so calling through a runtime-computed
 * address (the entry point elf_load just handed back) has to be asm,
 * same reasoning as every other "nsc needs an address it can't get
 * itself" gap in this kernel (idt_asm.s's isr address getters,
 * vmm_asm.s's get_pd_table). the loaded code is expected to ret back here when done --
 * there's no ring3/process-replacement semantics yet, this is just an
 * ordinary call.
 *
 * elf_call_entry(entry, argc, argv): entry/argc/argv arrive in
 * rdi/rsi/rdx per sysv (this function's own args), but the loaded
 * program expects the normal c `main(argc, argv)` convention --
 * argc/argv in rdi/rsi -- so they get shuffled down by one register
 * before the indirect call.
 */
.section .text
 
.global elf_call_entry
.type elf_call_entry, @function
elf_call_entry:
	movq %rdi, %rax    /* entry point */
	movq %rsi, %rdi    /* argc -> arg1 for the called program */
	movq %rdx, %rsi    /* argv -> arg2 for the called program */
	call *%rax
	ret
powered by btf.