From 4449c81a85eef44b10532032207e8db5858c00ee Mon Sep 17 00:00:00 2001 From: David Faust Date: Wed, 26 Aug 2020 15:39:00 +0200 Subject: 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. --- bfd/ChangeLog | 7 +++++++ bfd/archures.c | 1 + bfd/bfd-in2.h | 1 + bfd/cpu-bpf.c | 22 +++++++++++++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8a26777..616b22f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2020-08-26 David Faust + + * 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. + 2020-08-26 Alan Modra * archures.c (bfd_mach_ck860): Define. diff --git a/bfd/archures.c b/bfd/archures.c index 715abc7..969fa20 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -411,6 +411,7 @@ DESCRIPTION .#define bfd_mach_iq10 2 . bfd_arch_bpf, {* Linux eBPF. *} .#define bfd_mach_bpf 1 +.#define bfd_mach_xbpf 2 . bfd_arch_epiphany, {* Adapteva EPIPHANY. *} .#define bfd_mach_epiphany16 1 .#define bfd_mach_epiphany32 2 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index a16d037..3c85b07 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1811,6 +1811,7 @@ enum bfd_architecture #define bfd_mach_iq10 2 bfd_arch_bpf, /* Linux eBPF. */ #define bfd_mach_bpf 1 +#define bfd_mach_xbpf 2 bfd_arch_epiphany, /* Adapteva EPIPHANY. */ #define bfd_mach_epiphany16 1 #define bfd_mach_epiphany32 2 diff --git a/bfd/cpu-bpf.c b/bfd/cpu-bpf.c index edd24c6..947d786 100644 --- a/bfd/cpu-bpf.c +++ b/bfd/cpu-bpf.c @@ -23,6 +23,26 @@ #include "bfd.h" #include "libbfd.h" + +static const bfd_arch_info_type bfd_xbpf_arch = +{ + 64, /* Bits per word. */ + 64, /* Bits per address. */ + 8, /* Bits per byte. */ + bfd_arch_bpf, /* Architecture. */ + bfd_mach_xbpf, /* Machine. */ + "bpf", /* Architecture name. */ + "xbpf", /* Machine name. */ + 3, /* Section align power. */ + FALSE, /* The default ? */ + bfd_default_compatible, /* Architecture comparison fn. */ + bfd_default_scan, /* String to architecture convert fn. */ + bfd_arch_default_fill, /* Default fill. */ + NULL, /* Next in list. */ + 0 /* Maximum offset of a reloc from the start of an insn. */ +}; + + const bfd_arch_info_type bfd_bpf_arch = { 64, /* Bits per word. */ @@ -37,6 +57,6 @@ const bfd_arch_info_type bfd_bpf_arch = bfd_default_compatible, /* Architecture comparison fn. */ bfd_default_scan, /* String to architecture convert fn. */ bfd_arch_default_fill, /* Default fill. */ - NULL, /* Next in list. */ + &bfd_xbpf_arch, /* Next in list. */ 0 /* Maximum offset of a reloc from the start of an insn. */ }; -- cgit v1.1