[llvm-dev] Got stuck with PC-rel branching

Peter Bel via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 27 03:31:43 PST 2017


Thanks for telling me to use valgrind, need to be more careful with
switches.
It turned out that MCSymbolRefExpr::create() 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.
That's a bit strange, as there's an assert that symbol is not null, but for
some reason it still let it pass.
Anyway, thanks again, and sorry for asking noobish questions before using
all tools available (debugger, memcheck).

On Thu, Jan 26, 2017 at 8:04 PM, Friedman, Eli <efriedma at codeaurora.org>
wrote:

> On 1/26/2017 9:00 AM, Peter Bel wrote:
>
> Sorry for putting this topic up, but can I ask for your advice once again?
> I'm getting some very strange errors and I can't really understand why. In
> my applyFixup() I have fixup value adjustment, and for fixup PCREL24 I
> have the following simple code:
>
> case Epiphany::fixup_Epiphany_PCREL24
>   Value = Value << 7;
>   break;
>
> When I'm trying to compile a sample binary (any, even without this fixup
> type), it "might fail" on MC/ELFObjectWriter.cpp::
> executePostLayoutBinding():392, which is called from
> MCAssembler.cpp::layout(). If fails on the following line:
> const auto &Alias = cast<MCSymbolELF>(A);
>
> "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. Value = Value, 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.
>
> I've checked that it fails because MCSymbol &A has A.Kind different from
> 2 (SymbolKindELF), usually it's 1 or 0 (COFF or Unknown).
>
>
> This sounds like memory corruption of some sort... have you tried asan
> and/or valgrind?
>
> -Eli
>
> --
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170127/dedcb576/attachment.html>


More information about the llvm-dev mailing list