[llvm-dev] Linking Linux kernel with LLD
George Rimar via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 20 08:35:38 PST 2017
thanls for sharing. Few comments/questions below:
>Here is the list of modifications I had to do in order to link the kernel (I have used llvmlinux with clang and mainline with gcc, the >results are similar):
>1. LLD patches:
> - D28094 (Implemented support for R_386_PC8/R_386_8 relocations)
Do you remember where it was used ?
>5. In arch/x86/kernel/vmlinux.lds.S commented out the "CONSTRUCTORS", because LLD doesn't support it.
It is https://reviews.llvm.org/D28951. CONSTRUCTORS can be just removed, they do nothing for ELF.
>6. In arch/x86/boot/setup.ld replaced 5*512 with precalculated value of 2560 because it doesn't seem that LLD supports math inside >ASSERT in linker scripts.
It is actually not relative with ASSERT. LLD does not support "symbol = 5*6", but accepts "symbol = 5 * 6" currently.
Not sure what is easy fix here.
>Finally the kernel was built and it obviously didn't run (only printed out "No setup signature found..." but this is some result as well). >Probably, the result could be better if the --emit-relocs option didn't fail and CONSTRUCTORS were supported. I really don't know what >to do about the assertion that I have commented out.
I updated patch for --emit-relocs, now they do not fail: https://reviews.llvm.org/D28612
It looks to be important feature for self relocations, so it is not surprising it did not run without :)
More information about the llvm-dev