Open lambda-funcptr opened 1 month ago
Hm, ok, my bad. Placing the initrd right behind the kernel results in corruption of initrd, I've spaced the initrd from the kernel by at minimum 16Mi + kernel size as reasonable selections of magic numbers to make this work.
With kernels larger than 16Mi, it appears that the PE binary will collide the kernel and initrd segments.
This PR uses the kernel size + kernel vma offset + a buffer of 16Mi to calculate the offset required for the initrd section.
I've also bumped the minor version to signal a behavior change, but I'm open to reverting if that's not a good idea. Apologies in advance if this is undercooked, I don't have great intuition on early boot behavior, but it does seem to work.
Here's an example of a large 17Mi+ kernel.
My intuition here that .linux starting at 0x2000000 with size of 0x107c400 means it runs until 0x307c400.
However, initrd is loaded at 0x3000000, so this seems to corrupt the boot process:
With the patched script, I generate a nicer looking PE binary:
This seems to work for booting the kernel I'm building: