[llvm-dev] Linking Linux kernel with LLD
Dmitry Golovin via llvm-dev
llvm-dev at lists.llvm.org
Mon Jan 23 08:16:34 PST 2017
>> - D28094 (Implemented support for R_386_PC8/R_386_8 relocations)
> Do you remember where it was used ?
setup.elf:
ld.lld -m elf_i386 -T arch/x86/boot/setup.ld arch/x86/boot/a20.o arch/x86/boot/bioscall.o arch/x86/boot/cmdline.o arch/x86/boot/copy.o arch/x86/boot/cpu.o arch/x86/boot/cpuflags.o arch/x86/boot/cpucheck.o arch/x86/boot/early_serial_console.o arch/x86/boot/edd.o arch/x86/boot/header.o arch/x86/boot/main.o arch/x86/boot/mca.o arch/x86/boot/memory.o arch/x86/boot/pm.o arch/x86/boot/pmjump.o arch/x86/boot/printf.o arch/x86/boot/regs.o arch/x86/boot/string.o arch/x86/boot/tty.o arch/x86/boot/video.o arch/x86/boot/video-mode.o arch/x86/boot/version.o arch/x86/boot/video-vga.o arch/x86/boot/video-vesa.o arch/x86/boot/video-bios.o -o arch/x86/boot/setup.elf
ld.lld: error: do not know how to handle relocation 'R_386_PC8' (23)
> I updated patch for --emit-relocs, now they do not fail.
Thanks, applied it, doesn't fail.
I still didn't do anything with "Setup too big!" problem, just commented out the assert. Tried booting the resulting bzImage and vmlinux with qemu. The bzImage only did reboot over and over, but the vmlinux did show an adorable picture (attached).
Regards,
Dmitry
20.01.2017, 22:49, "Dmitry Golovin via llvm-dev" <llvm-dev at lists.llvm.org>:
>>> - D28094 (Implemented support for R_386_PC8/R_386_8 relocations)
>> Do you remember where it was used ?
>
> I can undo the patch (but I can access the build machine only on Monday) and see what breaks.
>
>> CONSTRUCTORS can be just removed, they do nothing for ELF.
>
> Okay, this is what I did (I thought it will break things, but it is okay). I will apply the patch.
>
>> LLD does not support "symbol = 5*6", but accepts "symbol = 5 * 6" currently. Not sure what is easy fix here.
>
> Just ignore it for now, it's not really a big deal.
>
>> I updated patch for --emit-relocs, now they do not fail: https://reviews.llvm.org/D28612
>
> Thank you, I will apply the updated patch and hope that it will boot.
>
> Regards,
> Dmitry
>
> 20.01.2017, 18:36, "George Rimar" <grimar at accesssoftek.com>:
>> Hi Dmitry,
>>
>> 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 :)
>>
>> George.
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qemu_vmlinux.png
Type: image/png
Size: 40347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170123/ca800383/attachment-0001.png>
More information about the llvm-dev
mailing list