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
8053699e
Verified
Commit
8053699e
authored
Jan 01, 2021
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an option for preserving DWARF info
parent
34e97b73
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
common.rb
scripts/common.rb
+1
-1
snpi.cpp
src/snpi.cpp
+5
-2
No files found.
scripts/common.rb
View file @
8053699e
...
@@ -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
...
...
src/snpi.cpp
View file @
8053699e
...
@@ -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
)
{
...
...
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