Commit 6110c629 authored by nagayama15's avatar nagayama15

Implement the watermark extractor driver

parent 80ae6441
......@@ -14,3 +14,11 @@ add_executable(snpi
target_link_libraries(snpi
kyut
)
add_executable(pisn
pisn.cpp
)
target_link_libraries(pisn
kyut
)
......@@ -3,6 +3,7 @@
#include <cassert>
#include <cstdint>
#include <string_view>
#include <vector>
namespace kyut {
......@@ -24,7 +25,14 @@ namespace kyut {
return data_;
}
[[nodiscard]] std::size_t tell() const noexcept {
[[nodiscard]] std::string_view dataAsString() const {
return std::string_view{
reinterpret_cast<const char *>(data_.data()),
data_.size(),
};
}
[[nodiscard]] std::size_t tell() const noexcept {
return pos_write_;
}
......
#include <fmt/printf.h>
#include <wasm-io.h>
#include "kyut/BitStreamWriter.hpp"
#include "kyut/watermarker/FunctionOrderingWatermarker.hpp"
int main(int argc, char *argv[]) {
// Parse command line options
if (argc != 2) {
fmt::print(std::cerr, "{} <input file>\n", argv[0]);
return 1;
}
const std::string inputFile = argv[1];
try {
// Read the input module
wasm::Module module;
wasm::ModuleReader{}.read(inputFile, module);
// Embed watermarks
kyut::BitStreamWriter stream;
kyut::watermarker::extractFunctionOrdering(module, stream, 10);
// Output watermarks extracted
std::cout << stream.dataAsString();
} catch (const wasm::ParseException &e) {
e.dump(std::cerr);
return 1;
} catch (const std::exception &e) {
fmt::print(std::cerr, "exception: {}\n", e.what());
return 1;
} catch (...) {
fmt::print(std::cerr, "unknown exception\n");
return 1;
}
}
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