rax register, not the address of phys_base.
addq phys_base(%rip), %rax
BTW, the value of phys_base =
the actual loaded physical address of kernel after relocation - the
likned physical address of kernel.
Signed-off-by: Firo Yang <firogh@gmail.com>
* Added dots around envp and argv since those are arrays of pointers.
While argc and NULL are just 8B, argv and envp are of variable size,
usually more than 8B. The dots visualize this.
* In the first image, moved rsp to point to argc. This is the initial
stack and register layout at the beginning of _start. Only after libc
popped the top of the stack into rsi, rsp will point to beginning of
argv. (*)
(*)
I verified this by writing my own _start implementation:
039ac7c03c/start.asm (L61)
'CPU mask' link in Initialization 7 is double-bracketed.
'Previous part' links in SyncPrim 3 & 4 have two opening brackets
and one closing.
'Previous part' link in SyncPrim 4 points to current page,
instead of previous.
Append to contributors.
This commit fixes some instances where return types did not match the type of
the variable being returned or printf format strings did not match the types of
arguments.
- rep stosl reduces ecx by 1 per write operation, not 4. Source: http://www.fermimn.gov.it/linux/quarta/x86/rep.htm
- Clarification: The four Page Directory tables contain 2048 entries in total, not 2048 each. Source: http://wiki.osdev.org/Page_Tables#Long_mode_.2864-bit.29_page_map
- Registers can not contain %rip-relative addresses, since %rip changes every single instruction. Only the instructions themselves can contain RIP-relative addresses.
- The first argument to decompress_kernel is called rmode, not boot_param.
- The boot_params struct goes in %rdi, not %rsi. Source: https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI
- find_random_addr does not ensure that the 'memory region is not less than value of kernel alignment'; it ensures the kernel is at or above the minimum load address.