1 | # $Id: Makefile.kmk 12170 2008-09-06 03:58:49Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # Sub-Makefile for the VBox Disassembler.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | # additional information or have any questions.
|
---|
20 | #
|
---|
21 |
|
---|
22 | ifdef VBOX_SINGLE_MAKEFILE
|
---|
23 | SUB_DEPTH = ../../../..
|
---|
24 | else
|
---|
25 | SUB_DEPTH = ..
|
---|
26 | DEPTH ?= ../../../..
|
---|
27 | endif
|
---|
28 | include $(KBUILD_PATH)/subheader.kmk
|
---|
29 | ifdef VBOX_WITH_TESTCASES
|
---|
30 |
|
---|
31 | PROGRAMS += tstDisasm-2
|
---|
32 | tstDisasm-2_TEMPLATE = VBOXR3TSTEXE
|
---|
33 | tstDisasm-2_DEFS = IN_DIS_R3
|
---|
34 | tstDisasm-2_SOURCES = \
|
---|
35 | tstDisasm-2.cpp
|
---|
36 | tstDisasm-2_LIBS = \
|
---|
37 | $(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
|
---|
38 | $(LIB_RUNTIME)
|
---|
39 |
|
---|
40 | # Tests that will be build, disassembled and re-build from disassembly.
|
---|
41 | VBOX_DISAS_TESTS_BUILD = \
|
---|
42 | tstAsmFnstsw-1.asm \
|
---|
43 | tstAsmLock-1.asm \
|
---|
44 | tstAsmMovSeg-1.asm \
|
---|
45 | tstAsmMovzx-1.asm \
|
---|
46 | tstAsmPop-1.asm \
|
---|
47 | tstAsmPush-1.asm \
|
---|
48 | tstAsmSignExtend-1.asm \
|
---|
49 | tstAsmRegs-1.asm \
|
---|
50 |
|
---|
51 | # Tests that only contains invalid/undefined instructions.
|
---|
52 | VBOX_DISAS_TESTS_INVALID = \
|
---|
53 | tstAsmLock-2.asm \
|
---|
54 | tstAsmLock-3.asm
|
---|
55 |
|
---|
56 | # Tests that will be disassembled and re-build from disassembly (list of binaries).
|
---|
57 | ## @todo tstBinMovzx-1.bin: does C7 imply 32-bit reg in 16-bit mode, or what exactly does it do?
|
---|
58 | VBOX_DISAS_TESTS_BINARIES := \
|
---|
59 | tstBinMovzx-1.bin \
|
---|
60 | tstBinFnstsw-1.bin
|
---|
61 | ifeq ($(USER)x,bird)
|
---|
62 | VBOX_DISAS_TESTS_BINARIES += \
|
---|
63 | tstBin-1.bin \
|
---|
64 | tstBin-2.bin \
|
---|
65 | tstBin-3.bin \
|
---|
66 | tstBin-4.bin \
|
---|
67 | tstBin-5.bin \
|
---|
68 | tstBin-6.bin
|
---|
69 | # $(PATH_BIN)/testcase/tstDisasm-2$(SUFF_EXEC)
|
---|
70 | endif
|
---|
71 |
|
---|
72 |
|
---|
73 | #
|
---|
74 | # The gory bits...
|
---|
75 | #
|
---|
76 |
|
---|
77 | # Where we put the output files from the testcases.
|
---|
78 | VBOX_DISAS_TEST_PATH := $(PATH_TARGET)/disas-testcase
|
---|
79 |
|
---|
80 | $(call DIRDEP,$(VBOX_DISAS_TEST_PATH)):
|
---|
81 | $(MKDIR) -p $@
|
---|
82 |
|
---|
83 | # Generate the rules for creating the .bin files.
|
---|
84 | VBOX_DISAS_TESTS_BIN = $(VBOX_DISAS_TESTS_BUILD) $(VBOX_DISAS_TESTS_INVALID)
|
---|
85 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_PATH)/,\
|
---|
86 | $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin)\
|
---|
87 | $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin)\
|
---|
88 | $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin))
|
---|
89 |
|
---|
90 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BIN:.asm=-16.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-16.bin,%.asm,$$(notdir $$(@))) | $$(call DIRDEP,$$(@D))
|
---|
91 | @$(ECHO) "Assembling: $(<F) into $(@F)"
|
---|
92 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
|
---|
93 |
|
---|
94 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BIN:.asm=-32.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-32.bin,%.asm,$$(notdir $$(@))) | $$(call DIRDEP,$$(@D))
|
---|
95 | @$(ECHO) "Assembling: $(<F) into $(@F)"
|
---|
96 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
|
---|
97 |
|
---|
98 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BIN:.asm=-64.bin)): $(PATH_SUB_CURRENT)/$$(patsubst %-64.bin,%.asm,$$(notdir $$(@))) | $$(call DIRDEP,$$(@D))
|
---|
99 | @$(ECHO) "Assembling: $(<F) into $(@F)"
|
---|
100 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
|
---|
101 |
|
---|
102 |
|
---|
103 | # Generate the rules for the 'build' tests.
|
---|
104 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_PATH)/,\
|
---|
105 | $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm)\
|
---|
106 | $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm)\
|
---|
107 | $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm))
|
---|
108 |
|
---|
109 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(INSTARGET_tstDisasm-2) | $$(call DIRDEP,$$(@D))
|
---|
110 | @$(ECHO) "Generating: $(@F) from $(<F)"
|
---|
111 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(INSTARGET_tstDisasm-2) --style=yasm --cpumode=16 $<
|
---|
112 |
|
---|
113 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(INSTARGET_tstDisasm-2) | $$(call DIRDEP,$$(@D))
|
---|
114 | @$(ECHO) "Generating: $(@F) from $(<F)"
|
---|
115 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(INSTARGET_tstDisasm-2) --style=yasm --cpumode=32 $<
|
---|
116 |
|
---|
117 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.asm)): $$(subst -disas.asm,.bin,$$@) $$(INSTARGET_tstDisasm-2) | $$(call DIRDEP,$$(@D))
|
---|
118 | @$(ECHO) "Generating: $(@F) from $(<F)"
|
---|
119 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -o $@ -- $(INSTARGET_tstDisasm-2) --style=yasm --cpumode=64 $<
|
---|
120 |
|
---|
121 |
|
---|
122 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_PATH)/,\
|
---|
123 | $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin)\
|
---|
124 | $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin)\
|
---|
125 | $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin))
|
---|
126 |
|
---|
127 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-16-disas.bin)): $$(subst .bin,.asm,$$@) | $$(call DIRDEP,$$(@D))
|
---|
128 | @$(ECHO) "Re-assembling: $(<F) into $(@F)"
|
---|
129 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=16 -o $@ $<
|
---|
130 |
|
---|
131 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-32-disas.bin)): $$(subst .bin,.asm,$$@) | $$(call DIRDEP,$$(@D))
|
---|
132 | @$(ECHO) "Re-assembling: $(<F) into $(@F)"
|
---|
133 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=32 -o $@ $<
|
---|
134 |
|
---|
135 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_BUILD:.asm=-64-disas.bin)): $$(subst .bin,.asm,$$@) | $$(call DIRDEP,$$(@D))
|
---|
136 | @$(ECHO) "Re-assembling: $(<F) into $(@F)"
|
---|
137 | $(TOOL_YASM_AS) -f bin -a x86 --force-strict -DTEST_BITS=64 -o $@ $<
|
---|
138 |
|
---|
139 |
|
---|
140 | VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_BUILD:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
|
---|
141 | $(addprefix $(VBOX_DISAS_TEST_PATH)/,\
|
---|
142 | $(VBOX_DISAS_TESTS_BUILD:.asm=-16.tst)\
|
---|
143 | $(VBOX_DISAS_TESTS_BUILD:.asm=-32.tst)\
|
---|
144 | $(VBOX_DISAS_TESTS_BUILD:.asm=-64.tst) ): $$(subst .tst,-disas.bin,$$@) | $$(call DIRDEP,$$(@D))
|
---|
145 | @$(ECHO) "Verifying build: $(<F) and $(@F:.tst=.bin)"
|
---|
146 | @$(RM) -f $@
|
---|
147 | $(CMP) $(@:.tst=.bin) $<
|
---|
148 | @$(APPEND) $@ "done"
|
---|
149 | @$(ECHO) " PASSED: $(<F) [re-assembled]"
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 | # Generate the rules for the 'invalid' tests.
|
---|
154 | VBOX_DISAS_TESTS += $(foreach test, $(VBOX_DISAS_TESTS_INVALID:.asm=), $(test)-16.tst $(test)-32.tst $(test)-64.tst)
|
---|
155 |
|
---|
156 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-16.tst)): $$(patsubst %.tst,%.bin,$$@) $$(INSTARGET_tstDisasm-2) | $$(call DIRDEP,$$(@D))
|
---|
157 | @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
|
---|
158 | @$(RM) -f $@
|
---|
159 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(INSTARGET_tstDisasm-2) --undef-op=all --cpumode=16 $<
|
---|
160 | @$(APPEND) $@ "done"
|
---|
161 | @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
|
---|
162 |
|
---|
163 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-32.tst)): $$(patsubst %.tst,%.bin,$$@) $$(INSTARGET_tstDisasm-2) | $$(call DIRDEP,$$(@D))
|
---|
164 | @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
|
---|
165 | @$(RM) -f $@
|
---|
166 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(INSTARGET_tstDisasm-2) --undef-op=all --cpumode=32 $<
|
---|
167 | @$(APPEND) $@ "done"
|
---|
168 | @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
|
---|
169 |
|
---|
170 | $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS_INVALID:.asm=-64.tst)): $$(patsubst %.tst,%.bin,$$@) $$(INSTARGET_tstDisasm-2) | $$(call DIRDEP,$$(@D))
|
---|
171 | @$(ECHO) "TESTING: $(@F) [--undef-op=all]"
|
---|
172 | @$(RM) -f $@
|
---|
173 | $(REDIRECT) -E VBOX_LOG_DEST=nofile -- $(INSTARGET_tstDisasm-2) --undef-op=all --cpumode=64 $<
|
---|
174 | @$(APPEND) $@ "done"
|
---|
175 | @$(ECHO) " PASSED: $(@F) [--undef-op=all]"
|
---|
176 |
|
---|
177 |
|
---|
178 | # Generate the rules for the binary tests.
|
---|
179 | define def_vbox_disas_binary_rules
|
---|
180 | $(outbase).asm: $(full_binary) $$$$(INSTARGET_tstDisasm-2) | $(VBOX_DISAS_TEST_PATH)/
|
---|
181 | @$$(ECHO) "Generating: $$(@F) from $$(<F)"
|
---|
182 | $$(REDIRECT) -E VBOX_LOG_DEST=nofile -o $$@ -- $$(INSTARGET_tstDisasm-2) --style=yasm --cpumode=$(bits) --undef-op=db $$<
|
---|
183 |
|
---|
184 | $(outbase).bin + $(outbase).lst: $(outbase).asm
|
---|
185 | @$$(ECHO) "Re-assembling: $$(<F) into $$(@F)"
|
---|
186 | $$(TOOL_YASM_AS) -f bin -a x86 --force-strict -l $(outbase).lst -o $$@ $$<
|
---|
187 |
|
---|
188 | $(outbase).tst: $(outbase).bin
|
---|
189 | @$$(ECHO) "Verifying build: $$(<F) against $(not-dir $(full_binary))"
|
---|
190 | @$$(RM) -f $$@
|
---|
191 | $$(CMP) -l $(full_binary) $$<
|
---|
192 | @$$(APPEND) $$@ "done"
|
---|
193 | @$$(ECHO) " PASSED: $$(<F) [binary]"
|
---|
194 |
|
---|
195 | $(name).tst:: $(outbase).tst
|
---|
196 | VBOX_DISAS_TEST_CLEAN += $(outbase).tst $(outbase).bin $(outbase).asm
|
---|
197 | VBOX_DISAS_TESTS += $(name)-rebuild-$(bits).tst
|
---|
198 | endef # def_vbox_disas_binary_rules
|
---|
199 |
|
---|
200 | define def_vbox_disas_binary
|
---|
201 | local name := $(notdir $(basename $(binary)))
|
---|
202 | local full_binary := $(abspathex $(binary),$(PATH_SUB_CURRENT))
|
---|
203 | local outbase := $(VBOX_DISAS_TEST_PATH)/$(name)-rebuild-$(bits)
|
---|
204 | $(eval $(def_vbox_disas_binary_rules))
|
---|
205 | endef # def_vbox_disas_binary
|
---|
206 |
|
---|
207 | ## @todo 64-bit is problematic because of bugs like POP RDI ending up as POP EDI (incorrect default opmode).
|
---|
208 | #$(foreach bits, 32 16 64, $(foreach binary, $(VBOX_DISAS_TESTS_BINARIES), $(evalvalctx def_vbox_disas_binary)))
|
---|
209 | $(foreach bits, 32 16, $(foreach binary, $(VBOX_DISAS_TESTS_BINARIES), $(evalvalctx def_vbox_disas_binary)))
|
---|
210 |
|
---|
211 |
|
---|
212 | # Add the .tst to the clean up.
|
---|
213 | VBOX_DISAS_TEST_CLEAN += $(addprefix $(VBOX_DISAS_TEST_PATH)/, $(VBOX_DISAS_TESTS))
|
---|
214 | OTHER_CLEAN += $(VBOX_DISAS_TEST_CLEAN)
|
---|
215 |
|
---|
216 | # We don't want any of the tests rules to run in parallel because the
|
---|
217 | # output will be difficult to follow. Abusing VBOX_DISAS_TEST_CLEAN here...
|
---|
218 | .NOTPARALLEL: $(VBOX_DISAS_TEST_CLEAN)
|
---|
219 |
|
---|
220 |
|
---|
221 | #
|
---|
222 | # Add the tests to the target list for the testing pass.
|
---|
223 | # (kBuild r1646)
|
---|
224 | #
|
---|
225 | TESTING += $(addprefix $(VBOX_DISAS_TEST_PATH)/,$(VBOX_DISAS_TESTS))
|
---|
226 |
|
---|
227 | # Aliases for use till kBuild gets updated.
|
---|
228 | .PHONY: check test
|
---|
229 | check test: $(TESTING)
|
---|
230 |
|
---|
231 |
|
---|
232 | #
|
---|
233 | # The test aliases
|
---|
234 | #
|
---|
235 | # To run the tstAsmLock-3.asm test: kmk tstAsmLock-3.tst
|
---|
236 | # To run the 64-bit tstAsmLock-3.asm test: kmk tstAsmLock-3-64.tst
|
---|
237 | #
|
---|
238 | define def_vbox_test_aliases
|
---|
239 | local test_base := $(basename $(test))
|
---|
240 | local test_root := $(patsubst %-16,%,$(patsubst %-32,%,$(patsubst %-64,%,$(test_base))))
|
---|
241 | $(test_base).tst:: $(VBOX_DISAS_TEST_PATH)/$(test)
|
---|
242 | $(test_root).tst:: $(test_base).tst
|
---|
243 | $(test_base).o:: $(test_base).tst
|
---|
244 | $(test_base).obj:: $(test_base).tst
|
---|
245 | $(test_root).o:: $(test_root).tst
|
---|
246 | $(test_root).obj:: $(test_root).tst
|
---|
247 | endef
|
---|
248 | $(foreach test,$(VBOX_DISAS_TESTS),$(evalvalctx def_vbox_test_aliases))
|
---|
249 |
|
---|
250 | endif # VBOX_WITH_TESTCASES
|
---|
251 | include $(KBUILD_PATH)/subfooter.kmk
|
---|
252 |
|
---|