diff options
author | Alon Zakai <azakai@google.com> | 2019-06-18 09:02:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-18 09:02:10 -0700 |
commit | 06698d7a32cb4eeb24fea942e83d1b15e86a73e6 (patch) | |
tree | 8ddba8a6aa67fa527e73154168a2b4f8d7c2e948 | |
parent | 3d3a5a6c28e9266eebcad7315cce96fba6e6dc09 (diff) | |
download | binaryen-06698d7a32cb4eeb24fea942e83d1b15e86a73e6.tar.gz binaryen-06698d7a32cb4eeb24fea942e83d1b15e86a73e6.tar.bz2 binaryen-06698d7a32cb4eeb24fea942e83d1b15e86a73e6.zip |
Make feature section errors into warnings (#2175)
Otherwise there is no way to view a wasm object file in binaryen.
-rw-r--r-- | src/wasm/wasm-binary.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 63321cffe..8804257a4 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2132,9 +2132,11 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { uint8_t prefix = getInt8(); if (prefix != BinaryConsts::FeatureUsed) { if (prefix == BinaryConsts::FeatureRequired) { - throwError("Required features not supported"); + std::cerr + << "warning: required features in feature section are ignored"; } else if (prefix == BinaryConsts::FeatureDisallowed) { - throwError("Disallowed features not supported"); + std::cerr + << "warning: disallowed features in feature section are ignored"; } else { throwError("Unrecognized feature policy prefix"); } @@ -2145,18 +2147,20 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { throwError("ill-formed string extends beyond section"); } - if (name == BinaryConsts::UserSections::AtomicsFeature) { - wasm.features.setAtomics(); - } else if (name == BinaryConsts::UserSections::BulkMemoryFeature) { - wasm.features.setBulkMemory(); - } else if (name == BinaryConsts::UserSections::ExceptionHandlingFeature) { - wasm.features.setExceptionHandling(); - } else if (name == BinaryConsts::UserSections::TruncSatFeature) { - wasm.features.setTruncSat(); - } else if (name == BinaryConsts::UserSections::SignExtFeature) { - wasm.features.setSignExt(); - } else if (name == BinaryConsts::UserSections::SIMD128Feature) { - wasm.features.setSIMD(); + if (prefix != BinaryConsts::FeatureDisallowed) { + if (name == BinaryConsts::UserSections::AtomicsFeature) { + wasm.features.setAtomics(); + } else if (name == BinaryConsts::UserSections::BulkMemoryFeature) { + wasm.features.setBulkMemory(); + } else if (name == BinaryConsts::UserSections::ExceptionHandlingFeature) { + wasm.features.setExceptionHandling(); + } else if (name == BinaryConsts::UserSections::TruncSatFeature) { + wasm.features.setTruncSat(); + } else if (name == BinaryConsts::UserSections::SignExtFeature) { + wasm.features.setSignExt(); + } else if (name == BinaryConsts::UserSections::SIMD128Feature) { + wasm.features.setSIMD(); + } } } if (pos != sectionPos + payloadLen) { |