aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorDavid Faust <david.faust@oracle.com>2026-02-04 13:53:34 -0800
committerDavid Faust <david.faust@oracle.com>2026-02-05 12:26:09 -0800
commitbdb4d0030dedaaf18f09690218a2896ea57a4cdd (patch)
tree204157deee3621e972f07f9512c27d23212a2734 /gas
parentba61cf9952f4f0c4b3d237348e8e17641918d354 (diff)
downloadbinutils-master.zip
binutils-master.tar.gz
binutils-master.tar.bz2
bpf: add may_goto instruction [PR32176]HEADmaster
The BPF "may_goto" instruction is a special sort of conditional jump where the condition is determined by the BPF runtime. That is, it is a no-op until the runtime decides otherwise. For normal asm syntax, the mnemonic "jcond" is chosen in keeping with the style of following the opcode definitions in the Linux kernel uapi BPF headers. This instruction is not currently emitted by GCC, but it can be inserted into BPF programs via macros defined in the Linux kernel. PR gas/32176 include/ * opcode/bpf.h (BPF_CODE_JCOND): New. (bpf_insn_id): Add BPF_INSN_JCOND. opcodes/ * bpf-opc.c: Add entry for BPF_INSN_JCOND. gas/testsuite/ * gas/bpf/bpf.exp: Run new dump tests. * gas/bpf/jcond-be-pseudoc.d: New. * gas/bpf/jcond-be.d: New. * gas/bpf/jcond-pseudoc.d: New. * gas/bpf/jcond-pseudoc.s: New. * gas/bpf/jcond.d: New. * gas/bpf/jcond.s: New.
Diffstat (limited to 'gas')
-rw-r--r--gas/testsuite/gas/bpf/bpf.exp6
-rw-r--r--gas/testsuite/gas/bpf/jcond-be-pseudoc.d14
-rw-r--r--gas/testsuite/gas/bpf/jcond-be.d14
-rw-r--r--gas/testsuite/gas/bpf/jcond-pseudoc.d14
-rw-r--r--gas/testsuite/gas/bpf/jcond-pseudoc.s8
-rw-r--r--gas/testsuite/gas/bpf/jcond.d14
-rw-r--r--gas/testsuite/gas/bpf/jcond.s8
7 files changed, 78 insertions, 0 deletions
diff --git a/gas/testsuite/gas/bpf/bpf.exp b/gas/testsuite/gas/bpf/bpf.exp
index 89955e1..f193221 100644
--- a/gas/testsuite/gas/bpf/bpf.exp
+++ b/gas/testsuite/gas/bpf/bpf.exp
@@ -47,6 +47,9 @@ if {[istarget bpf*-*-*]} {
run_dump_test jump-relax-ja
run_dump_test jump-relax-jump
+ run_dump_test jcond
+ run_dump_test jcond-pseudoc
+
# Big-endian BPF tests
run_dump_test call-be
run_dump_test exit-be
@@ -70,6 +73,9 @@ if {[istarget bpf*-*-*]} {
run_dump_test jump-relax-ja-be
run_dump_test jump-relax-jump-be
+ run_dump_test jcond-be
+ run_dump_test jcond-be-pseudoc
+
# Overflow tests
run_dump_test offset16-overflow
run_dump_test disp16-overflow
diff --git a/gas/testsuite/gas/bpf/jcond-be-pseudoc.d b/gas/testsuite/gas/bpf/jcond-be-pseudoc.d
new file mode 100644
index 0000000..5bd24e1
--- /dev/null
+++ b/gas/testsuite/gas/bpf/jcond-be-pseudoc.d
@@ -0,0 +1,14 @@
+#as: -EB -mdialect=pseudoc
+#objdump: -dr -M dec,pseudoc
+#source: jcond-pseudoc.s
+#name: BPF conditional pseudo-jump instruction, pseudoc syntax, big-endian
+
+.*: +file format .*bpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+ 0: e5 00 00 00 00 00 00 00 may_goto 0
+ 8: e5 00 00 01 00 00 00 00 may_goto 1
+ 10: e5 00 ff fe 00 00 00 00 may_goto -2
+ 18: e5 00 ff fd 00 00 00 00 may_goto -3
diff --git a/gas/testsuite/gas/bpf/jcond-be.d b/gas/testsuite/gas/bpf/jcond-be.d
new file mode 100644
index 0000000..da2cfba
--- /dev/null
+++ b/gas/testsuite/gas/bpf/jcond-be.d
@@ -0,0 +1,14 @@
+#as: -EB -mdialect=normal
+#objdump: -dr -M dec
+#source: jcond.s
+#name: BPF conditional pseudo-jump instruction, normal syntax, big-endian
+
+.*: +file format .*bpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+ 0: e5 00 00 00 00 00 00 00 jcond 0
+ 8: e5 00 00 01 00 00 00 00 jcond 1
+ 10: e5 00 ff fe 00 00 00 00 jcond -2
+ 18: e5 00 ff fd 00 00 00 00 jcond -3
diff --git a/gas/testsuite/gas/bpf/jcond-pseudoc.d b/gas/testsuite/gas/bpf/jcond-pseudoc.d
new file mode 100644
index 0000000..34c14c2
--- /dev/null
+++ b/gas/testsuite/gas/bpf/jcond-pseudoc.d
@@ -0,0 +1,14 @@
+#as: -EL -mdialect=pseudoc
+#objdump: -dr -M dec,pseudoc
+#source: jcond-pseudoc.s
+#name: BPF conditional pseudo-jump instruction, pseudoc syntax
+
+.*: +file format .*bpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+ 0: e5 00 00 00 00 00 00 00 may_goto 0
+ 8: e5 00 01 00 00 00 00 00 may_goto 1
+ 10: e5 00 fe ff 00 00 00 00 may_goto -2
+ 18: e5 00 fd ff 00 00 00 00 may_goto -3
diff --git a/gas/testsuite/gas/bpf/jcond-pseudoc.s b/gas/testsuite/gas/bpf/jcond-pseudoc.s
new file mode 100644
index 0000000..b48ef38
--- /dev/null
+++ b/gas/testsuite/gas/bpf/jcond-pseudoc.s
@@ -0,0 +1,8 @@
+# Test for conditional pseudo-jump instruction in pseudo-c syntax
+ .text
+ may_goto 1f
+1:
+ may_goto 2f
+ may_goto 1b
+2:
+ may_goto 1b
diff --git a/gas/testsuite/gas/bpf/jcond.d b/gas/testsuite/gas/bpf/jcond.d
new file mode 100644
index 0000000..69570e2
--- /dev/null
+++ b/gas/testsuite/gas/bpf/jcond.d
@@ -0,0 +1,14 @@
+#as: -EL -mdialect=normal
+#objdump: -dr -M dec
+#source: jcond.s
+#name: BPF conditional pseudo-jump instruction, normal syntax, little-endian
+
+.*: +file format .*bpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+ 0: e5 00 00 00 00 00 00 00 jcond 0
+ 8: e5 00 01 00 00 00 00 00 jcond 1
+ 10: e5 00 fe ff 00 00 00 00 jcond -2
+ 18: e5 00 fd ff 00 00 00 00 jcond -3
diff --git a/gas/testsuite/gas/bpf/jcond.s b/gas/testsuite/gas/bpf/jcond.s
new file mode 100644
index 0000000..9c61644c
--- /dev/null
+++ b/gas/testsuite/gas/bpf/jcond.s
@@ -0,0 +1,8 @@
+# Test for conditional pseudo-jump instruction
+ .text
+ jcond 1f
+1:
+ jcond 2f
+ jcond 1b
+2:
+ jcond 1b