diff options
author | David Faust <david.faust@oracle.com> | 2020-08-26 15:39:00 +0200 |
---|---|---|
committer | Jose E. Marchesi <jose.marchesi@oracle.com> | 2020-08-26 15:39:00 +0200 |
commit | 4449c81a85eef44b10532032207e8db5858c00ee (patch) | |
tree | 654bfee49c2ea7d88e009f2a37ce6b15d1edd18f /gas | |
parent | 37f628c34d2d1f7e30c95b21f9c4c21819cb4534 (diff) | |
download | gdb-4449c81a85eef44b10532032207e8db5858c00ee.zip gdb-4449c81a85eef44b10532032207e8db5858c00ee.tar.gz gdb-4449c81a85eef44b10532032207e8db5858c00ee.tar.bz2 |
bpf: add xBPF ISA
This patch adds support for xBPF, another ISA targetting the BPF
virtual architecture. For now, the primary difference between eBPF
and xBPF is that xBPF supports indirect calls through the
'call %reg' form of the call instruction.
bfd/
* archures.c (bfd_mach_xbpf): Define.
* bfd-in2.h: Regenerate.
* cpu-bpf.c (bfd_xbpf_arch) New.
(bfd_bpf_arch) Update next in list field to point to xbpf arch.
cpu/
* bpf.cpu (arch bpf): Add xbpf mach and isas.
(define-xbpf-isa) New pmacro.
(all-isas) Add xbpfle,xbpfbe.
(endian-isas): New pmacro.
(mach xbpf): New.
(model xbpf-def): Likewise.
(h-gpr): Add xbpf mach.
(f-dstle, f-srcle, dstle, srcle): Add xbpfle isa.
(f-dstbe, f-srcbe, dstbe, srcbe): Add xbpfbe isa.
(define-alu-insn-un): Use new endian-isas pmacro.
(define-alu-insn-bin, define-alu-insn-mov): Likewise.
(define-endian-insn, define-lddw): Likewise.
(dlind, dxli, dxsi, dsti): Likewise.
(define-cond-jump-insn, define-call-insn): Likewise.
(define-atomic-insns): Likewise.
gas/
* config/tc-bpf.c: Add option -mxbpf to select xbpf isa.
* testsuite/gas/bpf/indcall-1.d: New file.
* testsuite/gas/bpf/indcall-1.s: Likewise.
* testsuite/gas/bpf/indcall-bad-1.l: Likewise.
* testsuite/gas/bpf/indcall-bad-1.s: Likewise.
* testsuite/gas/bpf/bpf.exp: Run new tests.
opcodes/
* bpf-desc.c: Regenerate.
* bpf-desc.h: Likewise.
* bpf-opc.c: Likewise.
* bpf-opc.h: Likewise.
* disassemble.c (disassemble_init_for_target): Set bits for xBPF
ISA when appropriate.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 9 | ||||
-rw-r--r-- | gas/config/tc-bpf.c | 34 | ||||
-rw-r--r-- | gas/testsuite/gas/bpf/bpf.exp | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/bpf/indcall-1.d | 22 | ||||
-rw-r--r-- | gas/testsuite/gas/bpf/indcall-1.s | 14 | ||||
-rw-r--r-- | gas/testsuite/gas/bpf/indcall-bad-1.l | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/bpf/indcall-bad-1.s | 1 |
7 files changed, 82 insertions, 4 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index d8c92db..4e367a4 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2020-08-26 David Faust <david.faust@oracle.com> + + * config/tc-bpf.c: Add option -mxbpf to select xbpf isa. + * testsuite/gas/bpf/indcall-1.d: New file. + * testsuite/gas/bpf/indcall-1.s: Likewise. + * testsuite/gas/bpf/indcall-bad-1.l: Likewise. + * testsuite/gas/bpf/indcall-bad-1.s: Likewise. + * testsuite/gas/bpf/bpf.exp: Run new tests. + 2020-08-25 Alan Modra <amodra@gmail.com> PR26501 diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c index 026a631..34b2adf 100644 --- a/gas/config/tc-bpf.c +++ b/gas/config/tc-bpf.c @@ -97,13 +97,15 @@ static CGEN_BITSET *bpf_isa; enum options { OPTION_LITTLE_ENDIAN = OPTION_MD_BASE, - OPTION_BIG_ENDIAN + OPTION_BIG_ENDIAN, + OPTION_XBPF }; struct option md_longopts[] = { { "EL", no_argument, NULL, OPTION_LITTLE_ENDIAN }, { "EB", no_argument, NULL, OPTION_BIG_ENDIAN }, + { "mxbpf", no_argument, NULL, OPTION_XBPF }, { NULL, no_argument, NULL, 0 }, }; @@ -117,6 +119,10 @@ extern int target_big_endian; arguments. */ static int set_target_endian = 0; +static int target_xbpf = 0; + +static int set_xbpf = 0; + int md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED) { @@ -130,6 +136,10 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED) set_target_endian = 1; target_big_endian = 0; break; + case OPTION_XBPF: + set_xbpf = 1; + target_xbpf = 1; + break; default: return 0; } @@ -143,7 +153,8 @@ md_show_usage (FILE * stream) fprintf (stream, _("\nBPF options:\n")); fprintf (stream, _("\ --EL generate code for a little endian machine\n\ - --EB generate code for a big endian machine\n")); + --EB generate code for a big endian machine\n\ + -mxbpf generate xBPF instructions\n")); } @@ -163,12 +174,27 @@ md_begin (void) #endif } + /* If not specified in the command line, use eBPF rather + than xBPF. */ + if (!set_xbpf) + target_xbpf = 0; + /* Set the ISA, which depends on the target endianness. */ bpf_isa = cgen_bitset_create (ISA_MAX); if (target_big_endian) - cgen_bitset_set (bpf_isa, ISA_EBPFBE); + { + if (target_xbpf) + cgen_bitset_set (bpf_isa, ISA_XBPFBE); + else + cgen_bitset_set (bpf_isa, ISA_EBPFBE); + } else - cgen_bitset_set (bpf_isa, ISA_EBPFLE); + { + if (target_xbpf) + cgen_bitset_set (bpf_isa, ISA_XBPFLE); + else + cgen_bitset_set (bpf_isa, ISA_EBPFLE); + } /* Set the machine number and endian. */ gas_cgen_cpu_desc = bpf_cgen_cpu_open (CGEN_CPU_OPEN_ENDIAN, diff --git a/gas/testsuite/gas/bpf/bpf.exp b/gas/testsuite/gas/bpf/bpf.exp index 6225d0b..242b190 100644 --- a/gas/testsuite/gas/bpf/bpf.exp +++ b/gas/testsuite/gas/bpf/bpf.exp @@ -38,4 +38,7 @@ if {[istarget bpf*-*-*]} { run_dump_test exit-be run_dump_test atomic-be run_dump_test data-be + + run_dump_test indcall-1 + run_list_test indcall-bad-1 } diff --git a/gas/testsuite/gas/bpf/indcall-1.d b/gas/testsuite/gas/bpf/indcall-1.d new file mode 100644 index 0000000..e61e125 --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-1.d @@ -0,0 +1,22 @@ +#as: -mxbpf --EL +#objdump: -mxbpf -dr +#name: BPF indirect call 1 + +.*: +file format .*bpf.* + +Disassembly of section \.text: + +0000000000000000 <main>: + 0: b7 00 00 00 01 00 00 00 mov %r0,1 + 8: b7 01 00 00 01 00 00 00 mov %r1,1 + 10: b7 02 00 00 02 00 00 00 mov %r2,2 + 18: 18 06 00 00 38 00 00 00 lddw %r6,0x38 + 20: 00 00 00 00 00 00 00 00[ ]* + 18: R_BPF_INSN_64 .text + 28: 8d 06 00 00 00 00 00 00 call %r6 + 30: 95 00 00 00 00 00 00 00 exit + +0000000000000038 <bar>: + 38: b7 00 00 00 00 00 00 00 mov %r0,0 + 40: 95 00 00 00 00 00 00 00 exit +#pass diff --git a/gas/testsuite/gas/bpf/indcall-1.s b/gas/testsuite/gas/bpf/indcall-1.s new file mode 100644 index 0000000..5d49e41 --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-1.s @@ -0,0 +1,14 @@ + + .text + .align 4 +main: + mov %r0, 1 + mov %r1, 1 + mov %r2, 2 + lddw %r6, bar + call %r6 + exit + +bar: + mov %r0, 0 + exit diff --git a/gas/testsuite/gas/bpf/indcall-bad-1.l b/gas/testsuite/gas/bpf/indcall-bad-1.l new file mode 100644 index 0000000..510ec6e --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-bad-1.l @@ -0,0 +1,3 @@ +.*: Assembler messages: +.* Error: illegal operand `call %r6' +#pass diff --git a/gas/testsuite/gas/bpf/indcall-bad-1.s b/gas/testsuite/gas/bpf/indcall-bad-1.s new file mode 100644 index 0000000..0cdc4ab --- /dev/null +++ b/gas/testsuite/gas/bpf/indcall-bad-1.s @@ -0,0 +1 @@ + call %r6 |