-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
160 lines (133 loc) · 3.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(blacksmith VERSION 0.0.1 LANGUAGES CXX)
# === OPTIONS ==================================================================
set(
BLACKSMITH_ENABLE_JSON
ON
CACHE BOOL
"Use the nlohmann/json library to export JSON-formatted fuzzing data."
FORCE
)
set(
BLACKSMITH_ENABLE_JITTING
ON
CACHE BOOL
"Use the asmjit library to jit the hammering code."
FORCE
)
string(ASCII 27 ESC)
# === DEFINITIONS ==============================================================
set(GIT_COMMIT_HASH "NO_REPOSITORY")
execute_process(
COMMAND git status
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE ret
OUTPUT_QUIET
ERROR_QUIET
)
if (ret EQUAL "0")
# We're in a git repository, attempt to retrieve the current commit tag.
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif ()
# === DEPENDENCIES =============================================================
add_subdirectory(external)
# === LIBBLACKSMITH ============================================================
add_library(
bs
include/GlobalDefines.hpp
include/Utilities/TimeHelper.hpp
src/Forges/FuzzyHammerer.cpp
src/Forges/ReplayingHammerer.cpp
src/Forges/TraditionalHammerer.cpp
src/Fuzzer/Aggressor.cpp
src/Fuzzer/AggressorAccessPattern.cpp
src/Fuzzer/BitFlip.cpp
src/Fuzzer/CodeJitter.cpp
src/Fuzzer/FuzzingParameterSet.cpp
src/Fuzzer/HammeringPattern.cpp
src/Fuzzer/PatternAddressMapper.cpp
src/Fuzzer/PatternBuilder.cpp
src/Memory/DRAMAddr.cpp
src/Memory/DramAnalyzer.cpp
src/Memory/Memory.cpp
src/Utilities/Enums.cpp
src/Utilities/Logger.cpp
)
target_include_directories(
bs
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# Note: PUBLIC to also force consumers (i.e., the blacksmith executable) to use
# these features and options.
target_compile_features(
bs
PUBLIC
cxx_std_17
)
target_compile_options(
bs
PUBLIC
-O0
-Wall
-Wextra
-Wno-unused-function
-Wno-format-security
)
if (BLACKSMITH_ENABLE_JSON)
target_link_libraries(
bs
PUBLIC
nlohmann_json::nlohmann_json
)
target_compile_definitions(
bs
PUBLIC
ENABLE_JSON
)
endif ()
if (BLACKSMITH_ENABLE_JITTING)
# This fixes an issue that causes GCC 10.3 (but not 8.3 or 11.1) to miss a
# header somehow.
FetchContent_MakeAvailable(asmjit)
target_include_directories(
bs
PUBLIC
${asmjit_SOURCE_DIR}/src
)
target_link_libraries(
bs
PRIVATE
asmjit
)
target_compile_definitions(
bs
PUBLIC
ENABLE_JITTING
)
endif ()
# === BLACKSMITH ===============================================================
add_executable(
blacksmith
include/Blacksmith.hpp
src/Blacksmith.cpp
)
target_compile_definitions(
blacksmith
PRIVATE
GIT_COMMIT_HASH="${GIT_COMMIT_HASH}"
)
target_link_libraries(
blacksmith
PRIVATE
bs
argagg
)
# === CLEANUP ==================================================================
unset(BLACKSMITH_ENABLE_JSON CACHE)
unset(BLACKSMITH_ENABLE_JITTING CACHE)