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
|
# Makefile template for configure for the eBPF simulator
# Copyright (C) 2020-2021 Free Software Foundation, Inc.
#
# This file is part of GDB, the GNU debugger.
#
# 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; either version 3 of the License, or
# (at your option) any later version.
#
# 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, see <http://www.gnu.org/licenses/>.
## COMMON_PRE_CONFIG_FRAG
CGEN_STD_OBJS = cgen-run.o cgen-scache.o cgen-trace.o cgen-utils.o
BPF_GEN_OBJS = arch.o cpu.o \
decode-le.o decode-be.o \
sem-le.o sem-be.o \
mloop-le.o mloop-be.o
BPF_HAND_OBJS = bpf.o sim-if.o traps.o bpf-helpers.o
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
$(CGEN_STD_OBJS) \
$(BPF_GEN_OBJS) \
$(BPF_HAND_OBJS)
SIM_EXTRA_DEPS = \
$(CGEN_INCLUDE_DEPS) \
arch.h \
bpf-sim.h \
eng-le.h eng-be.h \
$(srcdir)/../../opcodes/bpf-desc.h \
$(srcdir)/../../opcodes/bpf-opc.h
SIM_EXTRA_CLEAN = bpf-clean
## COMMON_POST_CONFIG_FRAG
# cgen support, enable with --enable-cgen-maint
CGEN_MAINT = ; @true
# The following line is commented in or out depending upon --enable-cgen-maint.
@CGEN_MAINT@CGEN_MAINT =
# BPF headers
BPF_INCLUDE_DEPS = \
$(CGEN_MAIN_CPU_DEPS) \
$(SIM_EXTRA_DEPS) \
cpu.h cpuall.h \
decode-le.h decode-be.h \
defs-le.h defs-be.h \
eng-le.h eng-be.h
# Dependencies for binaries from CGEN generated source
mloop-le.o: mloop-le.c
$(COMPILE) -DWANT_ISA_EBPFLE mloop-le.c
$(POSTCOMPILE)
mloop-be.o: mloop-be.c
$(COMPILE) -DWANT_ISA_EBPFBE mloop-be.c
$(POSTCOMPILE)
decode-le.o: decode-le.c
$(COMPILE) -DWANT_ISA_EBPFLE $(srcdir)/decode-le.c
$(POSTCOMPILE)
decode-be.o: decode-be.c $(BPF_INCLUDE_DEPS)
$(COMPILE) -DWANT_ISA_EBPFBE $(srcdir)/decode-be.c
$(POSTCOMPILE)
sem-le.o: sem-le.c
$(COMPILE) -DWANT_ISA_EBPFLE $(srcdir)/sem-le.c
$(POSTCOMPILE)
sem-be.o: sem-be.c
$(COMPILE) -DWANT_ISA_EBPFBE $(srcdir)/sem-be.c
$(POSTCOMPILE)
arch = bpf
CGEN_COMMON_DEPS = \
$(CGEN_READ_SCM) \
$(srcdir)/../../cpu/bpf.cpu \
$(srcdir)/../../cpu/bpf.opc \
Makefile
stamp-arch: $(CGEN_COMMON_DEPS) $(CGEN_ARCH_SCM)
$(MAKE) cgen-arch $(CGEN_FLAGS_TO_PASS) \
mach=bpf cpu=bpfbf \
archfile=$(srcdir)/../../cpu/bpf.cpu \
FLAGS="with-scache"
touch $@
$(srcdir)/arch.h $(srcdir)/arch.c $(srcdir)/cpuall.h: $(CGEN_MAINT) stamp-arch
@true
stamp-cpu: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM)
$(MAKE) cgen-cpu $(CGEN_FLAGS_TO_PASS) \
isa=ebpfle,ebpfbe cpu=bpfbf mach=bpf \
archfile=$(srcdir)/../../cpu/bpf.cpu \
FLAGS="with-multiple-isa with-scache"
rm -f $(srcdir)/model.c
touch $@
$(srcdir)/cpu.h $(srcdir)/cpu.c $(srcdir)/model.c: $(CGEN_MAINT) stamp-cpu
@true
# We need to generate a group of files per ISA.
# For eBPF little-endian:
# defs-le.h
# sem-le.c, decode-le.c, decode-le.h
# $(objdir)/mloop-le.c $(objdir)/eng-le.h
# For eBPF big-endian:
# defs-be.h
# sem-be.c, decode-be.c, decode-be.h
# $(objdir)/mloop-be.c $(objdir)/eng-le.h
#
# The rules below take care of that.
stamp-defs-le: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM)
$(MAKE) cgen-defs $(CGEN_FLAGS_TO_PASS) \
isa=ebpfle cpu=bpfbf mach=bpf \
archfile=$(srcdir)/../../cpu/bpf.cpu \
FLAGS="with-scache" \
SUFFIX="-le"
touch $@
$(srcdir)/defs-le.h: $(CGEN_MAINT) stamp-defs-le
@true
stamp-defs-be: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM)
$(MAKE) cgen-defs $(CGEN_FLAGS_TO_PASS) \
isa=ebpfbe cpu=bpfbf mach=bpf \
archfile=$(srcdir)/../../cpu/bpf.cpu \
FLAGS="with-scache" \
SUFFIX="-be"
touch $@
$(srcdir)/defs-be.h: $(CGEN_MAINT) stamp-defs-be
@true
stamp-decode-le: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM) $(GEN_DECODE_SCM)
$(MAKE) cgen-decode $(CGEN_FLAGS_TO_PASS) \
isa=ebpfle cpu=bpfbf mach=bpf \
archfile=$(srcdir)/../../cpu/bpf.cpu \
FLAGS="with-scache" \
SUFFIX="-le" \
EXTRAFILES="$(CGEN_CPU_SEM)"
touch $@
$(srcdir)/sem-le.c $(srcdir)/decode-le.c $(srcdir)/decode-le.h: \
$(CGEN_MAINT) stamp-decode-le
@true
stamp-decode-be: $(CGEN_COMMON_DEPS) $(CGEN_CPU_SCM) $(GEN_DECODE_SCM)
$(MAKE) cgen-decode $(CGEN_FLAGS_TO_PASS) \
isa=ebpfbe cpu=bpfbf mach=bpf \
archfile=$(srcdir)/../../cpu/bpf.cpu \
FLAGS="with-scache" \
SUFFIX="-be" \
EXTRAFILES="$(CGEN_CPU_SEM)"
touch $@
$(srcdir)/sem-be.c $(srcdir)/decode-be.c $(srcdir)/decode-be.h: \
$(CGEN_MAINT) stamp-decode-be
@true
# Note the following files are generated in objdir, not srcdir.
stamp-mloop: stamp-mloop-le stamp-mloop-be
stamp-mloop-le: $(srcdir)/../common/genmloop.sh mloop.in Makefile
$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-mono -scache -prefix bpfbf_ebpfle -cpu bpfbf \
-infile $(srcdir)/mloop.in -outfile-suffix -le
$(SHELL) $(srcroot)/move-if-change eng-le.hin eng-le.h
$(SHELL) $(srcroot)/move-if-change mloop-le.cin mloop-le.c
touch $@
mloop-le.c eng-le.h: stamp-mloop-le
@true
stamp-mloop-be: $(srcdir)/../common/genmloop.sh mloop.in Makefile
$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-mono -scache -prefix bpfbf_ebpfbe -cpu bpfbf \
-infile $(srcdir)/mloop.in -outfile-suffix -be
$(SHELL) $(srcroot)/move-if-change eng-be.hin eng-be.h
$(SHELL) $(srcroot)/move-if-change mloop-be.cin mloop-be.c
touch $@
mloop-be.c eng-be.h: stamp-mloop-be
@true
.PHONY = bpf-clean
bpf-clean:
rm -f stamp-arch stamp-cpu stamp-decode stamp-defs stamp-mloop
|