<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 23, 2017 at 8:16 AM, Dmitry Golovin via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">>> - D28094 (Implemented support for R_386_PC8/R_386_8 relocations)<br>
> Do you remember where it was used ?<br>
<br>
</span>setup.elf:<br>
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_<wbr>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<br>
ld.lld: error: do not know how to handle relocation 'R_386_PC8' (23)<br>
<br>
> I updated patch for --emit-relocs, now they do not fail.<br>
<br>
Thanks, applied it, doesn't fail.<br>
<br>
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).<br></blockquote><div><br></div><div><div><br class="gmail-Apple-interchange-newline">That's beautiful! Looks like some kernel or loader text got copied into the VGA text buffer. Those "e with two dots above" looks like Code Page 437 (<a href="https://en.wikipedia.org/wiki/Code_page_437">https://en.wikipedia.org/wiki/Code_page_437</a>) for 0x89 which is a common MOV opcode in x86 machine code. "Capital H" and "capital Phi" also look like common x86 opcodes.</div><div><br></div><div>I remember when we were getting the FreeBSD kernel to link correctly, one of the bugs was that the kernel load address was too low (because of our MAXPAGESIZE value) which meant that the location where the kernel was asking to be copied into actually overlapped the bootloader's text, which ended about as well as you would expect it to. We didn't get a pretty picture though :)</div><div><br></div><div>-- Sean Silva</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regards,<br>
Dmitry<br>
<br>
20.01.2017, 22:49, "Dmitry Golovin via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>>:<br>
<div class="gmail-HOEnZb"><div class="gmail-h5">>>> - D28094 (Implemented support for R_386_PC8/R_386_8 relocations)<br>
>> Do you remember where it was used ?<br>
><br>
> I can undo the patch (but I can access the build machine only on Monday) and see what breaks.<br>
><br>
>> CONSTRUCTORS can be just removed, they do nothing for ELF.<br>
><br>
> Okay, this is what I did (I thought it will break things, but it is okay). I will apply the patch.<br>
><br>
>> LLD does not support "symbol = 5*6", but accepts "symbol = 5 * 6" currently. Not sure what is easy fix here.<br>
><br>
> Just ignore it for now, it's not really a big deal.<br>
><br>
>> I updated patch for --emit-relocs, now they do not fail: <a href="https://reviews.llvm.org/D28612" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28612</a><br>
><br>
> Thank you, I will apply the updated patch and hope that it will boot.<br>
><br>
> Regards,<br>
> Dmitry<br>
><br>
> 20.01.2017, 18:36, "George Rimar" <<a href="mailto:grimar@accesssoftek.com">grimar@accesssoftek.com</a>>:<br>
>> Hi Dmitry,<br>
>><br>
>> thanls for sharing. Few comments/questions below:<br>
>><br>
>>> 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):<br>
>>><br>
>>> 1. LLD patches:<br>
>><br>
>> > - D28094 (Implemented support for R_386_PC8/R_386_8 relocations)<br>
>><br>
>> Do you remember where it was used ?<br>
>><br>
>>> 5. In arch/x86/kernel/vmlinux.lds.S commented out the "CONSTRUCTORS", because LLD doesn't support it.<br>
>><br>
>> It is <a href="https://reviews.llvm.org/D28951" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28951</a>. CONSTRUCTORS can be just removed, they do nothing for ELF.<br>
>><br>
>>> 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.<br>
>><br>
>> It is actually not relative with ASSERT. LLD does not support "symbol = 5*6", but accepts "symbol = 5 * 6" currently.<br>
>> Not sure what is easy fix here.<br>
>><br>
>>> 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.<br>
>><br>
>> I updated patch for --emit-relocs, now they do not fail: <a href="https://reviews.llvm.org/D28612" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28612</a><br>
>> It looks to be important feature for self relocations, so it is not surprising it did not run without :)<br>
>><br>
>> George.<br>
><br>
> ______________________________<wbr>_________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>