1 | # $Id: Makefile.kmk 87281 2021-01-15 17:19:08Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # Sub-Makefile for the VBox Disassembler.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 | SUB_DEPTH = ../../../..
|
---|
19 | include $(KBUILD_PATH)/subheader.kmk
|
---|
20 | ifdef VBOX_WITH_TESTCASES
|
---|
21 |
|
---|
22 |
|
---|
23 | if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
|
---|
24 | PROGRAMS += tstDisasm-1
|
---|
25 | tstDisasm-1_TEMPLATE = VBOXR3TSTEXE
|
---|
26 | tstDisasm-1_DEFS = IN_DIS
|
---|
27 | tstDisasm-1_SOURCES = \
|
---|
28 | tstDisasm-1.cpp \
|
---|
29 | tstDisasm-1A.asm
|
---|
30 | tstDisasm-1_LIBS = \
|
---|
31 | $(PATH_STAGE_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
|
---|
32 | $(LIB_RUNTIME)
|
---|
33 | endif
|
---|
34 |
|
---|
35 |
|
---|
36 | PROGRAMS += tstDisasm-2
|
---|
37 | tstDisasm-2_TEMPLATE = VBOXR3TSTEXE
|
---|
38 | tstDisasm-2_DEFS = IN_DIS
|
---|
39 | tstDisasm-2_SOURCES = \
|
---|
40 | tstDisasm-2.cpp
|
---|
41 | tstDisasm-2_LIBS = \
|
---|
42 | $(PATH_STAGE_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
|
---|
43 | $(LIB_RUNTIME)
|
---|
44 |
|
---|
45 | # Tests that will be build, disassembled and re-build from disassembly.
|
---|
46 | VBOX_DISAS_TESTS_BUILD = \
|
---|
47 | tstAsmFnstsw-1.asm \
|
---|
48 | tstAsmLock-1.asm \
|
---|
49 | tstAsmMovFixedReg-1.asm \
|
---|
50 | tstAsmMovSeg-1.asm \
|
---|
51 | tstAsmMovzx-1.asm \
|
---|
52 | tstAsmPop-1.asm \
|
---|
53 | tstAsmPush-1.asm \
|
---|
54 | tstAsmSignExtend-1.asm \
|
---|
55 | tstAsmRegs-1.asm \
|
---|
56 | tstAsm3DNow-1.asm \
|
---|
57 |
|
---|
58 | # Tests that only contains invalid/undefined instructions.
|
---|
59 | VBOX_DISAS_TESTS_INVALID = \
|
---|
60 | tstAsmLock-2.asm \
|
---|
61 | tstAsmLock-3.asm
|
---|
62 |
|
---|
63 | # Tests that will be disassembled and re-build from disassembly (list of binaries).
|
---|
64 | ## @todo tstBinMovzx-1.bin: does C7 imply 32-bit reg in 16-bit mode, or what exactly does it do?
|
---|
65 | VBOX_DISAS_TESTS_BINARIES := \
|
---|
66 | tstBinMovzx-1.bin \
|
---|
67 | tstBinFnstsw-1.bin
|
---|
68 | ifeq ($(USER)x,bird)
|
---|
69 | VBOX_DISAS_TESTS_BINARIES += \
|
---|
70 | tstBin-1.bin \
|
---|
71 | tstBin-2.bin \
|
---|
72 | tstBin-3.bin \
|
---|
73 | tstBin-4.bin \
|
---|
74 | tstBin-5.bin \
|
---|
75 | tstBin-6.bin
|
---|
76 | # $(PATH_STAGE_BIN)/testcase/tstDisasm-2$(SUFF_EXEC)
|
---|
77 | endif
|
---|
78 | VBOX_DISAS_TESTS_BINARIES_NOT_16BIT := \
|
---|
79 | tstBinFnstsw-1.bin
|
---|
80 | VBOX_DISAS_TESTS_BINARIES_NOT_32BIT :=
|
---|
81 | VBOX_DISAS_TESTS_BINARIES_NOT_64BIT :=
|
---|
82 |
|
---|
83 |
|
---|
84 | #
|
---|
85 | # The gory bits...
|
---|
86 | #
|
---|
87 |
|
---|
88 | # Where we put the output files from the testcases.
|
---|
89 | VBOX_DISAS_TEST_OUT_DIR := $(PATH_TARGET)/Disassembler/testcase
|
---|
90 | BLDDIRS += $(VBOX_DISAS_TEST_OUT_DIR)
|
---|
91 |
|
---|
92 | # Generate the rules for creating the .bin files.
|
---|
93 | VBOX_DISAS_TESTS_BIN = $(VBOX_DISAS_TESTS_BUILD) $(VBOX_DISAS_TESTS_INVALID)
|
---|
94 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,\
|
---|
95 | $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin)\
|
---|
96 | $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin)\
|
---|
97 | $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin))
|
---|
98 |
|
---|
99 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-16.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
|
---|
100 | @$(ECHO) "Assembling: $(<F) into $(@F)"
|
---|
101 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
|
---|
102 |
|
---|
103 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-32.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
|
---|
104 | @$(ECHO) "Assembling: $(<F) into $(@F)"
|
---|
105 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
|
---|
106 |
|
---|
107 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-64.bin,%.asm,$$(notdir $$(@))) | $$(dir $$@)
|
---|
108 | @$(ECHO) "Assembling: $(<F) into $(@F)"
|
---|
109 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
|
---|
110 |
|
---|
111 |
|
---|
112 | # Generate the rules for the 'build' tests.
|
---|
113 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,\
|
---|
114 | $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm)\
|
---|
115 | $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm)\
|
---|
116 | $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm))
|
---|
117 |
|
---|
118 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
|
---|
119 | @$(ECHO) "Generating: $(@F) from $(<F)"
|
---|
120 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=16 $<
|
---|
121 |
|
---|
122 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
|
---|
123 | @$(ECHO) "Generating: $(@F) from $(<F)"
|
---|
124 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=32 $<
|
---|
125 |
|
---|
126 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
|
---|
127 | @$(ECHO) "Generating: $(@F) from $(<F)"
|
---|
128 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=64 $<
|
---|
129 |
|
---|
130 |
|
---|
131 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,\
|
---|
132 | $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin)\
|
---|
133 | $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin)\
|
---|
134 | $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin))
|
---|
135 |
|
---|
136 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
|
---|
137 | @$(ECHO) "Re-assembling: $(<F) into $(@F)"
|
---|
138 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
|
---|
139 |
|
---|
140 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
|
---|
141 | @$(ECHO) "Re-assembling: $(<F) into $(@F)"
|
---|
142 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
|
---|
143 |
|
---|
144 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin)): $$(subst .bin,.asm,$$@) | $$(dir $$@)
|
---|
145 | @$(ECHO) "Re-assembling: $(<F) into $(@F)"
|
---|
146 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
|
---|
147 |
|
---|
148 |
|
---|
149 | VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_BUILD:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
|
---|
150 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,\
|
---|
151 | $(VBOX_DISAS_TESTS_BUILD:.asm=-16.tst)\
|
---|
152 | $(VBOX_DISAS_TESTS_BUILD:.asm=-32.tst)\
|
---|
153 | $(VBOX_DISAS_TESTS_BUILD:.asm=-64.tst) ): $$(subst .tst,-disas.bin,$$@) | $$(dir $$@)
|
---|
154 | @$(ECHO) "Verifying build: $(<F) and $(@F:.tst=.bin)"
|
---|
155 | @$(RM) -f $@
|
---|
156 | $(CMP) $(@:.tst=.bin) $<
|
---|
157 | @$(APPEND) $@ "done"
|
---|
158 | @$(ECHO) " PASSED: $(<F) [re-assembled]"
|
---|
159 |
|
---|
160 |
|
---|
161 |
|
---|
162 | # Generate the rules for the 'invalid' tests.
|
---|
163 | VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_INVALID:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
|
---|
164 |
|
---|
165 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-16.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
|
---|
166 | @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
|
---|
167 | @$(RM) -f $@
|
---|
168 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=16 $<
|
---|
169 | @$(APPEND) $@ "done"
|
---|
170 | @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
|
---|
171 |
|
---|
172 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-32.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
|
---|
173 | @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
|
---|
174 | @$(RM) -f $@
|
---|
175 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=32 $<
|
---|
176 | @$(APPEND) $@ "done"
|
---|
177 | @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
|
---|
178 |
|
---|
179 | $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-64.tst)): $$(patsubst %.tst,%.bin,$$@) $$(tstDisasm-2_1_STAGE_TARGET) | $$(dir $$@)
|
---|
180 | @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
|
---|
181 | @$(RM) -f $@
|
---|
182 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(tstDisasm-2_1_STAGE_TARGET) --undef-op=all --cpumode=64 $<
|
---|
183 | @$(APPEND) $@ "done"
|
---|
184 | @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
|
---|
185 |
|
---|
186 |
|
---|
187 | # Generate the rules for the binary tests.
|
---|
188 | define def_vbox_disas_binary_rules
|
---|
189 | $(outbase).asm: $(full_binary) $$$$(tstDisasm-2_1_STAGE_TARGET) | $(VBOX_DISAS_TEST_OUT_DIR)/
|
---|
190 | @$$(ECHO) "Generating: $$(@F) from $$(<F)"
|
---|
191 | $$(REDIRECT) -E VBOX_LOG_DEST=nofile -o $$@ -- $$(tstDisasm-2_1_STAGE_TARGET) --style=yasm --cpumode=$(bits) --undef-op=db $$<
|
---|
192 |
|
---|
193 | $(outbase).bin + $(outbase).lst: $(outbase).asm
|
---|
194 | @$$(ECHO) "Re-assembling: $$(<F) into $$(@F)"
|
---|
195 | $$(TOOL_YASM_AS) -f bin -a x86 --force-strict -l $(outbase).lst -o $$@ $$<
|
---|
196 |
|
---|
197 | $(outbase).tst: $(outbase).bin
|
---|
198 | @$$(ECHO) "Verifying build: $$(<F) against $(not-dir $(full_binary))"
|
---|
199 | @$$(RM) -f $$@
|
---|
200 | $$(CMP) -l $(full_binary) $$<
|
---|
201 | @$$(APPEND) $$@ "done"
|
---|
202 | @$$(ECHO) " PASSED: $$(<F) [binary]"
|
---|
203 |
|
---|
204 | $(name).tst:: $(outbase).tst
|
---|
205 | VBOX_DISAS_TEST_CLEAN += $(outbase).tst $(outbase).bin $(outbase).asm
|
---|
206 | VBOX_DISAS_TESTS += $(name)-rebuild-$(bits).tst
|
---|
207 | endef # def_vbox_disas_binary_rules
|
---|
208 |
|
---|
209 | define def_vbox_disas_binary
|
---|
210 | local name := $(notdir $(basename $(binary)))
|
---|
211 | local full_binary := $(abspathex $(binary),$(PATH_SUB_CURRENT))
|
---|
212 | local outbase := $(VBOX_DISAS_TEST_OUT_DIR)/$(name)-rebuild-$(bits)
|
---|
213 | $(eval $(def_vbox_disas_binary_rules))
|
---|
214 | endef # def_vbox_disas_binary
|
---|
215 |
|
---|
216 | ## @todo 64-bit is problematic because of bugs like POP RDI ending up as POP EDI (incorrect default opmode).
|
---|
217 | #$(foreach bits, 64, $(foreach binary, $(VBOX_DISAS_TESTS_BINARIES), $(evalvalctx def_vbox_disas_binary)))
|
---|
218 | $(foreach bits, 32 16, $(foreach binary, $(filter-out $(VBOX_DISAS_TESTS_BINARIES_NOT_$(bits)BIT), $(VBOX_DISAS_TESTS_BINARIES)) \
|
---|
219 | , $(evalvalctx def_vbox_disas_binary)))
|
---|
220 |
|
---|
221 |
|
---|
222 | # Add the .tst to the clean up.
|
---|
223 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/, $(VBOX_DISAS_TESTS))
|
---|
224 | OTHER_CLEAN += $(VBOX_DISAS_TEST_CLEAN)
|
---|
225 |
|
---|
226 |
|
---|
227 | #
|
---|
228 | # Add the tests to the target list for the testing pass.
|
---|
229 | # (kBuild r1646)
|
---|
230 | #
|
---|
231 | TESTING += $(addprefix $(VBOX_DISAS_TEST_OUT_DIR)/,$(VBOX_DISAS_TESTS))
|
---|
232 |
|
---|
233 |
|
---|
234 | #
|
---|
235 | # The test aliases
|
---|
236 | #
|
---|
237 | # To run the tstAsmLock-3.asm test: kmk tstAsmLock-3.tst
|
---|
238 | # To run the 64-bit tstAsmLock-3.asm test: kmk tstAsmLock-3-64.tst
|
---|
239 | #
|
---|
240 | define def_vbox_test_aliases
|
---|
241 | local test_base := $(basename $(test))
|
---|
242 | local test_root := $(patsubst %-16,%,$(patsubst %-32,%,$(patsubst %-64,%,$(test_base))))
|
---|
243 | $(test_base).tst:: $(VBOX_DISAS_TEST_OUT_DIR)/$(test)
|
---|
244 | $(test_root).tst:: $(test_base).tst
|
---|
245 | $(test_base).o:: $(test_base).tst
|
---|
246 | $(test_base).obj:: $(test_base).tst
|
---|
247 | $(test_root).o:: $(test_root).tst
|
---|
248 | $(test_root).obj:: $(test_root).tst
|
---|
249 | endef
|
---|
250 | $(foreach test,$(VBOX_DISAS_TESTS),$(evalvalctx def_vbox_test_aliases))
|
---|
251 |
|
---|
252 | endif # VBOX_WITH_TESTCASES
|
---|
253 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|
254 |
|
---|