Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/trusted/validator_mips/testdata/test_jmp_imm.S

Issue 9979025: [MIPS] Adding validator for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Rebased patch, conflict resolved. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2012 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can
3 # be found in the LICENSE file.
4
5 # Test cases for jumps/branches.
6 # There are several kinds of jumps/branches regarding destination address:
7 # 1. Jumps into 0-0x10000, null guard region, where every address is OK.
8 # 2. Jumps into 0x10000-0x20000, trampoline code section, destination address
9 # needs to be bundle aligned.
10 # 3. Jumps into code section, all addresses are OK with additional check whether
11 # a branch target address is inside of a pseudo-instruction.
12 # Besides destination address we also check the position of branch/jump-and-link
13 # instructions, which need to be at bundle offset +8.
14
15 .globl _start
16 _start:
17 .align 4
18 .set noreorder
19
20 # Branches to null guard region, everything is OK.
21
22 bundle_b_to_0_0x1000:
23 b _start - 0x10010 # Destination address is 0xfff0 - OK.
24 nop # Instruction in the delay slot is always indented.
25 b _start - 0x1fff4 # Destination address is 0xc - OK.
26 nop
27
28 # Branches to trampoline code section, must be bundle aligned.
29
30 bundle_b_to_0x1000_0x20000:
31 b _start - 0x10000 # OK - trampoline start.
32 nop
33 b _start - 0xfff0 # OK - bundle aligned jump into trampoline.
34 nop
35 b _start - 0xfff4 # Error, destination address is 0x1000c, which is
36 nop # is not bundle aligned.
37 nop
38 nop
39
40 # Branches to code area.
41
42 bundle_b_to_code_area:
43 b _start + 0x1000 # OK
44 nop
45 b _start + 0x1004 # OK
46 nop
47 b _start + 0x10 # OK
48 nop
49 b end_of_code # OK
50 nop
51
52 # Both jumps are OK, because destinations are in guard region.
53
54 bundle_j_to_0_0x1000:
55 j 0x0
56 nop
57 j 0x4
58 nop
59
60 # Direct jumps to trampoline area, must be bundle aligned.
61
62 bundle_j_trampoline_area:
63 j 0x10000
64 nop
65 jal 0x10004 # Error - 0x10004 is not a trampoline start.
66 nop
67
68 nop
69 nop
70 jal 0x10010 # OK - not a trampoline start, but there is a halt.
71 nop
72
73 nop
74 nop
75 jal 0x10020 # OK
76 nop
77
78 # Jumps with negative argument.
79
80 bundle_j_negative:
81 j -0x4 # Dest. address 0xffffffc, inside code region - OK.
82 nop
83 j -0x10 # Dest. address 0xffffff0, inside code region - OK.
84 nop
85
86 bundle_1st:
87 and $a0, $a0, $t7
88 bundle_2nd:
89 sw $ra, 24($a0)
90 addiu $v0, $v0, 4
91 addiu $v0, $v1, 0
92
93 bl_check:
94 nop
95 nop
96 bal bundle_1st # OK
97 nop
98
99 # Branch inside a pseudo-instruction.
100
101 bundle_check_b_dest_addr:
102 b bundle_1st # OK
103 nop
104 b bundle_2nd # Error, branch at the middle of pseudo-instruction.
105 nop
106
107 # Test if branch and link is located at bundle offset 8.
108
109 bal 0x10000 # Error, misaligned call.
110 nop
111 bal 0x10000 # OK
112 nop
113
114 # Test if jump and link is located at bundle offset 8.
115
116 jal 0x10000 # Error, misaligned call.
117 nop
118 jal 0x3fffff0 # OK
119 nop
120
121 # Another branch instruction with the same target address.
122 # Check if this one is also reported.
123
124 b bundle_2nd # Error, branch at middle of pseudo-instruction.
125 nop
126
127 # Test forbidden instruction.
128
129 jalx 0x3ffffff0 # Error, forbidden instruction.
130 nop
131
132 end_of_code:
OLDNEW
« no previous file with comments | « src/trusted/validator_mips/testdata/test_invalid_dest.err ('k') | src/trusted/validator_mips/testdata/test_jmp_imm.err » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698