Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
llvm-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
llvm-watermarker
Commits
91146f8a
Commit
91146f8a
authored
Jan 22, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Functionの挿入順を逆にするだけのPassを追加
parent
e498fa81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
Makefile
src/Makefile
+1
-0
FunctionWatermarkPass.cpp
src/nykk/pass/FunctionWatermarkPass.cpp
+73
-0
No files found.
src/Makefile
View file @
91146f8a
TARGET
:=
nykk.so
SRCS
:=
\
nykk/pass/BlockWatermarkPass.cpp
\
nykk/pass/FunctionWatermarkPass.cpp
\
nykk/pass/InstructionWatermarkPass.cpp
include
../cxx.mk
src/nykk/pass/FunctionWatermarkPass.cpp
0 → 100644
View file @
91146f8a
#include <llvm/IR/Function.h>
#include <llvm/IR/Module.h>
#include <llvm/Pass.h>
#include <llvm/Support/raw_ostream.h>
#include "../CircularBitStream.hpp"
#include "../PermutationTable.hpp"
#include "Opts.hpp"
namespace
{
/**
* @brief Watermarking pass by function ordering methods.
*/
class
FunctionWatermarkPass
:
public
llvm
::
ModulePass
{
public
:
static
inline
char
ID
;
// Needed for LLVM.
/**
* @brief Constructor.
*/
explicit
FunctionWatermarkPass
()
:
ModulePass
(
ID
)
{
}
// Uncopyable, unmovable.
FunctionWatermarkPass
(
const
FunctionWatermarkPass
&
)
=
delete
;
FunctionWatermarkPass
(
FunctionWatermarkPass
&&
)
=
delete
;
FunctionWatermarkPass
&
operator
=
(
const
FunctionWatermarkPass
&
)
=
delete
;
FunctionWatermarkPass
&
operator
=
(
FunctionWatermarkPass
&&
)
=
delete
;
~
FunctionWatermarkPass
()
=
default
;
/**
* @brief Processes modules.
*
* @param module Reference to the module.
*
* @return `true` if the module was changed.
*/
bool
runOnModule
(
llvm
::
Module
&
module
)
override
{
const
auto
bit_stream
=
nykk
::
CircularBitStream
::
from_string
(
nykk
::
pass
::
watermark_opt
);
std
::
size_t
num_embedded_bits
=
0
;
bool
is_changed
=
false
;
auto
functions
=
std
::
vector
<
std
::
reference_wrapper
<
llvm
::
Function
>>
(
module
.
getFunctionList
().
rbegin
(),
module
.
getFunctionList
().
rend
());
for
(
const
auto
&
func
:
functions
)
{
is_changed
=
true
;
func
.
get
().
removeFromParent
();
module
.
getFunctionList
().
push_back
(
&
func
.
get
());
}
llvm
::
errs
()
<<
module
.
getName
()
<<
", "
<<
module
.
size
()
<<
", "
<<
num_embedded_bits
<<
"
\n
"
;
return
is_changed
;
}
};
// Registers pass.
const
llvm
::
RegisterPass
<
FunctionWatermarkPass
>
pass_registry
=
{
"func-wm"
,
"Watermarking pass by function ordering methods"
,
};
}
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