Index: lib/MC/WasmObjectWriter.cpp =================================================================== --- lib/MC/WasmObjectWriter.cpp +++ lib/MC/WasmObjectWriter.cpp @@ -430,9 +430,13 @@ if (SymA && SymA->isVariable()) { const MCExpr *Expr = SymA->getVariableValue(); - const auto *Inner = cast(Expr); - if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) - llvm_unreachable("weakref used in reloc not yet implemented"); + if (Expr->getKind() == MCExpr::SymbolRef) { + const auto *Inner = cast(Expr); + if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) + llvm_unreachable("weakref used in reloc not yet implemented"); + } else { + llvm_unreachable("expression kind not supported"); + } } // Put any constant offset in an addend. Offsets can be negative, and @@ -490,8 +494,12 @@ static const MCSymbolWasm* ResolveSymbol(const MCSymbolWasm& Symbol) { if (Symbol.isVariable()) { const MCExpr *Expr = Symbol.getVariableValue(); - auto *Inner = cast(Expr); - return cast(&Inner->getSymbol()); + if (Expr->getKind() == MCExpr::SymbolRef) { + auto *Inner = cast(Expr); + return cast(&Inner->getSymbol()); + } else { + llvm_unreachable("expression kind not supported"); + } } return &Symbol; }