diff options
-rw-r--r-- | src/binaryen-c.cpp | 4 | ||||
-rw-r--r-- | src/ir/module-utils.h | 2 | ||||
-rw-r--r-- | src/passes/Print.cpp | 2 | ||||
-rw-r--r-- | src/passes/Strip.cpp | 20 | ||||
-rw-r--r-- | src/wasm-binary.h | 14 | ||||
-rw-r--r-- | src/wasm.h | 4 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 180 | ||||
-rw-r--r-- | src/wasm/wasm-debug.cpp | 8 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 4 |
9 files changed, 119 insertions, 119 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 5fd5be5e5..e28b9fb77 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -6062,10 +6062,10 @@ void BinaryenAddCustomSection(BinaryenModuleRef module, const char* name, const char* contents, BinaryenIndex contentsSize) { - wasm::UserSection customSection; + wasm::CustomSection customSection; customSection.name = name; customSection.data = std::vector<char>(contents, contents + contentsSize); - ((Module*)module)->userSections.push_back(customSection); + ((Module*)module)->customSections.push_back(customSection); } // diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index f68e2a961..aba5b1ec6 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -160,7 +160,7 @@ inline void copyModule(const Module& in, Module& out) { copyDataSegment(curr.get(), out); } out.start = in.start; - out.userSections = in.userSections; + out.customSections = in.customSections; out.debugInfoFileNames = in.debugInfoFileNames; out.features = in.features; out.typeNames = in.typeNames; diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 6dbd54e73..d4b86f93d 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -3370,7 +3370,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { if (curr->dylinkSection) { printDylinkSection(curr->dylinkSection); } - for (auto& section : curr->userSections) { + for (auto& section : curr->customSections) { doIndent(o, indent); o << ";; custom section \"" << section.name << "\", size " << section.data.size(); diff --git a/src/passes/Strip.cpp b/src/passes/Strip.cpp index fe3476202..19bc099de 100644 --- a/src/passes/Strip.cpp +++ b/src/passes/Strip.cpp @@ -31,19 +31,19 @@ struct Strip : public Pass { bool requiresNonNullableLocalFixups() override { return false; } // A function that returns true if the method should be removed. - using Decider = std::function<bool(UserSection&)>; + using Decider = std::function<bool(CustomSection&)>; Decider decider; Strip(Decider decider) : decider(decider) {} void run(Module* module) override { // Remove name and debug sections. - auto& sections = module->userSections; + auto& sections = module->customSections; sections.erase(std::remove_if(sections.begin(), sections.end(), decider), sections.end()); // If we're cleaning up debug info, clear on the function and module too. - UserSection temp; - temp.name = BinaryConsts::UserSections::Name; + CustomSection temp; + temp.name = BinaryConsts::CustomSections::Name; if (decider(temp)) { module->clearDebugInfo(); for (auto& func : module->functions) { @@ -55,22 +55,22 @@ struct Strip : public Pass { }; Pass* createStripDebugPass() { - return new Strip([&](const UserSection& curr) { - return curr.name == BinaryConsts::UserSections::Name || - curr.name == BinaryConsts::UserSections::SourceMapUrl || + return new Strip([&](const CustomSection& curr) { + return curr.name == BinaryConsts::CustomSections::Name || + curr.name == BinaryConsts::CustomSections::SourceMapUrl || curr.name.find(".debug") == 0 || curr.name.find("reloc..debug") == 0; }); } Pass* createStripDWARFPass() { - return new Strip([&](const UserSection& curr) { + return new Strip([&](const CustomSection& curr) { return curr.name.find(".debug") == 0 || curr.name.find("reloc..debug") == 0; }); } Pass* createStripProducersPass() { - return new Strip([&](const UserSection& curr) { - return curr.name == BinaryConsts::UserSections::Producers; + return new Strip([&](const CustomSection& curr) { + return curr.name == BinaryConsts::CustomSections::Producers; }); } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index acde624f7..cc291f163 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -314,7 +314,7 @@ namespace BinaryConsts { enum Meta { Magic = 0x6d736100, Version = 0x01 }; enum Section { - User = 0, + Custom = 0, Type = 1, Import = 2, Function = 3, @@ -423,7 +423,7 @@ enum EncodedHeapType { none = -0x1b, // 0x65 }; -namespace UserSections { +namespace CustomSections { extern const char* Name; extern const char* SourceMapUrl; extern const char* Dylink; @@ -470,7 +470,7 @@ enum Subsection { DylinkNeeded = 2, }; -} // namespace UserSections +} // namespace CustomSections enum ASTNodes { Unreachable = 0x00, @@ -1300,7 +1300,7 @@ public: Address initial, Address maximum, bool hasMaximum, bool shared, bool is64); template<typename T> int32_t startSection(T code); void finishSection(int32_t start); - int32_t startSubsection(BinaryConsts::UserSections::Subsection code); + int32_t startSubsection(BinaryConsts::CustomSections::Subsection code); void finishSubsection(int32_t start); void writeStart(); void writeMemories(); @@ -1330,8 +1330,8 @@ public: void writeNames(); void writeSourceMapUrl(); void writeSymbolMap(); - void writeLateUserSections(); - void writeUserSection(const UserSection& section); + void writeLateCustomSections(); + void writeCustomSection(const CustomSection& section); void writeFeaturesSection(); void writeDylinkSection(); void writeLegacyDylinkSection(); @@ -1451,7 +1451,7 @@ public: skipFunctionBodies = skipFunctionBodies_; } void read(); - void readUserSection(size_t payloadLen); + void readCustomSection(size_t payloadLen); bool more() { return pos < input.size(); } diff --git a/src/wasm.h b/src/wasm.h index b37fdeb1b..56dfa1ff2 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2121,7 +2121,7 @@ public: // "Opaque" data, not part of the core wasm spec, that is held in binaries. // May be parsed/handled by utility code elsewhere, but not in wasm.h -class UserSection { +class CustomSection { public: std::string name; std::vector<char> data; @@ -2151,7 +2151,7 @@ public: Name start; - std::vector<UserSection> userSections; + std::vector<CustomSection> customSections; // Optional user section IR representation. std::unique_ptr<DylinkSection> dylinkSection; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 782979520..3cceaef46 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -86,7 +86,7 @@ void WasmBinaryWriter::write() { } #endif - writeLateUserSections(); + writeLateCustomSections(); writeFeaturesSection(); } @@ -186,8 +186,8 @@ void WasmBinaryWriter::finishSection(int32_t start) { } } -int32_t -WasmBinaryWriter::startSubsection(BinaryConsts::UserSections::Subsection code) { +int32_t WasmBinaryWriter::startSubsection( + BinaryConsts::CustomSections::Subsection code) { return startSection(code); } @@ -799,13 +799,13 @@ void WasmBinaryWriter::writeTags() { void WasmBinaryWriter::writeNames() { BYN_TRACE("== writeNames\n"); - auto start = startSection(BinaryConsts::Section::User); - writeInlineString(BinaryConsts::UserSections::Name); + auto start = startSection(BinaryConsts::Section::Custom); + writeInlineString(BinaryConsts::CustomSections::Name); // module name if (emitModuleName && wasm->name.is()) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameModule); + startSubsection(BinaryConsts::CustomSections::Subsection::NameModule); writeEscapedName(wasm->name.str); finishSubsection(substart); } @@ -819,7 +819,7 @@ void WasmBinaryWriter::writeNames() { // function names { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameFunction); + startSubsection(BinaryConsts::CustomSections::Subsection::NameFunction); o << U32LEB(indexes.functionIndexes.size()); Index emitted = 0; auto add = [&](Function* curr) { @@ -855,7 +855,7 @@ void WasmBinaryWriter::writeNames() { if (functionsWithLocalNames.size() > 0) { // Otherwise emit those functions but only include locals with a name. auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameLocal); + startSubsection(BinaryConsts::CustomSections::Subsection::NameLocal); o << U32LEB(functionsWithLocalNames.size()); Index emitted = 0; for (auto& [index, func] : functionsWithLocalNames) { @@ -906,7 +906,7 @@ void WasmBinaryWriter::writeNames() { } if (!namedTypes.empty()) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameType); + startSubsection(BinaryConsts::CustomSections::Subsection::NameType); o << U32LEB(namedTypes.size()); for (auto type : namedTypes) { o << U32LEB(indexedTypes.indices[type]); @@ -932,7 +932,7 @@ void WasmBinaryWriter::writeNames() { if (tablesWithNames.size() > 0) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameTable); + startSubsection(BinaryConsts::CustomSections::Subsection::NameTable); o << U32LEB(tablesWithNames.size()); for (auto& [index, table] : tablesWithNames) { @@ -959,7 +959,7 @@ void WasmBinaryWriter::writeNames() { assert(checked == indexes.memoryIndexes.size()); if (memoriesWithNames.size() > 0) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameMemory); + startSubsection(BinaryConsts::CustomSections::Subsection::NameMemory); o << U32LEB(memoriesWithNames.size()); for (auto& [index, memory] : memoriesWithNames) { o << U32LEB(index); @@ -984,7 +984,7 @@ void WasmBinaryWriter::writeNames() { assert(checked == indexes.globalIndexes.size()); if (globalsWithNames.size() > 0) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameGlobal); + startSubsection(BinaryConsts::CustomSections::Subsection::NameGlobal); o << U32LEB(globalsWithNames.size()); for (auto& [index, global] : globalsWithNames) { o << U32LEB(index); @@ -1008,7 +1008,7 @@ void WasmBinaryWriter::writeNames() { if (elemsWithNames.size() > 0) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameElem); + startSubsection(BinaryConsts::CustomSections::Subsection::NameElem); o << U32LEB(elemsWithNames.size()); for (auto& [index, elem] : elemsWithNames) { @@ -1031,7 +1031,7 @@ void WasmBinaryWriter::writeNames() { if (count) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameData); + startSubsection(BinaryConsts::CustomSections::Subsection::NameData); o << U32LEB(count); for (Index i = 0; i < wasm->dataSegments.size(); i++) { auto& seg = wasm->dataSegments[i]; @@ -1058,7 +1058,7 @@ void WasmBinaryWriter::writeNames() { } if (!relevantTypes.empty()) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameField); + startSubsection(BinaryConsts::CustomSections::Subsection::NameField); o << U32LEB(relevantTypes.size()); for (Index i = 0; i < relevantTypes.size(); i++) { auto type = relevantTypes[i]; @@ -1086,7 +1086,7 @@ void WasmBinaryWriter::writeNames() { if (count) { auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::NameTag); + startSubsection(BinaryConsts::CustomSections::Subsection::NameTag); o << U32LEB(count); for (Index i = 0; i < wasm->tags.size(); i++) { auto& tag = wasm->tags[i]; @@ -1104,8 +1104,8 @@ void WasmBinaryWriter::writeNames() { void WasmBinaryWriter::writeSourceMapUrl() { BYN_TRACE("== writeSourceMapUrl\n"); - auto start = startSection(BinaryConsts::Section::User); - writeInlineString(BinaryConsts::UserSections::SourceMapUrl); + auto start = startSection(BinaryConsts::Section::Custom); + writeInlineString(BinaryConsts::CustomSections::SourceMapUrl); writeInlineString(sourceMapUrl.c_str()); finishSection(start); } @@ -1173,16 +1173,16 @@ void WasmBinaryWriter::writeSourceMapEpilog() { *sourceMap << "\"}"; } -void WasmBinaryWriter::writeLateUserSections() { - for (auto& section : wasm->userSections) { - if (section.name != BinaryConsts::UserSections::Dylink) { - writeUserSection(section); +void WasmBinaryWriter::writeLateCustomSections() { + for (auto& section : wasm->customSections) { + if (section.name != BinaryConsts::CustomSections::Dylink) { + writeCustomSection(section); } } } -void WasmBinaryWriter::writeUserSection(const UserSection& section) { - auto start = startSection(BinaryConsts::User); +void WasmBinaryWriter::writeCustomSection(const CustomSection& section) { + auto start = startSection(BinaryConsts::Custom); writeInlineString(section.name.c_str()); for (size_t i = 0; i < section.data.size(); i++) { o << uint8_t(section.data[i]); @@ -1200,37 +1200,37 @@ void WasmBinaryWriter::writeFeaturesSection() { auto toString = [](FeatureSet::Feature f) { switch (f) { case FeatureSet::Atomics: - return BinaryConsts::UserSections::AtomicsFeature; + return BinaryConsts::CustomSections::AtomicsFeature; case FeatureSet::MutableGlobals: - return BinaryConsts::UserSections::MutableGlobalsFeature; + return BinaryConsts::CustomSections::MutableGlobalsFeature; case FeatureSet::TruncSat: - return BinaryConsts::UserSections::TruncSatFeature; + return BinaryConsts::CustomSections::TruncSatFeature; case FeatureSet::SIMD: - return BinaryConsts::UserSections::SIMD128Feature; + return BinaryConsts::CustomSections::SIMD128Feature; case FeatureSet::BulkMemory: - return BinaryConsts::UserSections::BulkMemoryFeature; + return BinaryConsts::CustomSections::BulkMemoryFeature; case FeatureSet::SignExt: - return BinaryConsts::UserSections::SignExtFeature; + return BinaryConsts::CustomSections::SignExtFeature; case FeatureSet::ExceptionHandling: - return BinaryConsts::UserSections::ExceptionHandlingFeature; + return BinaryConsts::CustomSections::ExceptionHandlingFeature; case FeatureSet::TailCall: - return BinaryConsts::UserSections::TailCallFeature; + return BinaryConsts::CustomSections::TailCallFeature; case FeatureSet::ReferenceTypes: - return BinaryConsts::UserSections::ReferenceTypesFeature; + return BinaryConsts::CustomSections::ReferenceTypesFeature; case FeatureSet::Multivalue: - return BinaryConsts::UserSections::MultivalueFeature; + return BinaryConsts::CustomSections::MultivalueFeature; case FeatureSet::GC: - return BinaryConsts::UserSections::GCFeature; + return BinaryConsts::CustomSections::GCFeature; case FeatureSet::Memory64: - return BinaryConsts::UserSections::Memory64Feature; + return BinaryConsts::CustomSections::Memory64Feature; case FeatureSet::RelaxedSIMD: - return BinaryConsts::UserSections::RelaxedSIMDFeature; + return BinaryConsts::CustomSections::RelaxedSIMDFeature; case FeatureSet::ExtendedConst: - return BinaryConsts::UserSections::ExtendedConstFeature; + return BinaryConsts::CustomSections::ExtendedConstFeature; case FeatureSet::Strings: - return BinaryConsts::UserSections::StringsFeature; + return BinaryConsts::CustomSections::StringsFeature; case FeatureSet::MultiMemories: - return BinaryConsts::UserSections::MultiMemoriesFeature; + return BinaryConsts::CustomSections::MultiMemoriesFeature; default: WASM_UNREACHABLE("unexpected feature flag"); } @@ -1240,8 +1240,8 @@ void WasmBinaryWriter::writeFeaturesSection() { wasm->features.iterFeatures( [&](FeatureSet::Feature f) { features.push_back(toString(f)); }); - auto start = startSection(BinaryConsts::User); - writeInlineString(BinaryConsts::UserSections::TargetFeatures); + auto start = startSection(BinaryConsts::Custom); + writeInlineString(BinaryConsts::CustomSections::TargetFeatures); o << U32LEB(features.size()); for (auto& f : features) { o << uint8_t(BinaryConsts::FeatureUsed); @@ -1255,8 +1255,8 @@ void WasmBinaryWriter::writeLegacyDylinkSection() { return; } - auto start = startSection(BinaryConsts::User); - writeInlineString(BinaryConsts::UserSections::Dylink); + auto start = startSection(BinaryConsts::Custom); + writeInlineString(BinaryConsts::CustomSections::Dylink); o << U32LEB(wasm->dylinkSection->memorySize); o << U32LEB(wasm->dylinkSection->memoryAlignment); o << U32LEB(wasm->dylinkSection->tableSize); @@ -1278,11 +1278,11 @@ void WasmBinaryWriter::writeDylinkSection() { return; } - auto start = startSection(BinaryConsts::User); - writeInlineString(BinaryConsts::UserSections::Dylink0); + auto start = startSection(BinaryConsts::Custom); + writeInlineString(BinaryConsts::CustomSections::Dylink0); auto substart = - startSubsection(BinaryConsts::UserSections::Subsection::DylinkMemInfo); + startSubsection(BinaryConsts::CustomSections::Subsection::DylinkMemInfo); o << U32LEB(wasm->dylinkSection->memorySize); o << U32LEB(wasm->dylinkSection->memoryAlignment); o << U32LEB(wasm->dylinkSection->tableSize); @@ -1291,7 +1291,7 @@ void WasmBinaryWriter::writeDylinkSection() { if (wasm->dylinkSection->neededDynlibs.size()) { substart = - startSubsection(BinaryConsts::UserSections::Subsection::DylinkNeeded); + startSubsection(BinaryConsts::CustomSections::Subsection::DylinkNeeded); o << U32LEB(wasm->dylinkSection->neededDynlibs.size()); for (auto& neededDynlib : wasm->dylinkSection->neededDynlibs) { writeInlineString(neededDynlib.str); @@ -1592,7 +1592,7 @@ bool WasmBinaryBuilder::hasDWARFSections() { throwError("Section extends beyond end of input"); } auto oldPos = pos; - if (sectionCode == BinaryConsts::Section::User) { + if (sectionCode == BinaryConsts::Section::Custom) { auto sectionName = getInlineString(); if (Debug::isDWARFSection(sectionName)) { has = true; @@ -1632,7 +1632,7 @@ void WasmBinaryBuilder::read() { // note the section in the list of seen sections, as almost no sections can // appear more than once, and verify those that shouldn't do not. - if (sectionCode != BinaryConsts::Section::User && + if (sectionCode != BinaryConsts::Section::Custom && sectionCode != BinaryConsts::Section::Code) { if (!seenSections.insert(BinaryConsts::Section(sectionCode)).second) { throwError("section seen more than once: " + @@ -1687,7 +1687,7 @@ void WasmBinaryBuilder::read() { readTags(); break; default: { - readUserSection(payloadLen); + readCustomSection(payloadLen); if (pos > oldPos + payloadLen) { throwError("bad user section size, started at " + std::to_string(oldPos) + " plus payload " + @@ -1710,8 +1710,8 @@ void WasmBinaryBuilder::read() { processNames(); } -void WasmBinaryBuilder::readUserSection(size_t payloadLen) { - BYN_TRACE("== readUserSection\n"); +void WasmBinaryBuilder::readCustomSection(size_t payloadLen) { + BYN_TRACE("== readCustomSection\n"); auto oldPos = pos; Name sectionName = getInlineString(); size_t read = pos - oldPos; @@ -1719,27 +1719,27 @@ void WasmBinaryBuilder::readUserSection(size_t payloadLen) { throwError("bad user section size"); } payloadLen -= read; - if (sectionName.equals(BinaryConsts::UserSections::Name)) { + if (sectionName.equals(BinaryConsts::CustomSections::Name)) { if (debugInfo) { readNames(payloadLen); } else { pos += payloadLen; } - } else if (sectionName.equals(BinaryConsts::UserSections::TargetFeatures)) { + } else if (sectionName.equals(BinaryConsts::CustomSections::TargetFeatures)) { readFeatures(payloadLen); - } else if (sectionName.equals(BinaryConsts::UserSections::Dylink)) { + } else if (sectionName.equals(BinaryConsts::CustomSections::Dylink)) { readDylink(payloadLen); - } else if (sectionName.equals(BinaryConsts::UserSections::Dylink0)) { + } else if (sectionName.equals(BinaryConsts::CustomSections::Dylink0)) { readDylink0(payloadLen); } else { // an unfamiliar custom section - if (sectionName.equals(BinaryConsts::UserSections::Linking)) { + if (sectionName.equals(BinaryConsts::CustomSections::Linking)) { std::cerr << "warning: linking section is present, so this is not a standard " "wasm file - binaryen cannot handle this properly!\n"; } - wasm.userSections.resize(wasm.userSections.size() + 1); - auto& section = wasm.userSections.back(); + wasm.customSections.resize(wasm.customSections.size() + 1); + auto& section = wasm.customSections.back(); section.name = sectionName.str; auto data = getByteView(payloadLen); section.data = {data.begin(), data.end()}; @@ -3328,10 +3328,10 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { lastType = nameType; auto subsectionSize = getU32LEB(); auto subsectionPos = pos; - if (nameType == BinaryConsts::UserSections::Subsection::NameModule) { + using Subsection = BinaryConsts::CustomSections::Subsection; + if (nameType == Subsection::NameModule) { wasm.name = getInlineString(); - } else if (nameType == - BinaryConsts::UserSections::Subsection::NameFunction) { + } else if (nameType == Subsection::NameFunction) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3347,7 +3347,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameLocal) { + } else if (nameType == Subsection::NameLocal) { auto numFuncs = getU32LEB(); for (size_t i = 0; i < numFuncs; i++) { auto funcIndex = getU32LEB(); @@ -3384,7 +3384,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { } } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameType) { + } else if (nameType == Subsection::NameType) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3400,7 +3400,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameTable) { + } else if (nameType == Subsection::NameTable) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3423,7 +3423,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameElem) { + } else if (nameType == Subsection::NameElem) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3440,7 +3440,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameMemory) { + } else if (nameType == Subsection::NameMemory) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3456,7 +3456,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameData) { + } else if (nameType == Subsection::NameData) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3472,7 +3472,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameGlobal) { + } else if (nameType == Subsection::NameGlobal) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3488,7 +3488,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(index) << std::endl; } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameField) { + } else if (nameType == Subsection::NameField) { auto numTypes = getU32LEB(); for (size_t i = 0; i < numTypes; i++) { auto typeIndex = getU32LEB(); @@ -3508,7 +3508,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { } } } - } else if (nameType == BinaryConsts::UserSections::Subsection::NameTag) { + } else if (nameType == Subsection::NameTag) { auto num = getU32LEB(); NameProcessor processor; for (size_t i = 0; i < num; i++) { @@ -3563,37 +3563,37 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { } FeatureSet feature; - if (name == BinaryConsts::UserSections::AtomicsFeature) { + if (name == BinaryConsts::CustomSections::AtomicsFeature) { feature = FeatureSet::Atomics; - } else if (name == BinaryConsts::UserSections::BulkMemoryFeature) { + } else if (name == BinaryConsts::CustomSections::BulkMemoryFeature) { feature = FeatureSet::BulkMemory; - } else if (name == BinaryConsts::UserSections::ExceptionHandlingFeature) { + } else if (name == BinaryConsts::CustomSections::ExceptionHandlingFeature) { feature = FeatureSet::ExceptionHandling; - } else if (name == BinaryConsts::UserSections::MutableGlobalsFeature) { + } else if (name == BinaryConsts::CustomSections::MutableGlobalsFeature) { feature = FeatureSet::MutableGlobals; - } else if (name == BinaryConsts::UserSections::TruncSatFeature) { + } else if (name == BinaryConsts::CustomSections::TruncSatFeature) { feature = FeatureSet::TruncSat; - } else if (name == BinaryConsts::UserSections::SignExtFeature) { + } else if (name == BinaryConsts::CustomSections::SignExtFeature) { feature = FeatureSet::SignExt; - } else if (name == BinaryConsts::UserSections::SIMD128Feature) { + } else if (name == BinaryConsts::CustomSections::SIMD128Feature) { feature = FeatureSet::SIMD; - } else if (name == BinaryConsts::UserSections::TailCallFeature) { + } else if (name == BinaryConsts::CustomSections::TailCallFeature) { feature = FeatureSet::TailCall; - } else if (name == BinaryConsts::UserSections::ReferenceTypesFeature) { + } else if (name == BinaryConsts::CustomSections::ReferenceTypesFeature) { feature = FeatureSet::ReferenceTypes; - } else if (name == BinaryConsts::UserSections::MultivalueFeature) { + } else if (name == BinaryConsts::CustomSections::MultivalueFeature) { feature = FeatureSet::Multivalue; - } else if (name == BinaryConsts::UserSections::GCFeature) { + } else if (name == BinaryConsts::CustomSections::GCFeature) { feature = FeatureSet::GC; - } else if (name == BinaryConsts::UserSections::Memory64Feature) { + } else if (name == BinaryConsts::CustomSections::Memory64Feature) { feature = FeatureSet::Memory64; - } else if (name == BinaryConsts::UserSections::RelaxedSIMDFeature) { + } else if (name == BinaryConsts::CustomSections::RelaxedSIMDFeature) { feature = FeatureSet::RelaxedSIMD; - } else if (name == BinaryConsts::UserSections::ExtendedConstFeature) { + } else if (name == BinaryConsts::CustomSections::ExtendedConstFeature) { feature = FeatureSet::ExtendedConst; - } else if (name == BinaryConsts::UserSections::StringsFeature) { + } else if (name == BinaryConsts::CustomSections::StringsFeature) { feature = FeatureSet::Strings; - } else if (name == BinaryConsts::UserSections::MultiMemoriesFeature) { + } else if (name == BinaryConsts::CustomSections::MultiMemoriesFeature) { feature = FeatureSet::MultiMemories; } else { // Silently ignore unknown features (this may be and old binaryen running @@ -3651,13 +3651,13 @@ void WasmBinaryBuilder::readDylink0(size_t payloadLen) { lastType = dylinkType; auto subsectionSize = getU32LEB(); auto subsectionPos = pos; - if (dylinkType == BinaryConsts::UserSections::Subsection::DylinkMemInfo) { + if (dylinkType == BinaryConsts::CustomSections::Subsection::DylinkMemInfo) { wasm.dylinkSection->memorySize = getU32LEB(); wasm.dylinkSection->memoryAlignment = getU32LEB(); wasm.dylinkSection->tableSize = getU32LEB(); wasm.dylinkSection->tableAlignment = getU32LEB(); } else if (dylinkType == - BinaryConsts::UserSections::Subsection::DylinkNeeded) { + BinaryConsts::CustomSections::Subsection::DylinkNeeded) { size_t numNeededDynlibs = getU32LEB(); for (size_t i = 0; i < numNeededDynlibs; ++i) { wasm.dylinkSection->neededDynlibs.push_back(getInlineString()); diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp index 8ca06b04d..abe1cd05c 100644 --- a/src/wasm/wasm-debug.cpp +++ b/src/wasm/wasm-debug.cpp @@ -34,7 +34,7 @@ namespace wasm::Debug { bool isDWARFSection(Name name) { return name.startsWith(".debug_"); } bool hasDWARFSections(const Module& wasm) { - for (auto& section : wasm.userSections) { + for (auto& section : wasm.customSections) { if (isDWARFSection(section.name)) { return true; } @@ -53,7 +53,7 @@ struct BinaryenDWARFInfo { BinaryenDWARFInfo(const Module& wasm) { // Get debug sections from the wasm. - for (auto& section : wasm.userSections) { + for (auto& section : wasm.customSections) { if (Name(section.name).startsWith(".debug_") && section.data.data()) { // TODO: efficiency sections[section.name.substr(1)] = llvm::MemoryBuffer::getMemBufferCopy( @@ -75,7 +75,7 @@ void dumpDWARF(const Module& wasm) { BinaryenDWARFInfo info(wasm); std::cout << "DWARF debug info\n"; std::cout << "================\n\n"; - for (auto& section : wasm.userSections) { + for (auto& section : wasm.customSections) { if (Name(section.name).startsWith(".debug_")) { std::cout << "Contains section " << section.name << " (" << section.data.size() << " bytes)\n"; @@ -1085,7 +1085,7 @@ void writeDWARFSections(Module& wasm, const BinaryLocations& newLocations) { // Update the custom sections in the wasm. // TODO: efficiency - for (auto& section : wasm.userSections) { + for (auto& section : wasm.customSections) { if (Name(section.name).startsWith(".debug_")) { auto llvmName = section.name.substr(1); if (newSections.count(llvmName)) { diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index a92b62343..604854878 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -27,7 +27,7 @@ Name RETURN_FLOW("*return:)*"); Name NONCONSTANT_FLOW("*nonconstant:)*"); namespace BinaryConsts { -namespace UserSections { +namespace CustomSections { const char* Name = "name"; const char* SourceMapUrl = "sourceMappingURL"; const char* Dylink = "dylink"; @@ -51,7 +51,7 @@ const char* RelaxedSIMDFeature = "relaxed-simd"; const char* ExtendedConstFeature = "extended-const"; const char* StringsFeature = "strings"; const char* MultiMemoriesFeature = "multi-memories"; -} // namespace UserSections +} // namespace CustomSections } // namespace BinaryConsts Name STACK_POINTER("__stack_pointer"); |