Changes

211 bytes added ,  05:28, 31 August 2019
Line 133: Line 133:  
</pre>
 
</pre>
   −
Then, it maps the kernel and applies its .dynamic's relocations.
+
Then, it maps the kernel at the final virtual address.
 
<pre>
 
<pre>
 
// TODO: Fill this out with pseudocode.
 
// TODO: Fill this out with pseudocode.
 
</pre>
 
</pre>
   −
Then, it calls the kernel's libc .init_array functions.
+
Then, it applies the kernel's .dynamic relocations and calls the kernel's libc .init_array functions.
 
<pre>
 
<pre>
// This is standard libc init_array code, but called for the kernel's binary instead of kernelldr's.
+
    // Applies all R_AARCH64_RELATIVE relocations.
for (uintptr_t cur_func = final_virtual_kernel_base + init_array_offset; cur_func < final_virtual_kernel_base + init_array_end_offset; cur_func += 8) {
+
    KernelLdr_ApplyRelocations(final_kernel_virtual_base, final_kernel_virtual_base + dynamic_offset);
    ((void (*)(void))(*(uint64_t *)cur_func)();
+
   
}
+
    // This is standard libc init_array code, but called for the kernel's binary instead of kernelldr's.
 +
    for (uintptr_t cur_func = final_virtual_kernel_base + init_array_offset; cur_func < final_virtual_kernel_base + init_array_end_offset; cur_func += 8) {
 +
        ((void (*)(void))(*(uint64_t *)cur_func)();
 +
    }
 
</pre>
 
</pre>