summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 9ca239e3b47..01ca73e3230 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1557,15 +1557,16 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
assert(Fixup.getKind() ==
MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
const MCExpr *Expr = Fixup.getValue();
- auto *Sym = dyn_cast<MCSymbolRefExpr>(Expr);
- if (!Sym)
+ auto *SymRef = dyn_cast<MCSymbolRefExpr>(Expr);
+ if (!SymRef)
report_fatal_error("fixups in .init_array should be symbol references");
- if (Sym->getKind() != MCSymbolRefExpr::VK_WebAssembly_FUNCTION)
- report_fatal_error("symbols in .init_array should be for functions");
- if (Sym->getSymbol().getIndex() == InvalidIndex)
+ const auto &TargetSym = cast<const MCSymbolWasm>(SymRef->getSymbol());
+ if (TargetSym.getIndex() == InvalidIndex)
report_fatal_error("symbols in .init_array should exist in symbtab");
+ if (!TargetSym.isFunction())
+ report_fatal_error("symbols in .init_array should be for functions");
InitFuncs.push_back(
- std::make_pair(Priority, Sym->getSymbol().getIndex()));
+ std::make_pair(Priority, TargetSym.getIndex()));
}
}
OpenPOWER on IntegriCloud