Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm: strip only Custom Sections with precompiled Wasm modules. #13775

Merged
merged 3 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "WebAssembly for Proxies (C++ host implementation)",
project_desc = "WebAssembly for Proxies (C++ host implementation)",
project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-host",
version = "d54b3795e7c3e61015dac2c2110b0da2be999b8e",
sha256 = "e95ad57b6b550b039d4baa35c896f7f523e427b7278ba56f22fac6e1bef8c7f0",
version = "40fd3d03842c07d65fed907a6b6ed0f89d68d531",
sha256 = "b5ae746e66b6209ea0cce86d6c21de99dacbec1da9cdadd53a9ec46bc296a3ba",
strip_prefix = "proxy-wasm-cpp-host-{version}",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
Expand All @@ -842,7 +842,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
"envoy.filters.network.wasm",
"envoy.stat_sinks.wasm",
],
release_date = "2020-10-22",
release_date = "2020-10-27",
cpe = "N/A",
),
emscripten_toolchain = dict(
Expand Down
18 changes: 15 additions & 3 deletions test/tools/wee8_compile/wee8_compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,22 @@ wasm::vec<byte_t> stripWasmModule(const wasm::vec<byte_t>& module) {
std::cerr << "ERROR: Failed to parse corrupted Wasm module." << std::endl;
return wasm::vec<byte_t>::invalid();
}
if (section_type != 0 /* custom section */) {
stripped.insert(stripped.end(), section_start, pos + section_len);
if (section_type == 0 /* custom section */) {
const auto section_data_start = pos;
const auto section_name_len = parseVarint(pos, end);
if (section_name_len == static_cast<uint32_t>(-1) || pos + section_name_len > end) {
std::cerr << "ERROR: Failed to parse corrupted Wasm module." << std::endl;
return wasm::vec<byte_t>::invalid();
}
auto section_name = std::string_view(pos, section_name_len);
if (section_name.find("precompiled_") == std::string::npos) {
stripped.insert(stripped.end(), section_start, section_data_start + section_len);
}
pos = section_data_start + section_len;
} else {
pos += section_len;
stripped.insert(stripped.end(), section_start, pos /* section end */);
}
pos += section_len;
}

return wasm::vec<byte_t>::make(stripped.size(), stripped.data());
Expand Down