-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
122 lines (98 loc) · 4 KB
/
Makefile
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
# Copyright (c) 2018 - 2020, Samsung Electronics Co., Ltd. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Author: Ernest Borowski <e.borowski@samsung.com>
# Author: Jakub Botwicz <j.botwicz@samsung.com>
# Author: Mateusz Nosek <m.nosek@samsung.com>
#
ifeq (${ESAN_PATH},)
ESAN_PATH := $(shell realpath ./)
endif
TEST_PATH = ${ESAN_PATH}/tests
UNIT_TEST_PATH = ${ESAN_PATH}/unit_tests
HOOK_PATH = ${ESAN_PATH}/hooks
LIB_PATH = ${ESAN_PATH}/in_library
SYSROOT = ${LIB_PATH}/sysroot
CC ?= clang
# Additional defines:
# -DAFL - disable logging:
# on failure exit
# on failure injection
# statistics on exit
# disable:
# statistics counting
#
# -DCP_WRONG_MAP - enable copying maps with wrong format to /tmp/esan_debug%d.txt
# where %d is random int, useful for debugging
#
# -DDEBUG - enable additional debug logging
#
# -DESAN_DISABLE_HOOKS_OPENSSL - disables openssl hooks
CFLAGS = -I${ESAN_PATH}/include
CFLAGS += -fPIC -Wall -Wextra -Werror -std=gnu89 -DESAN_DISABLE_HOOKS_OPENSSL
CFLAGS += $(CFLAGS_LOCAL)
LDFLAGS = $(LDFLAGS_LOCAL)
HOOK_OBJ = ${HOOK_PATH}/hooks.o
CFLAGS_COVERAGE = -fprofile-arcs -ftest-coverage -ggdb -DESAN_COVERAGE
LDFLAGS_COVERAGE = -lgcov --coverage
PRELOAD_SRC = error_sanitizer_preload.c esan_stats.c esan_fail.c error_sanitizer.c in_library.c \
esan_mutex.c esan_signal.c
LIB = error_sanitizer_preload.so
############################################################################
all: ev
rebuild: clean
$(MAKE) all
run: ev
cd $(TEST_PATH) && ESAN_PATH=$(ESAN_PATH) CFLAGS_LOCAL="${CFLAGS}" \
LDFLAGS_LOCAL="${LDFLAGS}" CC=${CC} $(MAKE) tests
cd $(UNIT_TEST_PATH) && ESAN_PATH=$(ESAN_PATH) CFLAGS_LOCAL="${CFLAGS}" \
LDFLAGS_LOCAL="${LDFLAGS}" CC=${CC} $(MAKE)
ev: hook $(LIB)
coverage_compile:
CC="gcc" CFLAGS_LOCAL="$(CFLAGS_COVERAGE) $(CFLAGS_LOCAL)" \
LDFLAGS_LOCAL="$(LDFLAGS_COVERAGE) $(LDFLAGS_LOCAL)" \
$(MAKE) rebuild
coverage:
CFLAGS_LOCAL="$(CFLAGS_LOCAL)" LDFLAGS_LOCAL="$(LDFLAGS_LOCAL)" $(MAKE) coverage_compile
CFLAGS_LOCAL="$(CFLAGS_LOCAL)" LDFLAGS_LOCAL="$(LDFLAGS_LOCAL)" $(MAKE) run
gcovr -r "${ESAN_PATH}" --delete --print-summary
find -type f -regex '.*\(gcno\|gcda\)$$' -delete
coverage_debug:
CFLAGS_LOCAL="$(CFLAGS_LOCAL) -DDEBUG" LDFLAGS_LOCAL="$(LDFLAGS_LOCAL)" make coverage
coverage_html:
CFLAGS_LOCAL="$(CFLAGS_LOCAL)" LDFLAGS_LOCAL="$(LDFLAGS_LOCAL)" $(MAKE) coverage_compile
CFLAGS_LOCAL="$(CFLAGS_LOCAL)" LDFLAGS_LOCAL="$(LDFLAGS_LOCAL)" $(MAKE) run
gcovr -r "${ESAN_PATH}" --delete --print-summary --html --html-details -o coverage.html
find -type f -regex '.*\(gcno\|gcda\)$$' -delete
coverage_html_debug:
CFLAGS_LOCAL="$(CFLAGS_LOCAL) -DDEBUG" LDFLAGS_LOCAL="$(LDFLAGS_LOCAL)" make coverage_html
error_sanitizer_preload.so: $(HOOK_OBJ) ${PRELOAD_SRC}
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -shared -ldl
clean: hook_clean test_clean unit_test_clean
rm -f $(LIB)
find -type f -regex '.*\(gcno\|gcda\|html\)$$' -delete
hook: ${HOOK_PATH}/hooks.o
${HOOK_OBJ}: ${HOOK_PATH}
cd ${HOOK_PATH} && ESAN_PATH=${ESAN_PATH} CFLAGS_LOCAL="${CFLAGS}" \
LDFLAGS_LOCAL="${LDFLAGS}" CC=${CC} $(MAKE)
hook_clean:
cd ${HOOK_PATH} && ESAN_PATH=${ESAN_PATH} $(MAKE) clean
test: $(LIBS)
cd ${TEST_PATH} && ESAN_PATH=${ESAN_PATH} CFLAGS_LOCAL="${CFLAGS}" \
LDFLAGS_LOCAL="${LDFLAGS}" CC=${CC} $(MAKE)
test_clean:
cd ${TEST_PATH} && ESAN_PATH=${ESAN_PATH} $(MAKE) clean
unit_test_clean:
cd ${UNIT_TEST_PATH} && ESAN_PATH=${ESAN_PATH} $(MAKE) clean