<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 28, 2017 at 9:57 AM, Dmitry Golovin <span dir="ltr"><<a href="mailto:dima@golovin.in" target="_blank">dima@golovin.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>At this point I'm able to link Linux kernel with LLD and objcopy doen't give me any errors.</div><div> </div><div>The versions are:</div><div> </div><div>Linux 4.10.0-rc5 (+ applied the patch from my previous message)</div><div>LLD 5.0.0 (<a href="https://github.com/llvm-mirror/lld" target="_blank">https://github.com/llvm-<wbr>mirror/lld</a> db83a5cc3968b3aac1dbe3270190bd<wbr>3282862e74) (+ applied D28612)</div><span class=""><div>GNU objcopy (GNU Binutils) 2.27</div><div> </div></span><div>The problem is that the resulting kernel doesn't boot. Does anybody have any suggestions on how to debug it or any guesses what did go wrong while linking?</div></blockquote><div><br></div><div>As far as different things that can go wrong, some things to consider:</div><div><br></div><div>- LLD's output binary has the same (or similar) data as the BFD/gold output binary. E.g. if the LLD binary is only half as big (or the PT_LOAD's that the booloader looks at are half as bit), LLD might not be putting things into the output or into the right output sections.</div><div><br></div><div>- The bootloader is looking for something in the dynamic symbol table, but it isn't there. LLD might be resolving symbols differently.</div><div><br></div><div>- Section contents are different between LLD and BFD/gold. E.g. for freebsd there is a "linker set" section which contains pointers to a bunch of metadata structs that are needed. LLD was not relocating these correctly because the symbols were not ending up in the output or something like that (I forget exactly; Michael might remember better).</div><div><br></div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div> </div><div>Regards,</div><div>Dmitry</div><div><br></div><div><br></div><div>28.01.2017, 05:48, "Sean Silva via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>:</div><blockquote type="cite"><div><div class="h5"><div dir="ltr"><br><div><br><div>On Fri, Jan 27, 2017 at 1:31 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sean,<div><br></div><div>So as you noticed that linker script tokenization rule is not very trivial -- it is context sensitive. The current lexer is extremely simple and almost always works well. Improving "almost always" to "perfect" is not high priority because we have many more high priority things, but I'm fine if someone improves it. If you are interested, please take it. Or maybe I'll take a look at it. It shouldn't be hard. It's probably just a half day work.</div></div></blockquote><div><br></div><div>Yeah. To be clear, I wasn't saying that this was high priority. Since I'm complaining so much about it maybe I should take a look this weekend :)</div><div> </div><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>As far as I know, the grammar is LL(1), so it needs only one push-back buffer. Handling INCLUDE directive can be a bit tricky though.<br></div><div><br></div><div>Maybe we should rename ScriptParserBase ScriptLexer.</div></div></blockquote><div><br></div><div>That sounds like a good idea.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><br><div>On Fri, Jan 27, 2017 at 11:17 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><span>> Hmm..., the crux of not being able to lex arithmetic expressions seems to<br>
> be due to lack of context sensitivity. E.g. consider `foo*bar`. Could be a<br>
> multiplication, or could be a glob pattern.<br>
><br>
> Looking at the code more closely, adding context sensitivity wouldn't be<br>
> that hard. In fact, our ScriptParserBase class is actually a lexer (look at<br>
> the interface; it is a lexer's interface). It shouldn't be hard to change<br>
> from an up-front tokenization to a more normal lexer approach of scanning<br>
> the text for each call that wants the next token. Roughly speaking, just<br>
> take the body of the for loop inside ScriptParserBase::tokenize and add a<br>
> helper which does that on the fly and is called by consume/next/etc.<br>
> Instead of an index into a token vector, just keep a `const char *` pointer<br>
> that we advance.<br>
><br>
> Once that is done, we can easily add a `nextArithmeticToken` or something<br>
> like that which just lexes with different rules.<br>
<br>
</span>I like that idea. I first thought of always having '*' as a token, but<br>
then space has to be a token, which is an incredible pain.<br>
<br>
I then thought of having a "setLexMode" method, but the lex mode can<br>
always be implicit from where we are in the parser. The parser should<br>
always know if it should call next or nextArithmetic.<br>
<br>
And I agree we should probably implement this. Even if it is not common,<br>
it looks pretty silly to not be able to handle 2*5.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div></div></div>
,<span class=""><p>______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></p></span></blockquote></blockquote></div><br></div></div>