Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
ad261fcf
Verified
Commit
ad261fcf
authored
Dec 07, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(op_swap): Implement the operand swapping method
parent
8a6f7c11
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
458 additions
and
8 deletions
+458
-8
CMakeLists.txt
lib/CMakeLists.txt
+4
-2
OperandSwapping.cpp
lib/kyut/methods/OperandSwapping.cpp
+421
-0
OperandSwapping.hpp
lib/kyut/methods/OperandSwapping.hpp
+21
-0
pisn.cpp
src/pisn.cpp
+6
-3
snpi.cpp
src/snpi.cpp
+6
-3
No files found.
lib/CMakeLists.txt
View file @
ad261fcf
add_library
(
kyut INTERFACE
)
add_library
(
kyut STATIC
kyut/methods/OperandSwapping.cpp
)
target_include_directories
(
kyut INTERFACE
target_include_directories
(
kyut INTERFACE
"."
"."
)
)
target_link_libraries
(
kyut
INTERFACE
target_link_libraries
(
kyut
binaryen::binaryen
binaryen::binaryen
fmtlib::fmt
fmtlib::fmt
)
)
lib/kyut/methods/OperandSwapping.cpp
0 → 100644
View file @
ad261fcf
This diff is collapsed.
Click to expand it.
lib/kyut/methods/OperandSwapping.hpp
0 → 100644
View file @
ad261fcf
#ifndef INCLUDE_kyut_methods_OperandSwapping_hpp
#define INCLUDE_kyut_methods_OperandSwapping_hpp
#include <cstddef>
namespace
wasm
{
class
Module
;
}
// namespace wasm
namespace
kyut
{
class
CircularBitStreamReader
;
class
BitStreamWriter
;
}
// namespace kyut
namespace
kyut
::
methods
::
operand_swapping
{
std
::
size_t
embed
(
CircularBitStreamReader
&
r
,
wasm
::
Module
&
module
);
std
::
size_t
extract
(
BitStreamWriter
&
w
,
wasm
::
Module
&
module
);
}
// namespace kyut::methods::operand_swapping
#endif // INCLUDE_kyut_methods_OperandSwapping_hpp
src/pisn.cpp
View file @
ad261fcf
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "cmdline.h"
#include "cmdline.h"
#include "kyut/methods/ExportReordering.hpp"
#include "kyut/methods/ExportReordering.hpp"
#include "kyut/methods/FunctionReordering.hpp"
#include "kyut/methods/FunctionReordering.hpp"
#include "kyut/methods/OperandSwapping.hpp"
#include "wasm-io.h"
#include "wasm-io.h"
namespace
{
namespace
{
...
@@ -15,7 +16,7 @@ int main(int argc, char* argv[]) {
...
@@ -15,7 +16,7 @@ int main(int argc, char* argv[]) {
options
.
add
(
"help"
,
'h'
,
"Print help message"
);
options
.
add
(
"help"
,
'h'
,
"Print help message"
);
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
<
std
::
string
>
(
"method"
,
'm'
,
"Embedding method (function-reorder
ing, export-reordering)"
,
true
,
""
,
cmdline
::
oneof
<
std
::
string
>
(
"function-reordering"
,
"export-reordering
"
));
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
::
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
<
std
::
string
>
(
"dump"
,
0
,
"Output format (ascii, hex)"
,
false
,
"ascii"
,
cmdline
::
oneof
<
std
::
string
>
(
"ascii"
,
"hex"
));
options
.
add
<
std
::
string
>
(
"dump"
,
0
,
"Output format (ascii, hex)"
,
false
,
"ascii"
,
cmdline
::
oneof
<
std
::
string
>
(
"ascii"
,
"hex"
));
...
@@ -51,10 +52,12 @@ int main(int argc, char* argv[]) {
...
@@ -51,10 +52,12 @@ int main(int argc, char* argv[]) {
kyut
::
BitStreamWriter
w
{};
kyut
::
BitStreamWriter
w
{};
std
::
size_t
size_bits
;
std
::
size_t
size_bits
;
if
(
method
==
"function-reorder
ing
"
)
{
if
(
method
==
"function-reorder"
)
{
size_bits
=
kyut
::
methods
::
function_reordering
::
extract
(
w
,
module
,
chunk_size
);
size_bits
=
kyut
::
methods
::
function_reordering
::
extract
(
w
,
module
,
chunk_size
);
}
else
if
(
method
==
"export-reorder
ing
"
)
{
}
else
if
(
method
==
"export-reorder"
)
{
size_bits
=
kyut
::
methods
::
export_reordering
::
extract
(
w
,
module
,
chunk_size
);
size_bits
=
kyut
::
methods
::
export_reordering
::
extract
(
w
,
module
,
chunk_size
);
}
else
if
(
method
==
"operand-swap"
)
{
size_bits
=
kyut
::
methods
::
operand_swapping
::
extract
(
w
,
module
);
}
else
{
}
else
{
WASM_UNREACHABLE
((
"unknown method: "
+
method
).
c_str
());
WASM_UNREACHABLE
((
"unknown method: "
+
method
).
c_str
());
}
}
...
...
src/snpi.cpp
View file @
ad261fcf
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "cmdline.h"
#include "cmdline.h"
#include "kyut/methods/ExportReordering.hpp"
#include "kyut/methods/ExportReordering.hpp"
#include "kyut/methods/FunctionReordering.hpp"
#include "kyut/methods/FunctionReordering.hpp"
#include "kyut/methods/OperandSwapping.hpp"
#include "support/colors.h"
#include "support/colors.h"
#include "wasm-io.h"
#include "wasm-io.h"
...
@@ -17,7 +18,7 @@ int main(int argc, char* argv[]) {
...
@@ -17,7 +18,7 @@ int main(int argc, char* argv[]) {
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
<
std
::
string
>
(
"output"
,
'o'
,
"Output filename"
,
true
);
options
.
add
<
std
::
string
>
(
"output"
,
'o'
,
"Output filename"
,
true
);
options
.
add
<
std
::
string
>
(
"method"
,
'm'
,
"Embedding method (function-reorder
ing, export-reordering)"
,
true
,
""
,
cmdline
::
oneof
<
std
::
string
>
(
"function-reordering"
,
"export-reordering
"
));
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
));
...
@@ -68,10 +69,12 @@ int main(int argc, char* argv[]) {
...
@@ -68,10 +69,12 @@ int main(int argc, char* argv[]) {
kyut
::
CircularBitStreamReader
r
{
watermark
};
kyut
::
CircularBitStreamReader
r
{
watermark
};
std
::
size_t
size_bits
;
std
::
size_t
size_bits
;
if
(
method
==
"function-reorder
ing
"
)
{
if
(
method
==
"function-reorder"
)
{
size_bits
=
kyut
::
methods
::
function_reordering
::
embed
(
r
,
module
,
chunk_size
);
size_bits
=
kyut
::
methods
::
function_reordering
::
embed
(
r
,
module
,
chunk_size
);
}
else
if
(
method
==
"export-reorder
ing
"
)
{
}
else
if
(
method
==
"export-reorder"
)
{
size_bits
=
kyut
::
methods
::
export_reordering
::
embed
(
r
,
module
,
chunk_size
);
size_bits
=
kyut
::
methods
::
export_reordering
::
embed
(
r
,
module
,
chunk_size
);
}
else
if
(
method
==
"operand-swap"
)
{
size_bits
=
kyut
::
methods
::
operand_swapping
::
embed
(
r
,
module
);
}
else
{
}
else
{
WASM_UNREACHABLE
((
"unknown method: "
+
method
).
c_str
());
WASM_UNREACHABLE
((
"unknown method: "
+
method
).
c_str
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment