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

Unified 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: Minor update to the patch set 1 Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator_mips/testdata/test_jmp_imm.S
===================================================================
--- src/trusted/validator_mips/testdata/test_jmp_imm.S (revision 0)
+++ src/trusted/validator_mips/testdata/test_jmp_imm.S (revision 0)
@@ -0,0 +1,105 @@
+# Copyright 2012 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can
+# be found in the LICENSE file.
+# Copyright 2012 MIPS Technologies / RT-RK.
+
+# test cases for jmps/branches
+# there are several kinds of jmps/branches in regards to destination address
+# 1. jmps into 0-0x10000, null guard region, where everything is considered OK
+# 2. jmps into 0x10000-0x20000, trampoline code section, jmps need to be bundle aligned
+# 3. jmps into code section, jmps need to be bundle aligned
+# beside destination address we also check the position of jmp/b and link
+# instructions, which need to bundle offset +8
+
+
+.globl _start
+_start:
+.align 4
+.set noreorder
+
+bundle_b_to_0_0x1000:
+ b _start - 0x10000 #destination addres is 0x10000 - OK
+ nop
+ b _start - 0x1fff4 #destination addres is 0xc (null guard region)- OK
+ nop
+
+bundle_b_to_0x1000_0x20000:
+ b _start - 0x10000 # ok - trampoline start
+ nop
+ b _start - 0xfff4 # dest_addr = 0x1000c, error (middle of the trampoline)
+ nop
+
+bundle_b_to_code_area:
+ b _start + 0x1000 # ok
+ nop
+ b _start + 0x1004 # ok, not on pseudo instruction
+ nop
+ b _start + 0x10 # ok
+ nop
+ b end_of_code # ok
+ nop
+
+bundle_j_to_0_0x1000:
+#all is allowed, b/c that is guard region
+ j 0x0
+ nop
+ j 0x4
+ nop
+
+bundle_j_trampoline_area:
+ j 0x10000
+ nop
+ jal 0x10004 # kProblemUnalignedJumpToTrampoline (not a trampoline start)
+ nop
+
+ nop
+ nop
+ jal 0x10010 # ok - not a trampoline start, but there is a halt, so ok.
+ nop
+
+ nop
+ nop
+ jal 0x10020 # ok
+ nop
+
+bundle_j_negative:
+ j -0x4 # ok
+ nop
+ j -0x10 # ok
+ nop
+
+bundle_1st:
+ and $a0, $a0, $t7
+bundle_2nd:
+ sw $ra, 24($a0)
+ addiu $v0, $v0, 4
+ addiu $v0, $v1, 0
+
+bl_check:
+ nop
+ nop
+ bal bundle_1st #ok
+ nop
+
+bundle_check_b_dest_addr:
+ b bundle_1st # ok
+ nop
+ b bundle_2nd # kProblemBranchSplitsPattern
+ nop
+
+ bal 0x10000 #error misaligned call
+ nop
+ jalx 0x3ffffff0 #error, forbidden instruction
+ nop
+
+ jal 0x10000 #error misaligned call
+ nop
+ jal 0x3fffff0 #ok
+ nop
+
+ b bundle_2nd # kProblemBranchSplitsPattern
+ nop
+ nop
+ nop
+
+end_of_code:
Property changes on: src/trusted/validator_mips/testdata/test_jmp_imm.S
___________________________________________________________________
Added: svn:executable
+ *

Powered by Google App Engine
This is Rietveld 408576698