summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp3
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp5
2 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 87ef0d927ee..a05948e2946 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1024,6 +1024,9 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
Imports.push_back(Import);
WasmIndices[&WS] = NumFunctionImports++;
} else if (WS.isGlobal()) {
+ if (WS.isWeak())
+ report_fatal_error("undefined global symbol cannot be weak");
+
wasm::WasmImport Import;
Import.Module = WS.getModuleName();
Import.Field = WS.getName();
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 3b18e194d02..65ae0639d4f 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -422,6 +422,11 @@ Error WasmObjectFile::parseLinkingSectionSymtab(const uint8_t *&Ptr,
IsDefined != isDefinedGlobalIndex(Info.ElementIndex))
return make_error<GenericBinaryError>("invalid global symbol index",
object_error::parse_failed);
+ if (!IsDefined &&
+ (Info.Flags & wasm::WASM_SYMBOL_BINDING_MASK) ==
+ wasm::WASM_SYMBOL_BINDING_WEAK)
+ return make_error<GenericBinaryError>("undefined weak global symbol",
+ object_error::parse_failed);
if (IsDefined) {
Info.Name = readString(Ptr);
unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals;
OpenPOWER on IntegriCloud