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.cpp8
-rw-r--r--llvm/lib/ObjectYAML/WasmYAML.cpp1
3 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 0f8a42aacec..0e122708504 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -857,8 +857,9 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats) {
SectionBookkeeping Section;
startCustomSection(Section, "linking");
- SectionBookkeeping SubSection;
+ encodeULEB128(wasm::WasmMetadataVersion, getStream());
+ SectionBookkeeping SubSection;
if (SymbolInfos.size() != 0) {
startSection(SubSection, wasm::WASM_SYMBOL_TABLE);
encodeULEB128(SymbolInfos.size(), getStream());
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index e6b7dded4e4..61db5d2468a 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -313,6 +313,14 @@ Error WasmObjectFile::parseLinkingSection(const uint8_t *Ptr,
"Linking data must come after code section", object_error::parse_failed);
}
+ LinkingData.Version = readVaruint32(Ptr);
+ if (LinkingData.Version != wasm::WasmMetadataVersion) {
+ return make_error<GenericBinaryError>(
+ "Unexpected metadata version: " + Twine(LinkingData.Version) +
+ " (Expected: " + Twine(wasm::WasmMetadataVersion) + ")",
+ object_error::parse_failed);
+ }
+
while (Ptr < End) {
uint8_t Type = readUint8(Ptr);
uint32_t Size = readVaruint32(Ptr);
diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp
index 72df93b876a..ff75bfc7676 100644
--- a/llvm/lib/ObjectYAML/WasmYAML.cpp
+++ b/llvm/lib/ObjectYAML/WasmYAML.cpp
@@ -57,6 +57,7 @@ static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
commonSectionMapping(IO, Section);
IO.mapRequired("Name", Section.Name);
+ IO.mapRequired("Version", Section.Version);
IO.mapOptional("SymbolTable", Section.SymbolTable);
IO.mapOptional("SegmentInfo", Section.SegmentInfos);
IO.mapOptional("InitFunctions", Section.InitFunctions);
OpenPOWER on IntegriCloud