Why first user process loads another program?
What happen?
The flow:
Why the process cannot call init directly?
init directly?My original Thought
The Truth
// Load the user initcode into address 0 of pagetable,
// for the very first process.
// sz must be less than a page.
void
uvminit(pagetable_t pagetable, uchar *src, uint sz)
{
char *mem;
if(sz >= PGSIZE)
panic(“inituvm: more than a page”);
mem = kalloc();
memset(mem, 0, PGSIZE);
mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
memmove(mem, src, sz);
}Understand initcode section in Makefile
initcode section in MakefileUse linker for ELF executable
Use objcopy to generate stripped binary
objcopy to generate stripped binaryResearch
Explain
Last updated