link time analysis for the kernel.

valdis.kletnieks at vt.edu valdis.kletnieks at vt.edu
Thu Oct 11 22:20:03 EDT 2018


On Thu, 11 Oct 2018 21:45:16 +0800, Carter Cheng said:

> There are some detaills about the current procedures for linking the kernel
> that I am unfamiliar with. My understanding is that GCC and Clang both have
> the ability to do link time analysis and transforms on code but is it
> possible to write link time passes that will run on the kernel since the
> linking phase is a bit different (i.e. doesnt produce an ELF file)?

The fact that the kernel gets linked is an existence proof that it is possible
to do link time processing on the kernel.

There's no LTO support in the stock 4.19 tree, but Andi Kleen did a patchset
for 4.15, and there's another patchset to enable LTO when using Clang rather
than gcc. (I haven't tried either one, don't use on a production machine, as
the resulting kernel may crash, eat filesystems, and/or turn your dog green...)

Note that 'vmlinux' is a statically linked ELF binary. That  plus a bootstrap
code gets merged to create a bzImage or similar thing that can be loaded by
Grub2 or whatever boot loader.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181011/c8de1582/attachment.sig>


More information about the Kernelnewbies mailing list