<div dir="ltr"><div>Thanks for telling me to use valgrind, need to be more careful with switches.<br>It turned out that <span style="font-family:monospace,monospace">MCSymbolRefExpr::create() </span>didn't throw any error regardless of what symbol is actually used for the expression. So, null was able to slip through, causing all kinds of problems, including AsmPrinter writing where it shouldn't, and MCAssembler going crazy while trying to resolve the symbol.<br></div><div>That's a bit strange, as there's an assert that symbol is not null, but for some reason it still let it pass.<br></div>Anyway, thanks again, and sorry for asking noobish questions before using all tools available (debugger, memcheck).<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 8:04 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">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><span class="">
    <div class="m_-4690817860852100539moz-cite-prefix">On 1/26/2017 9:00 AM, Peter Bel wrote:<br>
    </div>
    <blockquote type="cite">
      <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_<wbr>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::<wbr>executePostLayoutBinding():392</span><wbr>,
          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>
    </blockquote>
    <br></span>
    This sounds like memory corruption of some sort... have you tried
    asan and/or valgrind?<span class=""><br>
    <br>
    -Eli<br>
    <pre class="m_-4690817860852100539moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </span></div>

</blockquote></div><br></div>