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