This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.rules
264 lines (200 loc) · 11.1 KB
/
makefile.rules
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
##############################################################
#
# This file includes all the test targets as well as all the
# non-default build rules and test recipes.
#
##############################################################
##############################################################
#
# Test targets
#
##############################################################
###### Place all generic definitions here ######
# This defines tests which run tools of the same name. This is simply for convenience to avoid
# defining the test name twice (once in TOOL_ROOTS and again in TEST_ROOTS).
# Tests defined here should not be defined in TOOL_ROOTS and TEST_ROOTS.
TEST_TOOL_ROOTS := inscount0 inscount1 inscount2 proccount imageload staticcount detach malloctrace \
malloc_mt inscount_tls stack-debugger pinatrace itrace isampling safecopy invocation \
countreps nonstatica
# This defines the tests to be run that were not already defined in TEST_TOOL_ROOTS.
TEST_ROOTS :=
# This defines a list of tests that should run in the "short" sanity. Tests in this list must also
# appear either in the TEST_TOOL_ROOTS or the TEST_ROOTS list.
# If the entire directory should be tested in sanity, assign TEST_TOOL_ROOTS and TEST_ROOTS to the
# SANITY_SUBSET variable in the tests section below (see example in makefile.rules.tmpl).
SANITY_SUBSET :=
# This defines the tools which will be run during the the tests, and were not already defined in
# TEST_TOOL_ROOTS.
TOOL_ROOTS :=
# This defines the static analysis tools which will be run during the the tests. They should not
# be defined in TEST_TOOL_ROOTS. If a test with the same name exists, it should be defined in
# TEST_ROOTS.
# Note: Static analysis tools are in fact executables linked with the Pin Static Analysis Library.
# This library provides a subset of the Pin APIs which allows the tool to perform static analysis
# of an application or dll. Pin itself is not used when this tool runs.
SA_TOOL_ROOTS :=
# This defines all the applications that will be run during the tests.
APP_ROOTS := fibonacci little_malloc thread_app
# This defines any additional object files that need to be compiled.
OBJECT_ROOTS :=
# This defines any additional dlls (shared objects), other than the pintools, that need to be compiled.
DLL_ROOTS :=
# This defines any static libraries (archives), that need to be built.
LIB_ROOTS :=
###### Place probe mode tests here ######
ifeq ($(PROBE),1)
TEST_TOOL_ROOTS += replacesigprobed
endif
###### Place OS-specific definitions here ######
# Linux
ifeq ($(TARGET_OS),linux)
TEST_TOOL_ROOTS += buffer_linux fork_jit_tool follow_child_tool strace emudiv
TEST_ROOTS += statica
SA_TOOL_ROOTS += statica
APP_ROOTS += fork_app follow_child_app1 follow_child_app2 divide_by_zero
endif
# Mac OS X*
ifeq ($(TARGET_OS),mac)
TEST_TOOL_ROOTS += fork_jit_tool follow_child_tool strace
TEST_ROOTS += statica
SA_TOOL_ROOTS += statica
APP_ROOTS += fork_app follow_child_app1 follow_child_app2
endif
# Windows
ifeq ($(TARGET_OS),windows)
TEST_TOOL_ROOTS += w_malloctrace buffer_windows emudiv
APP_ROOTS += divide_by_zero
endif
###### Handle exceptions here ######
# TODO: These tests fail - fix and remove the following:
# See Mantis 2963
ifeq ($(TARGET),mic)
TEST_TOOL_ROOTS := $(filter-out nonstatica emudiv, $(TEST_TOOL_ROOTS))
TEST_ROOTS := $(filter-out statica, $(TEST_ROOTS))
SA_TOOL_ROOTS := $(filter-out statica, $(SA_TOOL_ROOTS))
endif
# See Mantis 3204
ifeq ($(TARGET_OS),mac)
TEST_TOOL_ROOTS := $(filter-out follow_child_tool, $(TEST_TOOL_ROOTS))
endif
##############################################################
#
# Test recipes
#
##############################################################
# This section contains recipes for tests other than the default.
# See makefile.default.rules for the default test rules.
# All tests in this section should adhere to the naming convention: <testname>.test
inscount_tls.test: $(OBJDIR)inscount_tls$(PINTOOL_SUFFIX) $(OBJDIR)thread_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)inscount_tls$(PINTOOL_SUFFIX) -- $(OBJDIR)thread_app$(EXE_SUFFIX) > $(OBJDIR)inscount_tls.out 2>&1
$(RM) $(OBJDIR)inscount_tls.out
malloc_mt.test: $(OBJDIR)malloc_mt$(PINTOOL_SUFFIX) $(OBJDIR)thread_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)malloc_mt$(PINTOOL_SUFFIX) -- $(OBJDIR)thread_app$(EXE_SUFFIX) > $(OBJDIR)malloc_mt.out 2>&1
$(RM) $(OBJDIR)malloc_mt.out
buffer_linux.test: $(OBJDIR)buffer_linux$(PINTOOL_SUFFIX) $(OBJDIR)thread_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)buffer_linux$(PINTOOL_SUFFIX) -- $(OBJDIR)thread_app$(EXE_SUFFIX) > $(OBJDIR)buffer_linux.out 2>&1
$(RM) $(OBJDIR)buffer_linux.out
buffer_windows.test: $(OBJDIR)buffer_windows$(PINTOOL_SUFFIX) $(OBJDIR)thread_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)buffer_windows$(PINTOOL_SUFFIX) -emit 0 \
-- $(OBJDIR)thread_app$(EXE_SUFFIX) > $(OBJDIR)buffer_windows.out 2>&1
$(RM) $(OBJDIR)buffer_windows.out
invocation.test: $(OBJDIR)invocation$(PINTOOL_SUFFIX) $(OBJDIR)little_malloc$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)invocation$(PINTOOL_SUFFIX) -- $(OBJDIR)little_malloc$(EXE_SUFFIX) > $(OBJDIR)invocation.out 2>&1
$(RM) $(OBJDIR)invocation.out
# This tool is tested in "Debugger/makefile". However, leave this line because it is referenced in the user manual.
# The user may invoke make stack-debugger.test to build the tool and app shown in the manual.
# There is an intentional "empty" line which contains a tab character so this "test" will have an empty recipe.
stack-debugger.test: $(OBJDIR)stack-debugger$(PINTOOL_SUFFIX) $(OBJDIR)fibonacci$(EXE_SUFFIX)
# stand alone pin tool
statica.test: $(OBJDIR)statica$(SATOOL_SUFFIX)
$(OBJDIR)statica$(SATOOL_SUFFIX) -i $(OBJDIR)statica$(SATOOL_SUFFIX) > $(OBJDIR)statica.dmp
$(RM) $(OBJDIR)statica.dmp
nonstatica.test: $(OBJDIR)nonstatica$(PINTOOL_SUFFIX) $(TESTAPP)
$(PIN) -t $(OBJDIR)nonstatica$(PINTOOL_SUFFIX) \
-- $(TESTAPP) makefile $(OBJDIR)nonstatica.makefile.copy > $(OBJDIR)nonstatica.dmp
$(DIFF) makefile $(OBJDIR)nonstatica.makefile.copy
$(RM) $(OBJDIR)nonstatica.makefile.copy $(OBJDIR)nonstatica.dmp
emudiv.test: $(OBJDIR)emudiv$(PINTOOL_SUFFIX) $(OBJDIR)divide_by_zero$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)emudiv$(PINTOOL_SUFFIX) -- $(OBJDIR)divide_by_zero$(EXE_SUFFIX) > $(OBJDIR)emudiv.out 2>&1
$(QGREP) "Caught divide by zero exception" $(OBJDIR)emudiv.out
$(RM) $(OBJDIR)emudiv.out
fork_jit_tool.test: $(OBJDIR)fork_jit_tool$(PINTOOL_SUFFIX) $(OBJDIR)fork_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)fork_jit_tool$(PINTOOL_SUFFIX) -- $(OBJDIR)fork_app$(EXE_SUFFIX)
follow_child_tool.test: $(OBJDIR)follow_child_tool$(PINTOOL_SUFFIX) $(OBJDIR)follow_child_app1$(EXE_SUFFIX) $(OBJDIR)follow_child_app2$(EXE_SUFFIX)
$(PIN) -follow_execv 1 -t $(OBJDIR)follow_child_tool$(PINTOOL_SUFFIX) \
-- $(OBJDIR)follow_child_app1$(EXE_SUFFIX) $(OBJDIR)follow_child_app2$(EXE_SUFFIX)
##############################################################
#
# Build rules
#
##############################################################
# This section contains the build rules for all binaries that have special build rules.
# See makefile.default.rules for the default build rules.
###### Special applications' build rules ######
$(OBJDIR)divide_by_zero$(EXE_SUFFIX): divide_by_zero_$(TARGET_OS).c
$(APP_CC) $(APP_CXXFLAGS_NOOPT) $(COMP_EXE)$@ $< $(APP_LDFLAGS_NOOPT) $(APP_LIBS)
$(OBJDIR)thread_app$(EXE_SUFFIX): thread_$(OS_TYPE).c
$(APP_CC) $(APP_CXXFLAGS) $(COMP_EXE)$@ $< $(APP_LDFLAGS) $(APP_LIBS)
#### stackhandling ####
# Build the intermediate object file.
$(OBJDIR)typeparser$(OBJ_SUFFIX): typeparser.cpp typeparser.h
$(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)heapmemory$(OBJ_SUFFIX): heapmemory.cpp heapmemory.h typeparser.h
$(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)stackmemory$(OBJ_SUFFIX): stackmemory.cpp stackmemory.h typeparser.h
$(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)stackhandling$(OBJ_SUFFIX): stackhandling.cpp typeparser.h heapmemory.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)objdumpparser$(OBJ_SUFFIX): objdumpparser.cpp objdumpparser.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)typerefiner$(OBJ_SUFFIX): typerefiner.cpp typerefiner.h typeparser.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)shadowstack$(OBJ_SUFFIX): shadowstack.cpp shadowstack.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
$(OBJDIR)callstack$(OBJ_SUFFIX): callstack.cpp callstack.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the tool as a dll (shared object).
$(OBJDIR)stackhandling$(PINTOOL_SUFFIX): $(OBJDIR)stackhandling$(OBJ_SUFFIX) $(OBJDIR)typeparser$(OBJ_SUFFIX) $(OBJDIR)heapmemory$(OBJ_SUFFIX) $(OBJDIR)stackmemory$(OBJ_SUFFIX) $(OBJDIR)objdumpparser$(OBJ_SUFFIX) $(OBJDIR)typerefiner$(OBJ_SUFFIX) $(OBJDIR)callstack$(OBJ_SUFFIX) $(OBJDIR)shadowstack$(OBJ_SUFFIX) typeparser.h
$(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $(^:%.h=) $(TOOL_LPATHS) $(TOOL_LIBS)
#### callreturn ####
# Build the intermediate object file.
$(OBJDIR)callreturn$(OBJ_SUFFIX): callreturn.cpp typeparser.h heapmemory.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
$(OBJDIR)callstack$(OBJ_SUFFIX): callstack.cpp callstack.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the tool as a dll (shared object).
$(OBJDIR)callreturn$(PINTOOL_SUFFIX): $(OBJDIR)callreturn$(OBJ_SUFFIX) $(OBJDIR)callstack$(OBJ_SUFFIX)
$(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $(^:%.h=) $(TOOL_LPATHS) $(TOOL_LIBS)
#### malloctrace ####
# Build the intermediate object file.
$(OBJDIR)typeparser$(OBJ_SUFFIX): typeparser.cpp typeparser.h
$(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)heapmemory$(OBJ_SUFFIX): heapmemory.cpp heapmemory.h typeparser.h
$(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)stackmemory$(OBJ_SUFFIX): stackmemory.cpp stackmemory.h typeparser.h
$(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)malloctrace$(OBJ_SUFFIX): malloctrace.cpp typeparser.h heapmemory.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)objdumpparser$(OBJ_SUFFIX): objdumpparser.cpp objdumpparser.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
# $(OBJDIR)typerefiner$(OBJ_SUFFIX): typerefiner.cpp typerefiner.h typeparser.h
# $(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
$(OBJDIR)callstack$(OBJ_SUFFIX): callstack.cpp callstack.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the intermediate object file.
$(OBJDIR)shadowstack$(OBJ_SUFFIX): shadowstack.cpp shadowstack.h
$(CXX) -g $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
# Build the tool as a dll (shared object).
$(OBJDIR)malloctrace$(PINTOOL_SUFFIX): $(OBJDIR)malloctrace$(OBJ_SUFFIX) $(OBJDIR)typeparser$(OBJ_SUFFIX) $(OBJDIR)heapmemory$(OBJ_SUFFIX) $(OBJDIR)stackmemory$(OBJ_SUFFIX) $(OBJDIR)objdumpparser$(OBJ_SUFFIX) $(OBJDIR)shadowstack$(OBJ_SUFFIX) $(OBJDIR)callstack$(OBJ_SUFFIX) typeparser.h
$(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $(^:%.h=) $(TOOL_LPATHS) $(TOOL_LIBS)