From 15f349f76f076202a8569ffdf15db153168bf4a2 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 9 Mar 2018 16:30:44 +0000 Subject: [WebAssembly] Disallow weak undefined globals in the object format This implements https://github.com/WebAssembly/tool-conventions/pull/47 Differential Revision: https://reviews.llvm.org/D44201 llvm-svn: 327146 --- llvm/lib/Object/WasmObjectFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 3b18e19..65ae063 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("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("undefined weak global symbol", + object_error::parse_failed); if (IsDefined) { Info.Name = readString(Ptr); unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals; -- cgit v1.1