<div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">12.10.2018, 10:50, "Carter Cheng" <cartercheng@gmail.com>:</div><blockquote xmlns="http://www.w3.org/1999/xhtml" type="cite"><div>I managed to find some information on this from Prof John Criswell who did something similar for his dissertation but I do wonder how complicated the make files for building the kernel are since the method he used would require using llvm-link to stitch together all the different object files(bitcode) into a single file and then convert them into machine code at one go. </div></blockquote><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">Hello,</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">I don't think it turns into machine code at once and at the bottom Dear Valdis say could be analyzed with a patchset and LTO support last time.</div><div xmlns="http://www.w3.org/1999/xhtml">All object files return step by step to the machine code and  I think we need to understand Andi Kleen's patchset logic.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml"><a href="https://github.com/SveSop/Kernel_LTO">https://github.com/SveSop/Kernel_LTO</a></div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">I'll look at the evening as well.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">Regards</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">Ozgur</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><blockquote xmlns="http://www.w3.org/1999/xhtml" type="cite"><div><div>On Fri, Oct 12, 2018 at 10:20 AM <<a href="mailto:valdis.kletnieks@vt.edu">valdis.kletnieks@vt.edu</a>> wrote:</div><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex;">On Thu, 11 Oct 2018 21:45:16 +0800, Carter Cheng said:<br /><br />> There are some detaills about the current procedures for linking the kernel<br />> that I am unfamiliar with. My understanding is that GCC and Clang both have<br />> the ability to do link time analysis and transforms on code but is it<br />> possible to write link time passes that will run on the kernel since the<br />> linking phase is a bit different (i.e. doesnt produce an ELF file)?<br /><br />The fact that the kernel gets linked is an existence proof that it is possible<br />to do link time processing on the kernel.<br /><br />There's no LTO support in the stock 4.19 tree, but Andi Kleen did a patchset<br />for 4.15, and there's another patchset to enable LTO when using Clang rather<br />than gcc. (I haven't tried either one, don't use on a production machine, as<br />the resulting kernel may crash, eat filesystems, and/or turn your dog green...)<br /><br />Note that 'vmlinux' is a statically linked ELF binary. That  plus a bootstrap<br />code gets merged to create a bzImage or similar thing that can be loaded by<br />Grub2 or whatever boot loader.</blockquote></div></blockquote>