aboutsummaryrefslogtreecommitdiff
path: root/gas/testsuite
diff options
context:
space:
mode:
authorPeter Bergner <bergner@linux.ibm.com>2021-01-08 16:07:12 -0600
committerAlan Modra <amodra@gmail.com>2021-01-09 15:16:13 +1030
commitaae7fcb8d755a2eb3f32a3f945a4e8f30cf5c5e2 (patch)
tree42165a09c958a6884c90a9126b87c3c9b3b4358a /gas/testsuite
parent6430704567c6c3f838ad7d01d5dfcf3fcb8d6b24 (diff)
downloadgdb-aae7fcb8d755a2eb3f32a3f945a4e8f30cf5c5e2.zip
gdb-aae7fcb8d755a2eb3f32a3f945a4e8f30cf5c5e2.tar.gz
gdb-aae7fcb8d755a2eb3f32a3f945a4e8f30cf5c5e2.tar.bz2
POWER10: Add Return-Oriented Programming instructions
POWER10 adds some return-oriented programming (ROP) instructions and this patch adds support for them. You will notice that they are enabled for POWER8 and later, not just POWER10 and later. This is on purpose. This allows the instructions to be added to POWER8 binaries that can be run on POWER8, POWER9 and POWER10 cpus. On POWER8 and POWER9, these instructions just act as nop's. opcodes/ * ppc-opc.c (insert_dw, (extract_dw): New functions. (DW, (XRC_MASK): Define. (powerpc_opcodes) <hashchk, hashchkp, hashst, haststp>: New mnemonics. gas/ * testsuite/gas/ppc/rop-checks.d, * testsuite/gas/ppc/rop-checks.l, * testsuite/gas/ppc/rop-checks.s, * testsuite/gas/ppc/rop.d, * testsuite/gas/ppc/rop.s: New tests. * testsuite/gas/ppc/ppc.exp: Run them.
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/ppc/ppc.exp2
-rw-r--r--gas/testsuite/gas/ppc/rop-checks.d3
-rw-r--r--gas/testsuite/gas/ppc/rop-checks.l17
-rw-r--r--gas/testsuite/gas/ppc/rop-checks.s18
-rw-r--r--gas/testsuite/gas/ppc/rop.d27
-rw-r--r--gas/testsuite/gas/ppc/rop.s21
6 files changed, 88 insertions, 0 deletions
diff --git a/gas/testsuite/gas/ppc/ppc.exp b/gas/testsuite/gas/ppc/ppc.exp
index bec3151..6f61ad0 100644
--- a/gas/testsuite/gas/ppc/ppc.exp
+++ b/gas/testsuite/gas/ppc/ppc.exp
@@ -146,5 +146,7 @@ run_dump_test "stringop"
run_dump_test "xvtlsbb"
run_dump_test "rightmost"
run_dump_test "scalarquad"
+run_dump_test "rop"
+run_dump_test "rop-checks"
run_dump_test "dcbt"
diff --git a/gas/testsuite/gas/ppc/rop-checks.d b/gas/testsuite/gas/ppc/rop-checks.d
new file mode 100644
index 0000000..b7ef25e
--- /dev/null
+++ b/gas/testsuite/gas/ppc/rop-checks.d
@@ -0,0 +1,3 @@
+#as: -mpower10
+#name: Test Return-Oriented Programming checks
+#error_output: rop-checks.l
diff --git a/gas/testsuite/gas/ppc/rop-checks.l b/gas/testsuite/gas/ppc/rop-checks.l
new file mode 100644
index 0000000..83ffbee
--- /dev/null
+++ b/gas/testsuite/gas/ppc/rop-checks.l
@@ -0,0 +1,17 @@
+[^:]*: Assembler messages:
+[^:]*:3: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:4: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:5: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:6: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:7: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:8: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:9: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:10: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:11: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:12: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:13: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:14: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:15: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:16: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:17: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
+[^:]*:18: Error: invalid offset: must be in the range \[-512, -8\] and be a multiple of 8
diff --git a/gas/testsuite/gas/ppc/rop-checks.s b/gas/testsuite/gas/ppc/rop-checks.s
new file mode 100644
index 0000000..83ca35a
--- /dev/null
+++ b/gas/testsuite/gas/ppc/rop-checks.s
@@ -0,0 +1,18 @@
+ .text
+_start:
+ hashst 20,8(1)
+ hashst 21,0(1)
+ hashst 22,-12(1)
+ hashst 23,-520(1)
+ hashchk 20,8(1)
+ hashchk 21,0(1)
+ hashchk 22,-12(1)
+ hashchk 23,-520(1)
+ hashstp 20,8(1)
+ hashstp 21,0(1)
+ hashstp 22,-12(1)
+ hashstp 23,-520(1)
+ hashchkp 20,8(1)
+ hashchkp 21,0(1)
+ hashchkp 22,-12(1)
+ hashchkp 23,-520(1)
diff --git a/gas/testsuite/gas/ppc/rop.d b/gas/testsuite/gas/ppc/rop.d
new file mode 100644
index 0000000..2671dd6
--- /dev/null
+++ b/gas/testsuite/gas/ppc/rop.d
@@ -0,0 +1,27 @@
+#as: -mpower8
+#objdump: -d -Mpower8
+#name: Return-Oriented Programming tests
+
+.*
+
+
+Disassembly of section \.text:
+
+0+0 <_start>:
+.*: (7f e1 a5 a5|a5 a5 e1 7f) hashst r20,-8\(r1\)
+.*: (7f c1 ad a5|a5 ad c1 7f) hashst r21,-16\(r1\)
+.*: (7c 01 b5 a5|a5 b5 01 7c) hashst r22,-256\(r1\)
+.*: (7c 01 bd a4|a4 bd 01 7c) hashst r23,-512\(r1\)
+.*: (7f e1 a5 e5|e5 a5 e1 7f) hashchk r20,-8\(r1\)
+.*: (7f c1 ad e5|e5 ad c1 7f) hashchk r21,-16\(r1\)
+.*: (7c 01 b5 e5|e5 b5 01 7c) hashchk r22,-256\(r1\)
+.*: (7c 01 bd e4|e4 bd 01 7c) hashchk r23,-512\(r1\)
+.*: (7f e1 a5 25|25 a5 e1 7f) hashstp r20,-8\(r1\)
+.*: (7f c1 ad 25|25 ad c1 7f) hashstp r21,-16\(r1\)
+.*: (7c 01 b5 25|25 b5 01 7c) hashstp r22,-256\(r1\)
+.*: (7c 01 bd 24|24 bd 01 7c) hashstp r23,-512\(r1\)
+.*: (7f e1 a5 65|65 a5 e1 7f) hashchkp r20,-8\(r1\)
+.*: (7f c1 ad 65|65 ad c1 7f) hashchkp r21,-16\(r1\)
+.*: (7c 01 b5 65|65 b5 01 7c) hashchkp r22,-256\(r1\)
+.*: (7c 01 bd 64|64 bd 01 7c) hashchkp r23,-512\(r1\)
+#pass
diff --git a/gas/testsuite/gas/ppc/rop.s b/gas/testsuite/gas/ppc/rop.s
new file mode 100644
index 0000000..22e45f4
--- /dev/null
+++ b/gas/testsuite/gas/ppc/rop.s
@@ -0,0 +1,21 @@
+# These instructions are new in POWER10, but enabled for POWER8 and
+# later cpus. On POWER8 and POWER9, these instructions behave as
+# nop's.
+ .text
+_start:
+ hashst 20,-8(1)
+ hashst 21,-16(1)
+ hashst 22,-256(1)
+ hashst 23,-512(1)
+ hashchk 20,-8(1)
+ hashchk 21,-16(1)
+ hashchk 22,-256(1)
+ hashchk 23,-512(1)
+ hashstp 20,-8(1)
+ hashstp 21,-16(1)
+ hashstp 22,-256(1)
+ hashstp 23,-512(1)
+ hashchkp 20,-8(1)
+ hashchkp 21,-16(1)
+ hashchkp 22,-256(1)
+ hashchkp 23,-512(1)