[llvm-dev] Linking Linux kernel with LLD
George Rimar via llvm-dev
llvm-dev at lists.llvm.org
Fri Feb 17 08:31:16 PST 2017
>>That boot_params.hdr.code32_start field is probably either invalid (bad reloc or something else causing the bootloader to >>calculate the wrong address) or valid but the thing it thinks it is pointing to wasn't loaded (missing PT_LOAD etc.).
>boot_params.hdr.code32_start field is valid :) It is 0x100000, like expected
>
>Then I suspect that that segment isn't being loaded. Is there a PT_LOAD that covers that address? Is the bootloader loading it?
That issue is gone. Not sure what changed, but looks something was fixed in LLD during last week.
Latest status of booting linux kernel is next currently:
At this location,
https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/arch/x86/boot/compressed/head_64.S#L424
kernel calls extract_kernel(). And 2 lines below it tries to jmp to the address of decompressed kernel and fails to do that for me.
extract_kernel() method is:
https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/arch/x86/boot/compressed/misc.c#L334
I added next lines before return:
__putstr("hi from extract_kernel");
if ((int) output == 0x1000000)
__putstr("== 0x1000000");
output[0] = 0xEB;
output[1] = 0xFE;
return output;
And during boot in shows all text from above and enters infinite loop as expected. So, that means it successfully jumps to 0x1000000, but looks something is wrong in decompressed code. Next destination point should be startup_64?.
https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/arch/x86/kernel/head_64.S#L50<https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/arch/x86/kernel/head_64.S#L48>
Though as I mentioned it does not reach it for me.
Next step I probably going to do is dump/printf-trace that memory area of decompressed kernel to compare with what produced there when BFD is used. Have no better ideas now.
George.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170217/a358ea3a/attachment.html>
More information about the llvm-dev
mailing list