Verified Commit 8053699e authored by nagayama15's avatar nagayama15

add an option for preserving DWARF info

parent 34e97b73
...@@ -80,7 +80,7 @@ def copy(file, out) ...@@ -80,7 +80,7 @@ def copy(file, out)
end end
def embed(file, out, method, watermark, chunk_size = 20) def embed(file, out, method, watermark, chunk_size = 20)
output = IO.popen([SNPI, "-o", out.to_s, "-m", method, "-w", watermark, "-c", chunk_size.to_s, file.to_s]).read output = IO.popen([SNPI, "-o", out.to_s, "-m", method, "-w", watermark, "-c", chunk_size.to_s, "-d", file.to_s]).read
puts "embed #{file}, #{out}, #{method}, #{watermark}, #{output}" puts "embed #{file}, #{out}, #{method}, #{watermark}, #{output}"
end end
......
...@@ -21,6 +21,7 @@ int main(int argc, char* argv[]) { ...@@ -21,6 +21,7 @@ int main(int argc, char* argv[]) {
options.add<std::string>("method", 'm', "Embedding method (function-reorder, export-reorder, operand-swap)", true, "", cmdline::oneof<std::string>("function-reorder", "export-reorder", "operand-swap")); options.add<std::string>("method", 'm', "Embedding method (function-reorder, export-reorder, operand-swap)", true, "", cmdline::oneof<std::string>("function-reorder", "export-reorder", "operand-swap"));
options.add<std::string>("watermark", 'w', "Watermark to embed", true); options.add<std::string>("watermark", 'w', "Watermark to embed", true);
options.add<std::size_t>("chunk-size", 'c', "Chunk size [2~20]", false, 20, cmdline::range<std::size_t>(2, 20)); options.add<std::size_t>("chunk-size", 'c', "Chunk size [2~20]", false, 20, cmdline::range<std::size_t>(2, 20));
options.add("debug", 'd', "Preserve debug info");
options.set_program_name(program_name); options.set_program_name(program_name);
options.footer("filename"); options.footer("filename");
...@@ -61,6 +62,7 @@ int main(int argc, char* argv[]) { ...@@ -61,6 +62,7 @@ int main(int argc, char* argv[]) {
const auto method = options.get<std::string>("method"); const auto method = options.get<std::string>("method");
const auto watermark = options.get<std::string>("watermark"); const auto watermark = options.get<std::string>("watermark");
const auto chunk_size = options.get<std::size_t>("chunk-size"); const auto chunk_size = options.get<std::size_t>("chunk-size");
const auto preserve_debug = options.exist("debug");
try { try {
wasm::Module module{}; wasm::Module module{};
...@@ -79,8 +81,9 @@ int main(int argc, char* argv[]) { ...@@ -79,8 +81,9 @@ int main(int argc, char* argv[]) {
WASM_UNREACHABLE(("unknown method: " + method).c_str()); WASM_UNREACHABLE(("unknown method: " + method).c_str());
} }
Colors::setEnabled(false); wasm::ModuleWriter w{};
wasm::ModuleWriter{}.writeBinary(module, output); w.setDebugInfo(preserve_debug);
w.writeBinary(module, output);
fmt::print("{} bits\n", size_bits); fmt::print("{} bits\n", size_bits);
} catch (const std::exception& e) { } catch (const std::exception& e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment