<div dir="ltr"><div>Sorry for putting this topic up, but can I ask for your advice once again? <br>I'm getting some very strange errors and I can't really understand why. In my <span style="font-family:monospace,monospace">applyFixup() </span>I have fixup value adjustment, and for fixup <span style="font-family:monospace,monospace">PCREL24 </span>I have the following simple code:<br></div><div><br><span style="font-family:monospace,monospace">case Epiphany::fixup_Epiphany_PCREL24<br> Value = Value << 7;<br></span></div><div><span style="font-family:monospace,monospace"> break;</span><br></div><div><br></div><div>When I'm trying to compile a sample binary (any, even without this fixup type), it "might fail" on <span style="font-family:monospace,monospace">MC/ELFObjectWriter.cpp::executePostLayoutBinding():392</span>, which is called from <span style="font-family:monospace,monospace">MCAssembler.cpp::layout()</span>. If fails on the following line:<br></div><div><span style="font-family:monospace,monospace">const auto &Alias = cast<MCSymbolELF>(A);<br><br></span></div><div>"Might fail" - because it doesn't fail every time. I can change some other completely unrelated piece of code - and suddenly it'll fail. If I'll change it to smth else, e.g. <span style="font-family:monospace,monospace">Value = Value</span>, it won't fail, but it still "might fail" after some other change. Sometimes it can fail on different lines, sometimes it can even pass through on the first run and fail on the second.<br><br>I've checked that it fails because <span style="font-family:monospace,monospace">MCSymbol &A </span>has <span style="font-family:monospace,monospace">A.Kind </span>different from 2 (<span style="font-family:monospace,monospace">SymbolKindELF</span>), usually it's 1 or 0 (COFF or Unknown).<br></div><div>Why it dumbfolded me heavily is because this code runs before <span style="font-family:monospace,monospace">applyFixup(), </span>not after (verified with the debugger), so in general it should not be affected. Changes made can be purely cosmetic, e.g. adding one more debug output.<br><br></div><div>After running the llc through the debugger, the wrong value is placed while running <span style="font-family:monospace,monospace">MCObjectStreamer::flushPendingLabels()</span>, but I failed to find what causes this failure.<br><br></div><div>Best regards,<br></div><div>Petr<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 7:02 PM, Peter Bel <span dir="ltr"><<a href="mailto:upcfrost@gmail.com" target="_blank">upcfrost@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Big thanks, i've managed to find what's going on. The thing that dumbfolded me a couple of times was that the error was thrown in one of the MCAssembler methods, but never in applyFixup() itself.<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 19, 2017 at 8:46 PM, Friedman, Eli <span dir="ltr"><<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 1/19/2017 10:21 AM, Peter Bel wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
For the function call - yes, probably. But what about branching inside one function (standard if-then for example)?<br>
<br>
For example:<br>
echo "int g() { int a = 1; if (a > 3) return 1; return 0; }" | clang -x c - -o /tmp/a.o -c && objdump -d /tmp/a.o<br>
</blockquote>
<br></span>
Yes, the assembler tries to avoid emitting relocations for relative offsets within a section. See MCAssembler::layout, particularly the bit at the end where it calls applyFixup().<div class="m_-8998960477962065806HOEnZb"><div class="m_-8998960477962065806h5"><br>
<br>
-Eli<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>