OLD | NEW |
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # A temporary Makefile to build the DFA-based validator, decoder, tests. This | 5 # A temporary Makefile to build the DFA-based validator, decoder, tests. This |
6 # will likely go away as soon we integrate with the NaCl build system(s). | 6 # will likely go away as soon we integrate with the NaCl build system(s). |
7 | 7 |
8 OUT = out | 8 OUT = out |
9 OUT_DIRS = $(OUT)/build/objs \ | 9 OUT_DIRS = $(OUT)/build/objs \ |
10 $(OUT)/tarballs \ | 10 $(OUT)/tarballs \ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 $(OBJD)/%.c: %.rl | 45 $(OBJD)/%.c: %.rl |
46 $(RAGEL) -G2 -I$(OBJD) $< -o $@ | 46 $(RAGEL) -G2 -I$(OBJD) $< -o $@ |
47 | 47 |
48 # Decoder, validator, etc. | 48 # Decoder, validator, etc. |
49 $(OBJD)/decoder-test: \ | 49 $(OBJD)/decoder-test: \ |
50 $(OBJD)/decoder-x86_32.o $(OBJD)/decoder-x86_64.o $(OBJD)/decoder-test.o | 50 $(OBJD)/decoder-x86_32.o $(OBJD)/decoder-x86_64.o $(OBJD)/decoder-test.o |
51 $(OBJD)/validator-test: \ | 51 $(OBJD)/validator-test: \ |
52 $(OBJD)/validator-x86_32.o $(OBJD)/validator-x86_64.o $(OBJD)/validator-test
.o | 52 $(OBJD)/validator-x86_32.o $(OBJD)/validator-x86_64.o $(OBJD)/validator-test
.o |
53 | 53 |
54 GEN_DECODER=$(OBJD)/gen-decoder | 54 GEN_DECODER=$(OBJD)/gen-decoder |
55 $(GEN_DECODER): gen-decoder.C | 55 $(GEN_DECODER): gen-decoder.C | $(OUT_DIRS) |
56 $(CXX) $(CXXFLAGS) $< -o $(GEN_DECODER) | 56 $(CXX) $(CXXFLAGS) $< -o $(GEN_DECODER) |
57 | 57 |
58 $(OBJD)/decoder-x86_32.c: $(OBJD)/decoder-x86_32-instruction-consts.c | 58 $(OBJD)/decoder-x86_32.c: $(OBJD)/decoder-x86_32-instruction-consts.c |
59 $(OBJD)/decoder-x86_32.c: $(OBJD)/decoder-x86_32-instruction.rl | 59 $(OBJD)/decoder-x86_32.c: $(OBJD)/decoder-x86_32-instruction.rl |
60 $(OBJD)/decoder-x86_32-instruction-consts.c \ | 60 $(OBJD)/decoder-x86_32-instruction-consts.c \ |
61 $(OBJD)/decoder-x86_32-instruction.rl: $(GEN_DECODER) $(INST_DEFS) | 61 $(OBJD)/decoder-x86_32-instruction.rl: $(GEN_DECODER) $(INST_DEFS) |
62 $(GEN_DECODER) -o $(OBJD)/decoder-x86_32-instruction.rl $(INST_DEFS) \ | 62 $(GEN_DECODER) -o $(OBJD)/decoder-x86_32-instruction.rl $(INST_DEFS) \ |
63 -d check_access,opcode,parse_operands_states,mark_data_fields | 63 -d check_access,opcode,parse_operands_states,mark_data_fields |
64 | 64 |
65 $(OBJD)/decoder-x86_64.c: $(OBJD)/decoder-x86_64-instruction-consts.c | 65 $(OBJD)/decoder-x86_64.c: $(OBJD)/decoder-x86_64-instruction-consts.c |
(...skipping 16 matching lines...) Expand all Loading... |
82 $(OBJD)/validator-x86_64.c: $(OBJD)/validator-x86_64-instruction.rl | 82 $(OBJD)/validator-x86_64.c: $(OBJD)/validator-x86_64-instruction.rl |
83 $(OBJD)/validator-x86_64-instruction-consts.c \ | 83 $(OBJD)/validator-x86_64-instruction-consts.c \ |
84 $(OBJD)/validator-x86_64-instruction.rl: $(GEN_DECODER) $(INST_DEFS) | 84 $(OBJD)/validator-x86_64-instruction.rl: $(GEN_DECODER) $(INST_DEFS) |
85 $(GEN_DECODER) -o $(OBJD)/validator-x86_64-instruction.rl $(INST_DEFS) \ | 85 $(GEN_DECODER) -o $(OBJD)/validator-x86_64-instruction.rl $(INST_DEFS) \ |
86 -d opcode,instruction_name,mark_data_fields,rel_operand_action \ | 86 -d opcode,instruction_name,mark_data_fields,rel_operand_action \ |
87 -d nacl-forbidden nops.def -m amd64 | 87 -d nacl-forbidden nops.def -m amd64 |
88 | 88 |
89 # Facilities for testing: | 89 # Facilities for testing: |
90 # one-instruction.dot: the description of the DFA that accepts all instruction | 90 # one-instruction.dot: the description of the DFA that accepts all instruction |
91 # the decoder is able to decode. | 91 # the decoder is able to decode. |
92 # decoder-test-x86-64: the decoder that follows the objdump format | 92 # decoder-test: the decoder that follows the objdump format |
93 $(OBJD)/one-instruction-x86_32.dot: one-instruction-x86_32.rl \ | 93 $(OBJD)/one-instruction-x86_32.dot: one-instruction-x86_32.rl \ |
94 $(OBJD)/one-valid-instruction-x86_32-consts.c \ | 94 $(OBJD)/one-valid-instruction-x86_32-consts.c \ |
95 $(OBJD)/one-valid-instruction-x86_32.rl | 95 $(OBJD)/one-valid-instruction-x86_32.rl |
96 $(RAGEL) -V -I$(OBJD) $< -o $@ | 96 $(RAGEL) -V -I$(OBJD) $< -o $@ |
97 | 97 |
98 $(OBJD)/one-instruction-x86_64.dot: one-instruction-x86_64.rl \ | 98 $(OBJD)/one-instruction-x86_64.dot: one-instruction-x86_64.rl \ |
99 $(OBJD)/one-valid-instruction-x86_64-consts.c \ | 99 $(OBJD)/one-valid-instruction-x86_64-consts.c \ |
100 $(OBJD)/one-valid-instruction-x86_64.rl | 100 $(OBJD)/one-valid-instruction-x86_64.rl |
101 $(RAGEL) -V -I$(OBJD) $< -o $@ | 101 $(RAGEL) -V -I$(OBJD) $< -o $@ |
102 | 102 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 rm -rf "$(OUT)"/timestamps "$(OUT)"/build | 183 rm -rf "$(OUT)"/timestamps "$(OUT)"/build |
184 | 184 |
185 # Clean side effects created while running tests. | 185 # Clean side effects created while running tests. |
186 .PHONY: clean-tests | 186 .PHONY: clean-tests |
187 clean-tests: | 187 clean-tests: |
188 rm -rf "$(OUT)"/test "$(FAST_TMP_FOR_TEST)"/_test_dfa_insts* | 188 rm -rf "$(OUT)"/test "$(FAST_TMP_FOR_TEST)"/_test_dfa_insts* |
189 rm -f dfa_ncval | 189 rm -f dfa_ncval |
190 | 190 |
191 # The target for all short-running tests. | 191 # The target for all short-running tests. |
192 .PHONY: check | 192 .PHONY: check |
193 check: check-irt check-as-alt-validator | 193 check: check-irt check-as-alt-validator check-ncval |
194 | 194 |
195 # Checks that the IRT is not rejected by the validator. | 195 # Checks that the IRT is not rejected by the validator. |
196 .PHONY: check-irt | 196 .PHONY: check-irt |
197 check-irt: outdirs $(OBJD)/validator-test | 197 check-irt: outdirs $(OBJD)/validator-test |
198 $(OBJD)/validator-test nacl_irt_x86_64.nexe | 198 $(OBJD)/validator-test nacl_irt_x86_64.nexe |
199 | 199 |
200 .PHONY: check-as-alt-validator | 200 .PHONY: check-as-alt-validator |
201 check-as-alt-validator: $(OBJD)/validator-test | 201 check-as-alt-validator: $(OBJD)/validator-test |
202 ln -sfn $(OBJD)/validator-test dfa_ncval | 202 ln -sfn $(OBJD)/validator-test dfa_ncval |
203 $(PYTHON2X) validator_test.py | 203 $(PYTHON2X) validator_test.py |
(...skipping 26 matching lines...) Expand all Loading... |
230 $(CC) $(LDFLAGS) "$(OUT)/test/test_dfa.o" \ | 230 $(CC) $(LDFLAGS) "$(OUT)/test/test_dfa.o" \ |
231 "$(OUT)/test/test_dfa_transitions-x86_64.o" \ | 231 "$(OUT)/test/test_dfa_transitions-x86_64.o" \ |
232 -o $(OUT)/test/test_dfa-x86_64 | 232 -o $(OUT)/test/test_dfa-x86_64 |
233 $(PYTHON2X) run_objdump_test.py \ | 233 $(PYTHON2X) run_objdump_test.py \ |
234 --gas="$(GAS) --64" \ | 234 --gas="$(GAS) --64" \ |
235 --objdump="$(OBJDUMP)" \ | 235 --objdump="$(OBJDUMP)" \ |
236 --decoder="$(OBJD)/decoder-test" \ | 236 --decoder="$(OBJD)/decoder-test" \ |
237 --tester=./decoder_test_one_file.sh \ | 237 --tester=./decoder_test_one_file.sh \ |
238 --nthreads=`cat /proc/cpuinfo | grep processor | wc -l` -- \ | 238 --nthreads=`cat /proc/cpuinfo | grep processor | wc -l` -- \ |
239 "$(OUT)/test/test_dfa-x86_64" "$(FAST_TMP_FOR_TEST)" | 239 "$(OUT)/test/test_dfa-x86_64" "$(FAST_TMP_FOR_TEST)" |
| 240 |
| 241 # The list of tests having both .hex and .rval files, acquired by |
| 242 # scanning native_client/src/trusted/validator_x86/testdata/64/. |
| 243 # TODO(pasko): automate the process of scanning |
| 244 HEX_TESTS=3DNow add_cs_gs_prefix add_mult_prefix addrex addrex2 add_rsp_r15 \ |
| 245 AhNotSubRsp ambig-segment bad66 bsf-mask bsr-mask bt call_aligned call-ex \ |
| 246 call_not_aligned call_not_aligned_16 change-subregs cmpxchg cpuid \ |
| 247 data66prefix direct-call-16 direct-call-32 direct-cond-jump-16 \ |
| 248 direct-cond-jump-32 direct-jump-16 direct-jump-32 dup-prefix extensions \ |
| 249 fpu fs_use hlt inc67 incno67 indirect_jmp_masked indirect_jmp_not_masked \ |
| 250 invalid_base invalid_base_store invalid_width_index jmp-16 jump_atomic \ |
| 251 jump_outside lea lea-add-rsp lea-rsp legacy maskmov_test mmx \ |
| 252 mov-esi-nop-use mov_esp_add_rsp_r15 mov-lea-rbp mov-lea-rbp-bad-1 \ |
| 253 mov-lea-rbp-bad-2 mov-lea-rbp-bad-3 mov-lea-rbp-bad-4 mov-lea-rbp-bad-5 \ |
| 254 mov-lea-rsp movlps-ex mov_rbp_2_rsp movsbw movs_test mv_ebp_add_rbp_r15 \ |
| 255 mv_ebp_alone nacl_illegal nops pop-rbp prefix-2 prefix-3 prefix-single \ |
| 256 push-memoff rbp67 rdmsr read_const_ptr rep_tests rex_invalid rex_not_last \ |
| 257 rip67 rip-relative segment_assign segment_store sse stack_regs stosd \ |
| 258 stosd67 stosd-bad stosdno67 strings stubseq sub-add-rsp sub-rsp test_alias \ |
| 259 test_insts ud2 valid_and_store valid_base_only valid_lea_store wrmsr x87 |
| 260 |
| 261 # Converts existing validator tests in testdata/64 and produces golden files |
| 262 # that can be used to compare with the DFA-based validator. |
| 263 .PHONY: convert-testdata |
| 264 convert-testdata: |
| 265 ln -sfn ../../validator_x86/testdata |
| 266 (for tst in $(HEX_TESTS); do \ |
| 267 python parse_hex.py testdata/64/$$tst.rval ; \ |
| 268 done) || /bin/true |
| 269 mv testdata/64/*.val.ref golden/ |
| 270 |
| 271 .PHONY: check-ncval |
| 272 check-ncval: outdirs $(BINUTILS_STAMP) $(OBJD)/validator-test \ |
| 273 $(OBJD)/decoder-test |
| 274 ln -sfn ../../validator_x86/testdata |
| 275 $(PYTHON2X) run_ncval_tests.py \ |
| 276 --decoder="$(OBJD)/decoder-test" \ |
| 277 --validator="$(OBJD)/validator-test" \ |
| 278 --gas="$(GAS)" \ |
| 279 --tmp="$(OUT)/test/" |
OLD | NEW |