This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/oracle/bpf] bfd, binutils, cpu, gas, include, opcodes: import of initial work on supporting BPF


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=531db4b75a571b752ffba32f93c210708e70b5d6

commit 531db4b75a571b752ffba32f93c210708e70b5d6
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date:   Mon Nov 19 21:29:36 2018 +0100

    bfd,binutils,cpu,gas,include,opcodes: import of initial work on supporting BPF

Diff:
---
 bfd/ChangeLog                 |  14 ++
 bfd/Makefile.in               |   5 +-
 bfd/aclocal.m4                |  44 ++--
 bfd/archures.c                |   5 +
 bfd/bfd-in2.h                 |   7 +
 bfd/config.bfd                |  16 ++
 bfd/configure                 |  30 ++-
 bfd/configure.ac              |   2 +
 bfd/cpu-bpf.c                 |  58 +++++
 bfd/doc/Makefile.in           |   5 +-
 bfd/elf64-bpf.c               | 295 ++++++++++++++++++++++++
 bfd/libbfd.h                  |   2 +
 bfd/reloc.c                   |   7 +
 bfd/targets.c                 |   9 +-
 binutils/ChangeLog            |   8 +
 binutils/readelf.c            |   8 +
 config.sub                    |   4 +-
 cpu/ChangeLog                 |   5 +
 cpu/bpf.cpu                   | 517 ++++++++++++++++++++++++++++++++++++++++++
 cpu/bpf.opc                   | 108 +++++++++
 gas/ChangeLog                 |  18 ++
 gas/Makefile.in               |   5 +-
 gas/aclocal.m4                |  46 ++--
 gas/config/tc-bpf.c           | 274 ++++++++++++++++++++++
 gas/configure                 |  40 +++-
 gas/configure.ac              |   8 +
 gas/configure.tgt             |   3 +
 gas/doc/Makefile.in           |   5 +-
 gas/testsuite/gas/bpf/alu.d   |  64 ++++++
 gas/testsuite/gas/bpf/alu.s   |  57 +++++
 gas/testsuite/gas/bpf/alu64.d |  58 +++++
 gas/testsuite/gas/bpf/alu64.s |  51 +++++
 gas/testsuite/gas/bpf/bpf.exp |  25 ++
 gas/testsuite/gas/bpf/lddw.d  |  17 ++
 gas/testsuite/gas/bpf/lddw.s  |   6 +
 gas/testsuite/gas/bpf/mem.d   |  17 ++
 gas/testsuite/gas/bpf/mem.s   |  12 +
 include/ChangeLog             |   4 +
 include/elf/bpf.h             |  34 +++
 opcodes/ChangeLog             |  13 ++
 opcodes/Makefile.am           |  17 ++
 opcodes/Makefile.in           |  27 ++-
 opcodes/aclocal.m4            |  44 ++--
 opcodes/configure             |  19 +-
 opcodes/configure.ac          |   1 +
 opcodes/disassemble.c         |   6 +
 opcodes/disassemble.h         |   1 +
 47 files changed, 1922 insertions(+), 99 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ffde4c9..02abb73 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+2018-11-26  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* elf64-bpf.c: New file.
+	* configure.ac (TDEFINES): Handle bpf_elf64_le_vec and
+	bpf_elf64_be_vec.
+	* targets.c (bpf_elf64_le_vec): Extern declaration.
+	(bpf_elf64_be_vec): Likewise.
+	(_bfd_target_vector): Added addresses of vectors for bpf.
+	* cpu-bpf.c: New file.
+	* config.bfd (targ_cpu): Recognize bpf-*-* targets.
+	* archures.c (bfd_arch_bpf): Define.
+	(bfd_mach_bpf_le): Likewise.
+	(bfd_mach_bpf_be): Likewise.
+
 2018-11-13  Jim Wilson  <jimw@sifive.com>
 
 	* elfnn-riscv.c (riscv_float_abi_string): New.
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index e63d63a..ceec358 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -438,6 +438,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4
index 4a6a47c..562636d 100644
--- a/bfd/aclocal.m4
+++ b/bfd/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2017 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
 [am__api_version='1.15'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.15.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.15.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2017 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -408,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -605,7 +605,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -629,7 +629,7 @@ AC_SUBST([install_sh])])
 # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
 # From Jim Meyering
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -664,7 +664,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -714,7 +714,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2017 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -753,7 +753,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -782,7 +782,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -829,7 +829,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -848,7 +848,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -929,7 +929,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2017 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -989,7 +989,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1017,7 +1017,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2017 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1036,7 +1036,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2017 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/bfd/archures.c b/bfd/archures.c
index 82b6741..2ceafc7 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -414,6 +414,9 @@ DESCRIPTION
 . bfd_arch_iq2000,     {* Vitesse IQ2000.  *}
 .#define bfd_mach_iq2000	1
 .#define bfd_mach_iq10		2
+.  bfd_arch_bpf,       {* Linux BPF.  *}
+.#define bfd_mach_bpf_le	1
+.#define bfd_mach_bpf_be	2
 .  bfd_arch_epiphany,  {* Adapteva EPIPHANY.  *}
 .#define bfd_mach_epiphany16	1
 .#define bfd_mach_epiphany32	2
@@ -598,6 +601,7 @@ extern const bfd_arch_info_type bfd_csky_arch;
 extern const bfd_arch_info_type bfd_d10v_arch;
 extern const bfd_arch_info_type bfd_d30v_arch;
 extern const bfd_arch_info_type bfd_dlx_arch;
+extern const bfd_arch_info_type bfd_bpf_arch;
 extern const bfd_arch_info_type bfd_epiphany_arch;
 extern const bfd_arch_info_type bfd_fr30_arch;
 extern const bfd_arch_info_type bfd_frv_arch;
@@ -689,6 +693,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
     &bfd_d10v_arch,
     &bfd_d30v_arch,
     &bfd_dlx_arch,
+    &bfd_bpf_arch,
     &bfd_epiphany_arch,
     &bfd_fr30_arch,
     &bfd_frv_arch,
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index ee8cd7e..b39c016 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2312,6 +2312,9 @@ enum bfd_architecture
  bfd_arch_iq2000,     /* Vitesse IQ2000.  */
 #define bfd_mach_iq2000        1
 #define bfd_mach_iq10          2
+  bfd_arch_bpf,       /* Linux BPF.  */
+#define bfd_mach_bpf_le        1
+#define bfd_mach_bpf_be        2
   bfd_arch_epiphany,  /* Adapteva EPIPHANY.  */
 #define bfd_mach_epiphany16    1
 #define bfd_mach_epiphany32    2
@@ -6585,6 +6588,10 @@ assembler and not (currently) written to any object files.  */
   BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD,
   BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD,
 
+/* Linux eBPF relocations.  */
+  BFD_RELOC_BPF_64_64,
+  BFD_RELOC_BPF_64_32,
+
 /* Adapteva EPIPHANY - 8 bit signed pc-relative displacement  */
   BFD_RELOC_EPIPHANY_SIMM8,
 
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 2bde98a..0419f4e 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -480,6 +480,22 @@ case "${targ}" in
     targ_defvec=d30v_elf32_vec
     ;;
 
+  bpfel-*-*)
+    # Note that bpfel is supported for compatibility with llvm.
+    targ_defvec=bpf_elf64_le_vec
+    targ_selvecs=bpf_elf64_be_vec
+    targ_archs="bfd_bpf_arch"
+    targ_underscore=yes
+    ;;
+
+  bpfeb-*-*)
+    # Note that bpfeb is supported for compatibility with llvm.
+    targ_defvec=bpf_elf64_be_vec
+    targ_selvecs=bpf_elf64_le_vec
+    targ_archs="bfd_bpf_arch"
+    targ_underscore=yes
+    ;;
+
   epiphany-*-*)
     targ_defvec=epiphany_elf32_vec
     targ_underscore=yes
diff --git a/bfd/configure b/bfd/configure
index dae6e1f..22f10f3 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -793,6 +793,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -889,6 +890,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1141,6 +1143,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1278,7 +1289,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1431,6 +1442,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -11728,7 +11740,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11731 "configure"
+#line 11743 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11834,7 +11846,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11837 "configure"
+#line 11849 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12223,7 +12235,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -12269,7 +12281,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -12293,7 +12305,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -12338,7 +12350,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -12362,7 +12374,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -14706,6 +14718,8 @@ do
     elf32_le_vec)		 tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     elf64_be_vec)		 tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     elf64_le_vec)		 tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+    bpf_elf64_le_vec)		 tb="$tb elf64-bpf.lo elf64.lo $elf"; target_size=64 ;;
+    bpf_elf64_be_vec)            tb="$tb elf64-bpf.lo elf64.lo $elf"; target_size=64 ;;
     epiphany_elf32_vec)		 tb="$tb elf32-epiphany.lo elf32.lo $elf" ;;
     fr30_elf32_vec)		 tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
     frv_elf32_vec)		 tb="$tb elf32-frv.lo elf32.lo $elf" ;;
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 5942a74..f304a1b 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -474,6 +474,8 @@ do
     elf32_le_vec)		 tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     elf64_be_vec)		 tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     elf64_le_vec)		 tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+    bpf_elf64_le_vec)		 tb="$tb elf64-bpf.lo elf64.lo $elf"; target_size=64 ;;
+    bpf_elf64_be_vec)            tb="$tb elf64-bpf.lo elf64.lo $elf"; target_size=64 ;;
     epiphany_elf32_vec)		 tb="$tb elf32-epiphany.lo elf32.lo $elf" ;;
     fr30_elf32_vec)		 tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
     frv_elf32_vec)		 tb="$tb elf32-frv.lo elf32.lo $elf" ;;
diff --git a/bfd/cpu-bpf.c b/bfd/cpu-bpf.c
new file mode 100644
index 0000000..0c25094
--- /dev/null
+++ b/bfd/cpu-bpf.c
@@ -0,0 +1,58 @@
+/* BFD support for the BPF processor.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   Contributed by Oracle Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_bpf_be_arch =
+{
+  64,				/* Bits per word */
+  64,				/* Bits per address.  */
+  8,				/* Bits per byte.  */
+  bfd_arch_bpf,			/* Architecture.  */
+  bfd_mach_bpf_be,		/* Machine.  */
+  "bpf",			/* Architecture name.  */
+  "bpf:be",			/* Machine name.  */
+  1,				/* 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.  */
+};
+
+const bfd_arch_info_type bfd_bpf_arch =
+{
+  64,				/* Bits per word */
+  64,				/* Bits per address.  */
+  8,				/* Bits per byte.  */
+  bfd_arch_bpf,			/* Architecture.  */
+  bfd_mach_bpf_le,		/* Machine.  */
+  "bpf",			/* Architecture name.  */
+  "bpf:le",			/* Machine name.  */
+  1,				/* Section align power.  */
+  TRUE,				/* The default ?  */
+  bfd_default_compatible,	/* Architecture comparison fn.  */
+  bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
+  &bfd_bpf_be_arch		/* Next in list.  */
+};
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index 0ccbb99..64f1030 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -375,6 +375,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/bfd/elf64-bpf.c b/bfd/elf64-bpf.c
new file mode 100644
index 0000000..20a738b
--- /dev/null
+++ b/bfd/elf64-bpf.c
@@ -0,0 +1,295 @@
+/* Linux bpf specific support for 64-bit ELF
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   Contributed by Oracle Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/bpf.h"
+#include "libiberty.h"
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value.  */
+#define MINUS_ONE (~ (bfd_vma) 0)
+
+#define BASEADDR(SEC)	((SEC)->output_section->vma + (SEC)->output_offset)
+
+/* Relocation tables.  */
+static reloc_howto_type bpf_elf_howto_table [] =
+{
+  HOWTO(R_BPF_NONE,	   0,3, 0,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_NONE",	FALSE,0,0x00000000,TRUE),
+  HOWTO(R_BPF_64_64,	   0,4,64,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_BPF_64_64",	FALSE,0,MINUS_ONE, TRUE),
+  HOWTO(R_BPF_64_32,	   0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_BPF_64_32",	FALSE,0,0xffffffff,TRUE),
+};
+#undef AHOW
+
+/* Map BFD reloc types to bpf ELF reloc types.  */
+
+static reloc_howto_type *
+bpf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+                        bfd_reloc_code_real_type code)
+{
+  /* Note that the bpf_elf_howto_table is indxed by the R_
+     constants.  Thus, the order that the howto records appear in the
+     table *must* match the order of the relocation types defined in
+     include/elf/bpf.h.  */
+
+  switch (code)
+    {
+    case BFD_RELOC_NONE:
+      return &bpf_elf_howto_table[ (int) R_BPF_NONE];
+
+    case BFD_RELOC_BPF_64_64:
+      return &bpf_elf_howto_table[ (int) R_BPF_64_64];
+    case BFD_RELOC_BPF_64_32:
+      return &bpf_elf_howto_table[ (int) R_BPF_64_32];
+
+    default:
+      /* Pacify gcc -Wall.  */
+      return NULL;
+    }
+  return NULL;
+}
+
+/* Map BFD reloc names to bpf ELF reloc names.  */
+
+static reloc_howto_type *
+bpf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0; i < ARRAY_SIZE (bpf_elf_howto_table); i++)
+    if (bpf_elf_howto_table[i].name != NULL
+	&& strcasecmp (bpf_elf_howto_table[i].name, r_name) == 0)
+      return &bpf_elf_howto_table[i];
+
+  return NULL;
+}
+
+/* Set the howto pointer for a bpf reloc.  */
+
+static bfd_boolean
+bpf_info_to_howto (bfd *abfd, arelent *bfd_reloc,
+                    Elf_Internal_Rela *elf_reloc)
+{
+  unsigned int r_type;
+
+  r_type = ELF64_R_TYPE (elf_reloc->r_info);
+  if (r_type >= (unsigned int) R_BPF_max)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                          abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  bfd_reloc->howto = &bpf_elf_howto_table [r_type];
+  return TRUE;
+}
+
+/* Relocate an bpf ELF section.
+
+   The RELOCATE_SECTION function is called by the new ELF backend linker
+   to handle the relocations for a section.
+
+   The relocs are always passed as Rela structures; if the section
+   actually uses Rel structures, the r_addend field will always be
+   zero.
+
+   This function is responsible for adjusting the section contents as
+   necessary, and (if using Rela relocs and generating a relocatable
+   output file) adjusting the reloc addend as necessary.
+
+   This function does not have to worry about setting the reloc
+   address or the reloc symbol index.
+
+   LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+   LOCAL_SECTIONS is an array giving the section in the input file
+   corresponding to the st_shndx field of each local symbol.
+
+   The global hash table entry for the global symbols can be found
+   via elf_sym_hashes (input_bfd).
+
+   When generating relocatable output, this function must handle
+   STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
+   going to be the section symbol corresponding to the output
+   section, which means that the addend must be adjusted
+   accordingly.  */
+
+static bfd_boolean
+bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+                           struct bfd_link_info *info,
+                           bfd *input_bfd,
+                           asection *input_section,
+                           bfd_byte *contents,
+                           Elf_Internal_Rela *relocs,
+                           Elf_Internal_Sym *local_syms,
+                           asection **local_sections)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  Elf_Internal_Rela *rel;
+  Elf_Internal_Rela *relend;
+
+  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (input_bfd);
+  relend     = relocs + input_section->reloc_count;
+
+  for (rel = relocs; rel < relend; rel ++)
+    {
+      reloc_howto_type *	   howto;
+      unsigned long		   r_symndx;
+      Elf_Internal_Sym *	   sym;
+      asection *		   sec;
+      struct elf_link_hash_entry * h;
+      bfd_vma			   relocation;
+      bfd_reloc_status_type	   r;
+      const char *		   name = NULL;
+      int			   r_type ATTRIBUTE_UNUSED;
+
+      r_type = ELF64_R_TYPE (rel->r_info);
+      r_symndx = ELF64_R_SYM (rel->r_info);
+      howto  = bpf_elf_howto_table + ELF64_R_TYPE (rel->r_info);
+      h      = NULL;
+      sym    = NULL;
+      sec    = NULL;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  sym = local_syms + r_symndx;
+	  sec = local_sections [r_symndx];
+	  relocation = BASEADDR (sec) + sym->st_value;
+
+	  name = bfd_elf_string_from_elf_section
+	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
+	  name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+	}
+      else
+	{
+	  bfd_boolean warned ATTRIBUTE_UNUSED;
+	  bfd_boolean unresolved_reloc ATTRIBUTE_UNUSED;
+	  bfd_boolean ignored ATTRIBUTE_UNUSED;
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes,
+				   h, sec, relocation,
+				   unresolved_reloc, warned, ignored);
+
+	  name = h->root.root.string;
+	}
+
+      if (sec != NULL && discarded_section (sec))
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, 1, relend, howto, 0, contents);
+
+      if (bfd_link_relocatable (info))
+	continue;
+
+      /* Relocate.  */
+      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+                                    contents, rel->r_offset,
+                                    relocation, rel->r_addend);
+
+      if (r != bfd_reloc_ok)
+	{
+	  const char * msg = NULL;
+
+	  switch (r)
+	    {
+	    case bfd_reloc_overflow:
+	      (*info->callbacks->reloc_overflow)
+		(info, (h ? &h->root : NULL), name, howto->name,
+		 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
+	      break;
+
+	    case bfd_reloc_undefined:
+	      (*info->callbacks->undefined_symbol)
+		(info, name, input_bfd, input_section, rel->r_offset, TRUE);
+	      break;
+
+	    case bfd_reloc_outofrange:
+	      msg = _("internal error: out of range error");
+	      break;
+
+	    default:
+	      msg = _("internal error: unknown error");
+	      break;
+	    }
+
+	  if (msg)
+	    (*info->callbacks->warning) (info, msg, name, input_bfd,
+					 input_section, rel->r_offset);
+	}
+    }
+
+  return TRUE;
+}
+
+/* Set the right machine number, which depends on the endianness of
+   the ELF file.  */
+
+static bfd_boolean
+bpf_elf_object_p (bfd *abfd)
+{
+  /* The machine number depends on the endianness of the ELF file.  */
+  switch (elf_elfheader (abfd)->e_ident[EI_DATA])
+    {
+    default:
+    case ELFDATA2LSB:
+      (void) bfd_default_set_arch_mach (abfd, bfd_arch_bpf, bfd_mach_bpf_le); break;
+    case ELFDATA2MSB:
+      (void) bfd_default_set_arch_mach (abfd, bfd_arch_bpf, bfd_mach_bpf_be); break;
+    }
+
+  return TRUE;
+}
+
+/* The macros below configure the architecture.  */
+
+#define TARGET_LITTLE_SYM 	bpf_elf64_le_vec
+#define TARGET_LITTLE_NAME 	"elf64-bpfle"
+
+#define TARGET_BIG_SYM		bpf_elf64_be_vec
+#define TARGET_BIG_NAME		"elf64-bpfbe"
+
+#define ELF_ARCH bfd_arch_bpf
+#define ELF_MACHINE_CODE EM_BPF
+
+#define ELF_MAXPAGESIZE 0x8000 /* XXX: No pages on the bpf  */
+
+#define elf_info_to_howto_rel			bpf_info_to_howto
+#define elf_info_to_howto			bpf_info_to_howto
+
+#define elf_backend_may_use_rel_p		1
+#define elf_backend_may_use_rela_p		0
+#define elf_backend_default_use_rela_p		0
+
+#define elf_backend_can_gc_sections		1
+#define elf_backend_relocate_section		bpf_elf_relocate_section
+
+#define elf_symbol_leading_char			'_'
+#define bfd_elf64_bfd_reloc_type_lookup		bpf_reloc_type_lookup
+#define bfd_elf64_bfd_reloc_name_lookup		bpf_reloc_name_lookup
+
+#define elf_backend_object_p			bpf_elf_object_p
+
+#include "elf64-target.h"
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 1189e63..e0723e1 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -3231,6 +3231,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD",
   "BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD",
   "BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD",
+  "BFD_RELOC_BPF_64_64",
+  "BFD_RELOC_BPF_64_32",
   "BFD_RELOC_EPIPHANY_SIMM8",
   "BFD_RELOC_EPIPHANY_SIMM24",
   "BFD_RELOC_EPIPHANY_HIGH",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 1686780..e2729a5 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -7851,6 +7851,13 @@ ENUMDOC
   Tilera TILE-Gx Relocations.
 
 ENUM
+  BFD_RELOC_BPF_64_64
+ENUMX
+  BFD_RELOC_BPF_64_32
+ENUMDOC
+  Linux eBPF relocations.
+
+ENUM
   BFD_RELOC_EPIPHANY_SIMM8
 ENUMDOC
   Adapteva EPIPHANY - 8 bit signed pc-relative displacement
diff --git a/bfd/targets.c b/bfd/targets.c
index dc4bef1..dcbc092 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -639,6 +639,8 @@ extern const bfd_target elf32_be_vec;
 extern const bfd_target elf32_le_vec;
 extern const bfd_target elf64_be_vec;
 extern const bfd_target elf64_le_vec;
+extern const bfd_target bpf_elf64_le_vec;
+extern const bfd_target bpf_elf64_be_vec;
 extern const bfd_target epiphany_elf32_vec;
 extern const bfd_target fr30_elf32_vec;
 extern const bfd_target frv_elf32_vec;
@@ -981,7 +983,7 @@ static const bfd_target * const _bfd_target_vector[] =
 	&elf64_be_vec,
 	&elf64_le_vec,
 #endif
-
+        
 	&epiphany_elf32_vec,
 
 	&fr30_elf32_vec,
@@ -1021,6 +1023,11 @@ static const bfd_target * const _bfd_target_vector[] =
 	&iamcu_elf32_vec,
 
 #ifdef BFD64
+	&bpf_elf64_be_vec,
+        &bpf_elf64_le_vec,
+#endif
+
+#ifdef BFD64
 #if 0
 	&ia64_elf32_be_vec,
 #endif
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 0d980b7..5552e19 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2018-11-28  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* readelf.c: Include elf/bpf.h.
+	(guess_is_rela): EM_BPF uses REL relocations.
+	(dump_relocations): Handle EM_BPF.
+	(get_machine_name): Likewise.
+	(is_32bit_abs_reloc): Likewise.
+
 2018-11-13  Francois H. Theron <francois.theron@netronome.com>
 
 	* testsuite/binutils-all/nfp/test1.d: Test for swapped operand crc[].
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 3974400..07157b4 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -102,6 +102,7 @@
 #include "elf/d10v.h"
 #include "elf/d30v.h"
 #include "elf/dlx.h"
+#include "elf/bpf.h"
 #include "elf/epiphany.h"
 #include "elf/fr30.h"
 #include "elf/frv.h"
@@ -780,6 +781,7 @@ guess_is_rela (unsigned int e_machine)
     case EM_SCORE:
     case EM_XGATE:
     case EM_NFP:
+    case EM_BPF:
       return FALSE;
 
       /* Targets that use RELA relocations.  */
@@ -1481,6 +1483,10 @@ dump_relocations (Filedata *          filedata,
 	  rtype = elf_visium_reloc_type (type);
 	  break;
 
+        case EM_BPF:
+          rtype = elf_bpf_reloc_type (type);
+          break;
+
 	case EM_ADAPTEVA_EPIPHANY:
 	  rtype = elf_epiphany_reloc_type (type);
 	  break;
@@ -12322,6 +12328,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
     case EM_AARCH64:
       return (reloc_type == 258
 	      || reloc_type == 1); /* R_AARCH64_ABS32 || R_AARCH64_P32_ABS32 */
+    case EM_BPF:
+      return reloc_type == 2; /* R_BPF_64_32 XXX is this correct?*/
     case EM_ADAPTEVA_EPIPHANY:
       return reloc_type == 3;
     case EM_ALPHA:
diff --git a/config.sub b/config.sub
index c95acc6..c9dd94b 100755
--- a/config.sub
+++ b/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2018-07-03'
+timestamp='2019-01-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -580,7 +580,7 @@ case $basic_machine in
 	| bfin \
 	| c4x | c8051 | clipper | csky \
 	| d10v | d30v | dlx | dsp16xx \
-	| e2k | epiphany \
+	| e2k | epiphany | bpfel | bpfeb \
 	| fido | fr30 | frv | ft32 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| hexagon \
diff --git a/cpu/ChangeLog b/cpu/ChangeLog
index df03e60..1eb5dd0 100644
--- a/cpu/ChangeLog
+++ b/cpu/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-26  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* bpf.cpu: New file.
+	* bpf.opc: Likewise.
+
 2018-10-05  Richard Henderson  <rth@twiddle.net>
 	    Stafford Horne  <shorne@gmail.com>
 
diff --git a/cpu/bpf.cpu b/cpu/bpf.cpu
new file mode 100644
index 0000000..9732d61
--- /dev/null
+++ b/cpu/bpf.cpu
@@ -0,0 +1,517 @@
+;; Linux BPF CPU description  -*- Scheme -*-
+;; Copyright 2018 Free Software Foundation, Inc.
+;;
+;; Contributed by Oracle Inc.
+;;
+;; This file is part of the GNU Binutils and of GDB.
+;;
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 3 of the
+;; License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+(include "simplify.inc")
+
+;;;; Hardware Hierarchy
+
+;;
+;;                       bpf                 architecture
+;;                        |
+;;                      bpfbf                cpu-family
+;;                    /        \
+;;                bpf:be      bpf:le         machine
+;;                   |           |
+;;             bpf-be-def   bpf-le-def       model
+
+(define-arch
+  (name bpf)
+  (comment "Linux kernel BPF")
+  (insn-lsb0? #t)
+  (machs bpf:le bpf:be)
+  (isas ebpf-isa))
+
+(define-isa
+  (name ebpf-isa)
+  (comment "The eBPF instruction set")
+  ;; Default length to record in ifields.  This is used in
+  ;; calculations involving bit numbers.
+  (default-insn-word-bitsize 32)
+  ;; Length of an unknown instruction.  Used by disassembly and by the
+  ;; simulator's invalid insn handler.
+  (default-insn-bitsize 64) ;; XXX: there is an error when the last
+                            ;; instruction is unknown: it tries to
+                            ;; read 64-bit after the unkonwn 32-bit
+                            ;; base word.  CGEN bug.
+  ;; Number of bits of insn that can be initially fetched.
+  (base-insn-bitsize 64))
+
+(define-cpu
+  (name bpfbf) ; bf stands for "base family".
+  (comment "Linux kernel eBPF virtual CPU, base family")
+  ;; XXX: how to handle endianness in the disassembler??
+  (endian either)
+  (word-bitsize 64))
+
+(define-mach
+  (name bpf:le)
+  (comment "Linux eBPF, little-endian")
+  (cpu bpfbf)
+  (isas ebpf-isa))
+
+(define-mach
+  (name bpf:be)
+  (comment "Linux eBPF, big-endian")
+  (cpu bpfbf)
+  (isas ebpf-isa))
+
+(define-model
+  (name bpf-le-def)
+  (comment "Linux eBPF (little-endian) default model")
+  (mach bpf:le)
+  (unit u-exec "execution unit" ()
+    1 ; issue
+    1 ; done
+    () ; state
+    () ; inputs
+    () ; outputs
+    () ; profile action (default)
+    ))
+
+(define-model
+  (name bpf-be-def)
+  (comment "Linux eBPF (big-endian) default model")
+  (mach bpf:be)
+  (unit u-exec "execution unit" ()
+    1 ; issue
+    1 ; done
+    () ; state
+    () ; inputs
+    () ; outputs
+    () ; profile action (default)
+    ))
+
+;;;; Hardware Elements
+
+;; eBPF programs can access 10 general-purpose registers which are
+;; 64-bit.
+
+(define-hardware
+  (name h-gpr)
+  (comment "General Purpose Registers")
+  (attrs (ISA ebpf-isa) (MACH bpf:le bpf:be))
+  (type register DI (16))
+  (indices keyword "%" ;; XXX If we don't use register prefixes, then
+                       ;; there can be conflicts with symbols, which
+                       ;; would require to reorder the insns and also
+                       ;; could lead to confusing situations.
+           (;; ABI names.  Take priority when disassembling.
+            (a 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6)
+            (r7 7) (r8 8) (r9 9) (fp 10)
+            ;; Additional names recognized when assembling.
+            (r0 0) (r10 10))))
+
+;; The program counter.  CGEN requires it, even if it is not visible
+;; to eBPF programs.
+
+(dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
+
+;;;; The ISA
+
+;; The encoding of 64-bit eBPF instructions is:
+;;
+;;    msb                                                        lsb
+;;    +------------------------+----------------+----+----+--------+
+;;    |imm32|imm64-a           |offset16        |src |dst |opcode  |
+;;    +------------------------+----------------+----+----+--------+
+;;    63                        31               15   11   7      0
+;;
+;; The encoding of the 128-bit eBPF instruction is:
+;;
+;;    msb                                                        lsb
+;;    +------------------------+----------------+----+----+--------+
+;;    |imm64                   |offset16        |src |dst |opcode  |
+;;    +------------------------+----------------+----+----+--------+
+;;    63                        31               15   11   7      0
+;;    +------------------------+-----------------------------------+
+;;    |imm64                   |                                   |
+;;    +------------------------+-----------------------------------+
+
+;;; Fields
+
+(define-pmacro (dwf x-name x-comment x-attrs
+                    x-word-offset x-word-length x-start x-length
+                    x-mode)
+  "Define a field including its containing word."
+  (define-ifield
+    (name x-name)
+    (comment x-comment)
+    (.splice attrs (.unsplice x-attrs))
+    (word-offset x-word-offset)
+    (word-length x-word-length)
+    (start x-start)
+    (length x-length)
+    (mode x-mode)))
+
+;; XXX endianness impacts the numbering of insn words?
+(dwf f-offset16 "eBPF offset field" ((ISA ebpf-isa)) 0 32 31 16 INT)
+(dwf f-src "eBPF source register field" ((ISA ebpf-isa)) 0 32 15 4 UINT)
+(dwf f-dst "eBPF source register field" ((ISA ebpf-isa)) 0 32 11 4 UINT)
+;;(dwf f-opcode "eBPF instruction opcode field" ((ISA ebpf-isa)) 0 32 7 8 UINT)
+(dwf f-op-code "eBPF opcode code" ((ISA ebpf-isa)) 0 32 7 4 UINT)
+(dwf f-op-src "eBPF opcode source" ((ISA ebpf-isa)) 0 32 3 1 UINT)
+(dwf f-op-class "eBPF opcode instruction class" ((ISA ebpf-isa)) 0 32 2 3 UINT)
+(dwf f-op-mode "eBPF opcode mode" ((ISA ebpf-isa)) 0 32 7 3 UINT)
+(dwf f-op-size "eBPF opcode size" ((ISA ebpf-isa)) 0 32 4 2 UINT)
+
+;; Note that, due to a CGEN limitation, the only safe usage of f-imm32
+;; fields in instruction formats is when it is initialized to 0.  This
+;; is because the resulting mask is applied to the first word (32-bit)
+;; of the instruction, regardless word-offset.
+;;
+;; It is ok to use $imm32 in assembler syntax though.
+
+(dwf f-imm32 "eBPF 32-bit immediate field" ((ISA ebpf-isa)) 32 32 31 32 INT)
+
+;; CGEN doesn't support instruction words bigger than 32-bit.  Also,
+;; in practice fields are required to fit in a single containing
+;; instruction word.  Therefore the eBPF 64-bit immediate fields shall
+;; be defined using a multi-ifield, as it is done below.
+;;
+;; Note that despite the f-imm64-c field should be part of the
+;; multi-ifield, even if it is not used in any instruction operand.
+
+(dwf f-imm64-a "eBPF 64-bit immediate a" ((ISA ebpf-isa)) 32 32 31 32 UINT)
+(dwf f-imm64-b "eBPF 64-bit immediate b" ((ISA ebpf-isa)) 64 32 31 32 UINT)
+(dwf f-imm64-c "eBPF 64-bit immediate c" ((ISA ebpf-isa)) 96 32 31 32 UINT)
+
+(define-multi-ifield
+  (name f-imm64)
+  (comment "eBPF 64-bit immediate field")
+  (attrs (ISA ebpf-isa))
+  (mode DI)
+  (subfields f-imm64-a f-imm64-b f-imm64-c)
+  ;; XXX: handle endianness in `insert' and 'extract'!!
+  ;; XXX: also negative numbers are NOT diplayed as such in the disasssembler.
+  (insert (sequence ()
+                    (set (ifield f-imm64-c) (const 0))
+                    (set (ifield f-imm64-b) (srl (ifield f-imm64) (const 32)))
+                    (set (ifield f-imm64-a) (and (ifield f-imm64) (const #xffffffff)))))
+  (extract (sequence ()
+                     (set (ifield f-imm64) (or (sll (ifield f-imm64-b) (const 16))
+                                               (ifield f-imm64-a))))))
+
+;;; Operands
+
+(dnop dst "destination register" ((ISA ebpf-isa)) h-gpr f-dst)
+(dnop src "source register" ((ISA ebpf-isa)) h-gpr f-src)
+(dnop imm32 "32-bit immediate" ((ISA ebpf-isa)) h-sint f-imm32)
+(dnop imm64 "64-bit immediate" ((ISA ebpf-isa)) h-sint f-imm64)
+(dnop offset16 "16-bit offset" ((ISA ebpf-isa)) h-sint f-offset16)
+
+;;; Instruction classes, sources and codes
+
+(define-normal-insn-enum insn-op-class "eBPF instruction class"
+  ((ISA ebpf-isa)) OP_CLASS_ f-op-class
+  ((LD    #b000) (LDX   #b001) (ST    #b010) (STX   #b011)
+   (ALU   #b100) (JMP   #b101) (ALU64 #b111)))
+
+(define-normal-insn-enum insn-op-src "eBPF instruction source"
+  ((ISA ebpf-isa)) OP_SRC_ f-op-src
+  ;; in eBPF: X => use `src' as source operand.
+  ;;          K => use `imm32' as ource operand.
+  ((K #b0) (X #b1)))
+
+(define-normal-insn-enum insn-op-bitsize "eBPF bit size for le/be"
+  ((ISA ebpf-isa)) OP_BITSIZE_ f-imm32
+  (("16" #x00000010) ("32" #x00000020) ("64" #x00000040)))
+
+(define-normal-insn-enum insn-op-code-alu "eBPF instruction codes"
+  ((ISA ebpf-isa)) OP_CODE_ f-op-code
+  (;; Codes for OP_CLASS_ALU and OP_CLASS_ALU64
+   (ADD #x0) (SUB #x1) (MUL #x2) (DIV #x3) (OR #x4) (AND #x5)
+   (LSH #x6) (RSH #x7) (NEG #x8) (MOD #x9) (XOR #xa) (MOV #xb)
+   (ARSH #xc) (END #xd)
+   ;; Codes for OP_CLASS_JMP
+   (JA #x0) (JEQ #x1) (JGT #x2) (JGE #x3) (JSET #x4)
+   (JNE #x5) (JSGT #x6) (JSGE #x7) (CALL #x8) (EXIT #x9)
+   (JLT #xa) (JLE #xb) (JSLT #xc) (JSLE #xd)))
+
+(define-normal-insn-enum insn-op-size "eBPF load/store instruction sizes"
+  ((ISA ebpf-isa)) OP_SIZE_ f-op-size
+  ((W  #b00)   ;; Word:        4 byte
+   (H  #b01)   ;; Half-word:   2 byte
+   (B  #b10)   ;; Byte:        1 byte
+   (DW #b11))) ;; Double-word: 8 byte
+
+(define-normal-insn-enum insn-op-mode "eBPF load/store instruction modes"
+  ((ISA ebpf-isa)) OP_MODE_ f-op-mode
+  ((IMM #b000) (ABS #b001) (IND #b010) (MEM #b011)
+   ;; #b100 and #b101 are used in classic BPF only, reserved in eBPF.
+   (XADD #b110)))
+
+;;; ALU instructions
+
+(define-pmacro (define-alu-insn-un x-basename x-suffix x-op-class x-op-code)
+  (dni (.sym x-basename x-suffix)
+       (.str x-basename x-suffix)
+       ((ISA ebpf-isa))
+       (.str x-basename x-suffix " $dst")
+       (+ (f-imm32 0) (f-offset16 0) (f-src 0) dst
+          x-op-class OP_SRC_X x-op-code) () ()))
+
+(define-pmacro (define-alu-insn-bin x-basename x-suffix x-op-class x-op-code)
+  (begin
+    (dni (.sym x-basename x-suffix "i")
+         (.str x-basename x-suffix " immediate")
+         ((ISA ebpf-isa))
+         (.str x-basename x-suffix " $dst,$imm32")
+         (+ imm32 (f-offset16 0) (f-src 0) dst
+            x-op-class OP_SRC_K x-op-code) () ())
+    (dni (.sym x-basename x-suffix "r")
+         (.str x-basename x-suffix " register")
+         ((ISA ebpf-isa))
+         (.str x-basename x-suffix " $dst,$src")
+         (+ (f-imm32 0) (f-offset16 0) src dst
+            x-op-class OP_SRC_X x-op-code) () ())))
+
+(define-pmacro (daiu x-basename x-op-code)
+  (begin
+    (define-alu-insn-un x-basename "" OP_CLASS_ALU64 x-op-code)
+    (define-alu-insn-un x-basename "32" OP_CLASS_ALU x-op-code)))
+
+(define-pmacro (daib x-basename x-op-code)
+  (begin
+    (define-alu-insn-bin x-basename "" OP_CLASS_ALU64 x-op-code)
+    (define-alu-insn-bin x-basename "32" OP_CLASS_ALU x-op-code)))
+
+(daib add OP_CODE_ADD)
+(daib sub OP_CODE_SUB)
+(daib mul OP_CODE_MUL)
+(daib div OP_CODE_DIV)
+(daib or  OP_CODE_OR)
+(daib and OP_CODE_AND)
+(daib lsh OP_CODE_LSH)
+(daib rsh OP_CODE_RSH)
+(daib mod OP_CODE_MOD)
+(daib xor OP_CODE_XOR)
+(daib mov OP_CODE_MOV)
+(daib arsh OP_CODE_ARSH)
+(daiu neg OP_CODE_NEG)
+
+;;; Endianness conversion instructions
+
+(define-pmacro (define-endian-insn x-prefix x-bitsize x-op-src)
+  (dni (.sym x-prefix x-bitsize)
+       (.str x-prefix x-bitsize " register")
+       ((ISA ebpf-isa))
+       (.str x-prefix x-bitsize " $dst")
+       (+  (f-imm32 16) (f-offset16 0) (f-src 0) dst ;;(.sym OP_BITSIZE_ x-bitsize)
+          OP_CLASS_ALU x-op-src OP_CODE_END) () ()))
+
+(define-pmacro (deni x-bitsize)
+  (begin
+    (define-endian-insn "le" x-bitsize OP_SRC_X)
+    (define-endian-insn "be" x-bitsize OP_SRC_K)))
+
+;;(deni 16)
+;;(deni 32)
+;;(deni 64)
+
+;;; Load/Store instructions
+
+(dni lddw "LDDW" ((ISA ebpf-isa)) "lddw $dst,$imm64"
+     (+ imm64 (f-offset16 0) (f-src 0) dst
+        OP_CLASS_LD OP_SIZE_DW OP_MODE_IMM) () ())
+
+(dni ldabsw "LDABSW" ((ISA ebpf-isa)) "ldabsw $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_W OP_MODE_ABS) () ())
+
+(dni ldabsh "LDABSH" ((ISA ebpf-isa)) "ldabsh $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_H OP_MODE_ABS) () ())
+
+(dni ldabsb "LDABSB" ((ISA ebpf-isa)) "ldabsb $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_B OP_MODE_ABS) () ())
+
+(dni ldabsdw "LDABSDW" ((ISA ebpf-isa)) "ldabsdw $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_DW OP_MODE_ABS) () ())
+
+(dni ldindw "LDINDW" ((ISA ebpf-isa)) "ldindw $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_W OP_MODE_IND) () ())
+
+(dni ldindh "LDINDH" ((ISA ebpf-isa)) "ldindh $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_H OP_MODE_IND) () ())
+
+(dni ldindb "LDINDB" ((ISA ebpf-isa)) "ldindb $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_B OP_MODE_IND) () ())
+
+(dni ldinddw "LDINDDW" ((ISA ebpf-isa)) "ldinddw $src,$dst,$imm32"
+     (+ imm32 (f-offset16 0) src dst
+        OP_CLASS_LD OP_SIZE_DW OP_MODE_IND) () ())
+
+(dni ldxw "LDXW" ((ISA ebpf-isa)) "ldxw $dst,[$src+$offset16]"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_LDX OP_SIZE_W OP_MODE_MEM) () ())
+
+(dni ldxh "LDXH" ((ISA ebpf-isa)) "ldxh $dst,[$src+$offset16]"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_LDX OP_SIZE_H OP_MODE_MEM) () ())
+
+(dni ldxb "LDXB" ((ISA ebpf-isa)) "ldxb $dst,[$src+$offset16]"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_LDX OP_SIZE_B OP_MODE_MEM) () ())
+
+(dni ldxdw "LDXDW" ((ISA ebpf-isa)) "ldxdw $dst,[$src+$offset16]"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_LDX OP_SIZE_DW OP_MODE_MEM) () ())
+
+(dni stw "STW" ((ISA ebpf-isa)) "stw [$dst+$offset16],$imm32"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_ST OP_SIZE_W OP_MODE_MEM) () ())
+
+(dni sth "STH" ((ISA ebpf-isa)) "sth [$dst+$offset16],$imm32"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_ST OP_SIZE_H OP_MODE_MEM) () ())
+
+(dni stb "STB" ((ISA ebpf-isa)) "stb [$dst+$offset16],$imm32"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_ST OP_SIZE_B OP_MODE_MEM) () ())
+
+(dni stdw "STDW" ((ISA ebpf-isa)) "stdw [$dst+$offset16],$imm32"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_ST OP_SIZE_DW OP_MODE_MEM) () ())
+
+(dni stxw "STXW" ((ISA ebpf-isa)) "stxw [$dst+$offset16],$src"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_STX OP_SIZE_W OP_MODE_MEM) () ())
+
+(dni stxh "STXH" ((ISA ebpf-isa)) "stxh [$dst+$offset16],$src"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_STX OP_SIZE_H OP_MODE_MEM) () ())
+
+(dni stxb "STXB" ((ISA ebpf-isa)) "stxb [$dst+$offset16],$src"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_STX OP_SIZE_B OP_MODE_MEM) () ())
+
+(dni stxdw "STXDW" ((ISA ebpf-isa)) "stxdw [$dst+$offset16],$src"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_STX OP_SIZE_DW OP_MODE_MEM) () ())
+
+;;; Jump instructions
+
+(dni ja "JA" ((ISA ebpf-isa)) "ja +$offset16"
+     (+ (f-imm32 0) offset16 (f-src 0) (f-dst 0)
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JA) () ())
+
+(dni jeqi "JEQI" ((ISA ebpf-isa)) "jeq $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JEQ) () ())
+
+(dni jeqr "JEQR" ((ISA ebpf-isa)) "jeq $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JEQ) () ())
+
+(dni jgti "JGTI" ((ISA ebpf-isa)) "jgt $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JGT) () ())
+
+(dni jgtr "JGTR" ((ISA ebpf-isa)) "jgt $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JGT) () ())
+
+(dni jgei "JGEI" ((ISA ebpf-isa)) "jge $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JGE) () ())
+
+(dni jger "JGER" ((ISA ebpf-isa)) "jge $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JGE) () ())
+
+(dni jlti "JLTI" ((ISA ebpf-isa)) "jlt $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JLT) () ())
+
+(dni jltr "JLTR" ((ISA ebpf-isa)) "jlt $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JLT) () ())
+
+(dni jlei "JLEI" ((ISA ebpf-isa)) "jle $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JLE) () ())
+
+(dni jler "JLER" ((ISA ebpf-isa)) "jle $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JLE) () ())
+
+(dni jseti "JSETI" ((ISA ebpf-isa)) "jset $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JSET) () ())
+
+(dni jsetr "JSETR" ((ISA ebpf-isa)) "jset $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JSET) () ())
+
+(dni jnei "JNEI" ((ISA ebpf-isa)) "jne $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JNE) () ())
+
+(dni jner "JNER" ((ISA ebpf-isa)) "jne $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JNE) () ())
+
+(dni jsgti "JSGTI" ((ISA ebpf-isa)) "jsgt $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JSGT) () ())
+
+(dni jsgtr "JSGTR" ((ISA ebpf-isa)) "jsgt $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JSGT) () ())
+
+(dni jsgei "JSGEI" ((ISA ebpf-isa)) "jsge $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JSGE) () ())
+
+(dni jsger "JSGER" ((ISA ebpf-isa)) "jsge $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JSGE) () ())
+
+(dni jslti "JSLTI" ((ISA ebpf-isa)) "jslt $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JSLT) () ())
+
+(dni jsltr "JSLTR" ((ISA ebpf-isa)) "jslt $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JSLT) () ())
+
+(dni jslei "JSLEI" ((ISA ebpf-isa)) "jsle $dst,$imm32,+$offset16"
+     (+ imm32 offset16 (f-src 0) dst
+        OP_CLASS_JMP OP_SRC_K OP_CODE_JSLE) () ())
+
+(dni jsler "JSLER" ((ISA ebpf-isa)) "jsle $dst,$src,+$offset16"
+     (+ (f-imm32 0) offset16 src dst
+        OP_CLASS_JMP OP_SRC_X OP_CODE_JSLE) () ())
+
+(dni call "CALL" ((ISA ebpf-isa)) "call $imm32"
+     (+ imm32 (f-offset16 0) (f-src 0) (f-dst 0)
+        OP_CLASS_JMP OP_SRC_K OP_CODE_CALL) () ())
+
+(dni "exit" "EXIT" ((ISA ebpf-isa)) "exit"
+     (+ (f-imm32 0) (f-offset16 0) (f-src 0) (f-dst 0)
+        OP_CLASS_JMP (f-op-src 0) OP_CODE_EXIT) () ())
+
diff --git a/cpu/bpf.opc b/cpu/bpf.opc
new file mode 100644
index 0000000..b4c1342
--- /dev/null
+++ b/cpu/bpf.opc
@@ -0,0 +1,108 @@
+/* EBPF opcode support.  -*- c -*-
+
+   Copyright 2018 Free Software Foundation, Inc.
+
+   Contributed by Oracle, Inc.
+
+   This file is part of the GNU Binutils and of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+/*
+   Each section is delimited with start and end markers.
+
+   <arch>-opc.h additions use: "-- opc.h"
+   <arch>-opc.c additions use: "-- opc.c"
+   <arch>-asm.c additions use: "-- asm.c"
+   <arch>-dis.c additions use: "-- dis.c"
+   <arch>-ibd.h additions use: "-- ibd.h".  */
+
+/* -- opc.h */
+
+#undef CGEN_DIS_HASH_SIZE
+#define CGEN_DIS_HASH_SIZE 1
+
+#undef CGEN_DIS_HASH
+#define CGEN_DIS_HASH(buffer, value) 0
+
+/* Allows reason codes to be output when assembler errors occur.  */
+#define CGEN_VERBOSE_ASSEMBLER_ERRORS
+
+
+
+/* -- opc.c */
+
+/* -- asm.c */
+
+/* -- dis.c */
+
+/* We need to customize the disassembler a bit:
+   - Use 8 bytes per line by default.
+*/
+
+#define CGEN_PRINT_INSN ebpf_print_insn
+
+static int
+ebpf_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
+{
+  bfd_byte buf[CGEN_MAX_INSN_SIZE];
+  int buflen;
+  int status;
+
+  info->bytes_per_chunk = 1;
+  info->bytes_per_line = 8;
+
+  /* Attempt to read the base part of the insn.  */
+  buflen = cd->base_insn_bitsize / 8;
+  status = (*info->read_memory_func) (pc, buf, buflen, info);
+
+  /* Try again with the minimum part, if min < base.  */
+  if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
+    {
+      buflen = cd->min_insn_bitsize / 8;
+      status = (*info->read_memory_func) (pc, buf, buflen, info);
+    }
+
+  if (status != 0)
+    {
+      (*info->memory_error_func) (status, pc, info);
+      return -1;
+    }
+
+  return print_insn (cd, pc, info, buf, buflen);
+}
+
+#if 0
+/* Print signed immediate operands with '#' prefixes.  */
+
+static void
+print_signed_with_hash_prefix (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
+                               void *dis_info,
+                               long value,
+                               unsigned int attrs ATTRIBUTE_UNUSED,
+                               bfd_vma pc ATTRIBUTE_UNUSED,
+                               int length ATTRIBUTE_UNUSED)
+{
+  disassemble_info *info = (disassemble_info *) dis_info;
+
+  (*info->fprintf_func) (info->stream, "#");
+  (*info->fprintf_func) (info->stream, "%ld", value);
+}
+#endif
+
+
+/* -- */
+
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 977d4bc..d4ce722 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,21 @@
+2018-11-29  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* testsuite/gas/bpf/bpf.exp: New file.
+	* testsuite/gas/bpf/lddw.s: Likewise.
+	* testsuite/gas/bpf/lddw.d: Likewise.
+	* testsuite/gas/bpf/alu64.s: Likewise.
+	* testsuite/gas/bpf/alu.s: Likewise.
+	* testsuite/gas/bpf/alu.d: Likewise.
+	* testsuite/gas/bpf/mem.d: Likewise.
+
+2018-11-28  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* configure.ac (DEFAULT_FLAG_COMPRESS_DEBUG): Canonicalize
+	cgen_cpu_prefix for BPF.
+	* configure.tgt: Support BPF targets.
+	* config/tc-bpf.h: New file.
+	* config/tc-bpf.c: Likewise.
+
 2018-11-13  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
 	* config/tc-arm.c (arm_archs): Reindent.
diff --git a/gas/Makefile.in b/gas/Makefile.in
index a558df7..95cc1c8 100644
--- a/gas/Makefile.in
+++ b/gas/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -402,6 +402,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/gas/aclocal.m4 b/gas/aclocal.m4
index a9f9f5c..19e8acb 100644
--- a/gas/aclocal.m4
+++ b/gas/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2017 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
 [am__api_version='1.15'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.15.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.15.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2017 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -408,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -605,7 +605,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -626,7 +626,7 @@ if test x"${install_sh+set}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 1998-2017 Free Software Foundation, Inc.
+# Copyright (C) 1998-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -647,7 +647,7 @@ fi])
 # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
 # From Jim Meyering
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -682,7 +682,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -732,7 +732,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2017 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -771,7 +771,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -800,7 +800,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -847,7 +847,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -866,7 +866,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -947,7 +947,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2017 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1007,7 +1007,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1035,7 +1035,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2017 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1054,7 +1054,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2017 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c
new file mode 100644
index 0000000..d9a7ee4
--- /dev/null
+++ b/gas/config/tc-bpf.c
@@ -0,0 +1,274 @@
+/* tc-bpf.c -- Assembler for the Linux eBPF.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   Contributed by Oracle, Inc.
+
+   This file is part of GAS, the GNU Assembler.
+
+   GAS is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GAS is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GAS; see the file COPYING.  If not, write to
+   the Free Software Foundation, 51 Franklin Street - Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include "as.h"
+#include "subsegs.h"
+#include "symcat.h"
+#include "opcodes/bpf-desc.h"
+#include "opcodes/bpf-opc.h"
+#include "cgen.h"
+#include "elf/common.h"
+#include "elf/bpf.h"
+#include "dwarf2dbg.h"
+
+const char comment_chars[]        = ";";
+const char line_comment_chars[] = "#";
+const char line_separator_chars[] = "`";
+const char EXP_CHARS[]            = "eE";
+const char FLT_CHARS[]            = "fFdD";
+
+/* The target specific pseudo-ops which we support.  */
+const pseudo_typeS md_pseudo_table[] =
+{
+    { NULL,         NULL,             0 }
+};
+
+
+
+/* Command-line options processing.  */
+
+enum options
+{
+  OPTION_LITTLE_ENDIAN = OPTION_MD_BASE,
+  OPTION_BIG_ENDIAN
+};
+
+struct option md_longopts[] =
+{
+  { "LE", no_argument, NULL, OPTION_LITTLE_ENDIAN },
+  { "BE", no_argument, NULL, OPTION_BIG_ENDIAN },
+  { NULL,          no_argument, NULL, 0 },
+};
+
+size_t md_longopts_size = sizeof (md_longopts);
+
+const char * md_shortopts = "";
+
+extern int target_big_endian; /* Little-endian by default.  */
+
+int
+md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
+{
+  switch (c)
+    {
+    case OPTION_BIG_ENDIAN:
+      target_big_endian = 1;
+      break;
+    case OPTION_LITTLE_ENDIAN:  /* This is the default.  */
+      break;
+    default:
+      return 0;
+    }
+
+  return 1;
+}
+
+void
+md_show_usage (FILE * stream)
+{
+  fprintf (stream, _("\nBPF options:\n"));
+  fprintf (stream, _("\
+  --LE			generate code for a little endian machine (default)\n\
+  --BE			generate code for a big endian machine\n"));
+}
+
+
+void
+md_begin (void)
+{
+  /* Initialize the `cgen' interface.  */
+
+  /* Set the machine number and endian.  */
+  gas_cgen_cpu_desc = bpf_cgen_cpu_open (CGEN_CPU_OPEN_ENDIAN,
+                                          target_big_endian ?
+                                          CGEN_ENDIAN_BIG : CGEN_ENDIAN_LITTLE,
+                                          CGEN_CPU_OPEN_END);
+  bpf_cgen_init_asm (gas_cgen_cpu_desc);
+
+  /* This is a callback from cgen to gas to parse operands.  */
+  cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand);
+
+  /* Set the machine type.  */
+  bfd_default_set_arch_mach (stdoutput, bfd_arch_bpf,
+                             target_big_endian ? bfd_mach_bpf_be : bfd_mach_bpf_le);
+}
+
+valueT
+md_section_align (segT segment, valueT size)
+{
+  int align = bfd_get_section_alignment (stdoutput, segment);
+
+  return ((size + (1 << align) - 1) & -(1 << align));
+}
+
+
+/* Functions concerning relocs.  */
+
+long
+md_pcrel_from (fixS *fixP ATTRIBUTE_UNUSED)
+{
+  abort ();
+}
+
+/* Write a value out to the object file, using the appropriate endianness.  */
+
+void
+md_number_to_chars (char * buf, valueT val, int n)
+{
+  if (target_big_endian)
+    number_to_chars_bigendian (buf, val, n);
+  else
+    number_to_chars_littleendian (buf, val, n);
+}
+
+arelent *
+tc_gen_reloc (asection *sec, fixS *fix)
+{
+  return gas_cgen_tc_gen_reloc (sec, fix);
+}
+
+/* Return the bfd reloc type for OPERAND of INSN at fixup FIXP.  This
+   is called when the operand is an expression that couldn't be fully
+   resolved.  Returns BFD_RELOC_NONE if no reloc type can be found.
+   *FIXP may be modified if desired.  */
+
+bfd_reloc_code_real_type
+md_cgen_lookup_reloc (const CGEN_INSN *insn ATTRIBUTE_UNUSED,
+		      const CGEN_OPERAND *operand,
+		      fixS *fixP ATTRIBUTE_UNUSED)
+{
+  switch (operand->type)
+    {
+    case BPF_OPERAND_IMM64:
+      return BFD_RELOC_BPF_64_64;
+      /*    case EPIPHANY_OPERAND_IMM16:
+      if (0 == strcmp ("movt", CGEN_INSN_MNEMONIC (insn)))
+	return BFD_RELOC_EPIPHANY_HIGH;
+      else if (0 == strcmp ("mov", CGEN_INSN_MNEMONIC (insn)))
+	return BFD_RELOC_EPIPHANY_LOW;
+      else
+      as_bad ("unknown imm16 operand");*/
+    default:
+      break;
+    }
+  return BFD_RELOC_NONE;
+}
+
+/* *FRAGP has been relaxed to its final size, and now needs to have
+   the bytes inside it modified to conform to the new size.
+
+   Called after relaxation is finished.
+   fragP->fr_type == rs_machine_dependent.
+   fragP->fr_subtype is the subtype of what the address relaxed to.  */
+
+void
+md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED,
+		 segT sec ATTRIBUTE_UNUSED,
+		 fragS *fragP ATTRIBUTE_UNUSED)
+{
+  as_fatal (_("convert_frag called"));
+}
+
+int
+md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
+                               segT segment ATTRIBUTE_UNUSED)
+{
+  as_fatal (_("estimate_size_before_relax called"));
+  return 0;
+}
+
+
+/* Parse %-operands.  XXX: writeme  */
+
+int
+bpf_cgen_parse_fix_exp (int opinfo, expressionS *exp ATTRIBUTE_UNUSED)
+{
+  switch (opinfo)
+    {
+    case BFD_RELOC_BPF_64_64:
+    case BFD_RELOC_BPF_64_32:
+      break;
+    default:
+      return opinfo;
+    }
+
+  /* XXX: writeme.  */
+  return opinfo;
+}
+
+void
+md_apply_fix (fixS *fixP, valueT *valP, segT seg)
+{
+  return gas_cgen_md_apply_fix (fixP, valP, seg);
+}
+
+void
+md_assemble (char *str)
+{
+  const CGEN_INSN *insn;
+  char *errmsg;
+  CGEN_FIELDS fields;
+
+#if CGEN_INT_INSN_P
+  CGEN_INSN_INT buffer[CGEN_MAX_INSN_SIZE / sizeof (CGEN_INT_INSN_P)];
+#else
+  unsigned char buffer[CGEN_MAX_INSN_SIZE];
+#endif
+
+  gas_cgen_init_parse ();
+  insn = bpf_cgen_assemble_insn (gas_cgen_cpu_desc, str, &fields,
+                                  buffer, &errmsg);
+
+  if (insn == NULL)
+    {
+      as_bad ("%s", errmsg);
+      return;
+    }
+
+  gas_cgen_finish_insn (insn, buffer, CGEN_FIELDS_BITSIZE (&fields),
+                        0, /* zero to ban relaxable insns.  */
+                        NULL); /* NULL so results not returned here.  */
+}
+
+void
+md_operand (expressionS *expressionP)
+{
+  gas_cgen_md_operand (expressionP);
+}
+
+
+symbolS *
+md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
+{
+  return NULL;
+}
+
+
+/* Turn a string in input_line_pointer into a floating point constant
+   of type TYPE, and store the appropriate bytes in *LITP.  The number
+   of LITTLENUMS emitted is stored in *SIZEP.  An error message is
+   returned, or NULL on OK.  */
+
+const char *
+md_atof (int type, char *litP, int *sizeP)
+{
+  return ieee_md_atof (type, litP, sizeP, FALSE);
+}
diff --git a/gas/configure b/gas/configure
index 27b6e8e..ab4dee0 100755
--- a/gas/configure
+++ b/gas/configure
@@ -770,6 +770,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -865,6 +866,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1117,6 +1119,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1254,7 +1265,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1407,6 +1418,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -11337,7 +11349,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11340 "configure"
+#line 11352 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11443,7 +11455,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11446 "configure"
+#line 11458 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11830,7 +11842,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -11876,7 +11888,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -11900,7 +11912,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -11945,7 +11957,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -11969,7 +11981,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -12805,6 +12817,16 @@ _ACEOF
 	done
 	;;
 
+      bpf)
+      	if test $this_target = $target ; then
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_ARCH "${arch}"
+_ACEOF
+
+	fi
+        using_cgen=yes
+        ;;
       epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | or1k)
 	using_cgen=yes
 	;;
@@ -13163,6 +13185,8 @@ if test $using_cgen = yes ; then
   case ${target_cpu} in
     or1knd)
        cgen_cpu_prefix=or1k ;;
+    bpfel|bpfeb)
+       cgen_cpu_prefix=bpf ;;
     *) cgen_cpu_prefix=${target_cpu} ;;
   esac
 
diff --git a/gas/configure.ac b/gas/configure.ac
index 93faa41..b03354a 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -410,6 +410,12 @@ changequote([,])dnl
 	done
 	;;
 
+      bpf)
+      	if test $this_target = $target ; then
+	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
+	fi
+        using_cgen=yes
+        ;;
       epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | or1k)
 	using_cgen=yes
 	;;
@@ -722,6 +728,8 @@ if test $using_cgen = yes ; then
   case ${target_cpu} in
     or1knd)
        cgen_cpu_prefix=or1k ;;
+    bpfel|bpfeb)
+       cgen_cpu_prefix=bpf ;;
     *) cgen_cpu_prefix=${target_cpu} ;;
   esac
   AC_SUBST(cgen_cpu_prefix)
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 532f113..51b7d41 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -58,6 +58,8 @@ case ${cpu} in
   cr16*)		cpu_type=cr16 endian=little ;;
   crisv32)		cpu_type=cris arch=crisv32 ;;
   crx*)			cpu_type=crx endian=little ;;
+  bpfel)		cpu_type=bpf endian=little ;;
+  bpfeb)		cpu_type=bpf endian=big ;;
   epiphany*)		cpu_type=epiphany endian=little ;;
   fido)			cpu_type=m68k ;;
   hppa*)		cpu_type=hppa ;;
@@ -182,6 +184,7 @@ case ${generic_target} in
   d30v-*-*)				fmt=elf ;;
   dlx-*-*)				fmt=elf ;;
 
+  bpf*-*-*)				fmt=elf ;;
   epiphany-*-*)				fmt=elf ;;
 
   fr30-*-*)				fmt=elf ;;
diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in
index 855259d..8241219 100644
--- a/gas/doc/Makefile.in
+++ b/gas/doc/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -364,6 +364,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff --git a/gas/testsuite/gas/bpf/alu.d b/gas/testsuite/gas/bpf/alu.d
new file mode 100644
index 0000000..9222fa3
--- /dev/null
+++ b/gas/testsuite/gas/bpf/alu.d
@@ -0,0 +1,64 @@
+#as: --LE
+#objdump: -dr
+#name: eBPF ALU instructions
+
+.*: +file format .*ebpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+   0:	04 02 00 00 9a 02 00 00 	add32 %r2,666
+   8:	04 03 00 00 66 fd ff ff 	add32 %r3,-666
+  10:	04 04 00 00 ef be ad de 	add32 %r4,-559038737
+  18:	0c 65 00 00 00 00 00 00 	add32 %r5,%r6
+  20:	14 02 00 00 9a 02 00 00 	sub32 %r2,666
+  28:	14 03 00 00 66 fd ff ff 	sub32 %r3,-666
+  30:	14 04 00 00 ef be ad de 	sub32 %r4,-559038737
+  38:	1c 65 00 00 00 00 00 00 	sub32 %r5,%r6
+  40:	24 02 00 00 9a 02 00 00 	mul32 %r2,666
+  48:	24 03 00 00 66 fd ff ff 	mul32 %r3,-666
+  50:	24 04 00 00 ef be ad de 	mul32 %r4,-559038737
+  58:	2c 65 00 00 00 00 00 00 	mul32 %r5,%r6
+  60:	34 02 00 00 9a 02 00 00 	div32 %r2,666
+  68:	34 03 00 00 66 fd ff ff 	div32 %r3,-666
+  70:	34 04 00 00 ef be ad de 	div32 %r4,-559038737
+  78:	3c 65 00 00 00 00 00 00 	div32 %r5,%r6
+  80:	44 02 00 00 9a 02 00 00 	or32 %r2,666
+  88:	44 03 00 00 66 fd ff ff 	or32 %r3,-666
+  90:	44 04 00 00 ef be ad de 	or32 %r4,-559038737
+  98:	4c 65 00 00 00 00 00 00 	or32 %r5,%r6
+  a0:	54 02 00 00 9a 02 00 00 	and32 %r2,666
+  a8:	54 03 00 00 66 fd ff ff 	and32 %r3,-666
+  b0:	54 04 00 00 ef be ad de 	and32 %r4,-559038737
+  b8:	5c 65 00 00 00 00 00 00 	and32 %r5,%r6
+  c0:	64 02 00 00 9a 02 00 00 	lsh32 %r2,666
+  c8:	64 03 00 00 66 fd ff ff 	lsh32 %r3,-666
+  d0:	64 04 00 00 ef be ad de 	lsh32 %r4,-559038737
+  d8:	6c 65 00 00 00 00 00 00 	lsh32 %r5,%r6
+  e0:	74 02 00 00 9a 02 00 00 	rsh32 %r2,666
+  e8:	74 03 00 00 66 fd ff ff 	rsh32 %r3,-666
+  f0:	74 04 00 00 ef be ad de 	rsh32 %r4,-559038737
+  f8:	7c 65 00 00 00 00 00 00 	rsh32 %r5,%r6
+ 100:	94 02 00 00 9a 02 00 00 	mod32 %r2,666
+ 108:	94 03 00 00 66 fd ff ff 	mod32 %r3,-666
+ 110:	94 04 00 00 ef be ad de 	mod32 %r4,-559038737
+ 118:	9c 65 00 00 00 00 00 00 	mod32 %r5,%r6
+ 120:	a4 02 00 00 9a 02 00 00 	xor32 %r2,666
+ 128:	a4 03 00 00 66 fd ff ff 	xor32 %r3,-666
+ 130:	a4 04 00 00 ef be ad de 	xor32 %r4,-559038737
+ 138:	ac 65 00 00 00 00 00 00 	xor32 %r5,%r6
+ 140:	b4 02 00 00 9a 02 00 00 	mov32 %r2,666
+ 148:	b4 03 00 00 66 fd ff ff 	mov32 %r3,-666
+ 150:	b4 04 00 00 ef be ad de 	mov32 %r4,-559038737
+ 158:	bc 65 00 00 00 00 00 00 	mov32 %r5,%r6
+ 160:	c4 02 00 00 9a 02 00 00 	arsh32 %r2,666
+ 168:	c4 03 00 00 66 fd ff ff 	arsh32 %r3,-666
+ 170:	c4 04 00 00 ef be ad de 	arsh32 %r4,-559038737
+ 178:	cc 65 00 00 00 00 00 00 	arsh32 %r5,%r6
+ 180:	8c 02 00 00 00 00 00 00 	neg32 %r2
+ 188:	d4 09 00 00 10 00 00 00 	le16 %r9
+ 190:	d4 08 00 00 20 00 00 00 	le32 %r8
+ 198:	d4 07 00 00 40 00 00 00 	le64 %r7
+ 1a0:	dc 06 00 00 10 00 00 00 	be16 %r6
+ 1a8:	dc 05 00 00 20 00 00 00 	be32 %r5
+ 1b0:	dc 04 00 00 40 00 00 00 	be64 %r4
diff --git a/gas/testsuite/gas/bpf/alu.s b/gas/testsuite/gas/bpf/alu.s
new file mode 100644
index 0000000..d9885d5
--- /dev/null
+++ b/gas/testsuite/gas/bpf/alu.s
@@ -0,0 +1,57 @@
+# Tests for the ALU eBPF instructions
+        .text
+        add32	%r2, 666
+        add32	%r3, -666
+        add32	%r4, 0xdeadbeef
+        add32	%r5, %r6
+        sub32	%r2, 666
+        sub32	%r3, -666
+        sub32	%r4, 0xdeadbeef
+        sub32	%r5, %r6
+        mul32	%r2, 666
+        mul32	%r3, -666
+        mul32	%r4, 0xdeadbeef
+        mul32	%r5, %r6
+        div32	%r2, 666
+        div32	%r3, -666
+        div32	%r4, 0xdeadbeef
+        div32	%r5, %r6
+        or32	%r2, 666
+        or32	%r3, -666
+        or32	%r4, 0xdeadbeef
+        or32	%r5, %r6
+        and32	%r2, 666
+        and32	%r3, -666
+        and32	%r4, 0xdeadbeef
+        and32	%r5, %r6
+        lsh32	%r2, 666
+        lsh32	%r3, -666
+        lsh32	%r4, 0xdeadbeef
+        lsh32	%r5, %r6
+        rsh32	%r2, 666
+        rsh32	%r3, -666
+        rsh32	%r4, 0xdeadbeef
+        rsh32	%r5, %r6
+        mod32	%r2, 666
+        mod32	%r3, -666
+        mod32	%r4, 0xdeadbeef
+        mod32	%r5, %r6
+        xor32	%r2, 666
+        xor32	%r3, -666
+        xor32	%r4, 0xdeadbeef
+        xor32	%r5, %r6
+        mov32	%r2, 666
+        mov32	%r3, -666
+        mov32	%r4, 0xdeadbeef
+        mov32	%r5, %r6
+        arsh32	%r2, 666
+        arsh32	%r3, -666
+        arsh32	%r4, 0xdeadbeef
+        arsh32	%r5, %r6
+        neg32	%r2
+	le16	%r9
+        le32	%r8
+        le64	%r7
+        be16	%r6
+        be32	%r5
+        be64	%r4
diff --git a/gas/testsuite/gas/bpf/alu64.d b/gas/testsuite/gas/bpf/alu64.d
new file mode 100644
index 0000000..48bb785
--- /dev/null
+++ b/gas/testsuite/gas/bpf/alu64.d
@@ -0,0 +1,58 @@
+#as: --LE
+#objdump: -dr
+#name: eBPF ALU64 instructions
+
+.*: +file format .*ebpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+   0:	07 02 00 00 9a 02 00 00 	add %r2,666
+   8:	07 03 00 00 66 fd ff ff 	add %r3,-666
+  10:	07 04 00 00 ef be ad de 	add %r4,-559038737
+  18:	0f 65 00 00 00 00 00 00 	add %r5,%r6
+  20:	17 02 00 00 9a 02 00 00 	sub %r2,666
+  28:	17 03 00 00 66 fd ff ff 	sub %r3,-666
+  30:	17 04 00 00 ef be ad de 	sub %r4,-559038737
+  38:	1f 65 00 00 00 00 00 00 	sub %r5,%r6
+  40:	27 02 00 00 9a 02 00 00 	mul %r2,666
+  48:	27 03 00 00 66 fd ff ff 	mul %r3,-666
+  50:	27 04 00 00 ef be ad de 	mul %r4,-559038737
+  58:	2f 65 00 00 00 00 00 00 	mul %r5,%r6
+  60:	37 02 00 00 9a 02 00 00 	div %r2,666
+  68:	37 03 00 00 66 fd ff ff 	div %r3,-666
+  70:	37 04 00 00 ef be ad de 	div %r4,-559038737
+  78:	3f 65 00 00 00 00 00 00 	div %r5,%r6
+  80:	47 02 00 00 9a 02 00 00 	or %r2,666
+  88:	47 03 00 00 66 fd ff ff 	or %r3,-666
+  90:	47 04 00 00 ef be ad de 	or %r4,-559038737
+  98:	4f 65 00 00 00 00 00 00 	or %r5,%r6
+  a0:	57 02 00 00 9a 02 00 00 	and %r2,666
+  a8:	57 03 00 00 66 fd ff ff 	and %r3,-666
+  b0:	57 04 00 00 ef be ad de 	and %r4,-559038737
+  b8:	5f 65 00 00 00 00 00 00 	and %r5,%r6
+  c0:	67 02 00 00 9a 02 00 00 	lsh %r2,666
+  c8:	67 03 00 00 66 fd ff ff 	lsh %r3,-666
+  d0:	67 04 00 00 ef be ad de 	lsh %r4,-559038737
+  d8:	6f 65 00 00 00 00 00 00 	lsh %r5,%r6
+  e0:	77 02 00 00 9a 02 00 00 	rsh %r2,666
+  e8:	77 03 00 00 66 fd ff ff 	rsh %r3,-666
+  f0:	77 04 00 00 ef be ad de 	rsh %r4,-559038737
+  f8:	7f 65 00 00 00 00 00 00 	rsh %r5,%r6
+ 100:	97 02 00 00 9a 02 00 00 	mod %r2,666
+ 108:	97 03 00 00 66 fd ff ff 	mod %r3,-666
+ 110:	97 04 00 00 ef be ad de 	mod %r4,-559038737
+ 118:	9f 65 00 00 00 00 00 00 	mod %r5,%r6
+ 120:	a7 02 00 00 9a 02 00 00 	xor %r2,666
+ 128:	a7 03 00 00 66 fd ff ff 	xor %r3,-666
+ 130:	a7 04 00 00 ef be ad de 	xor %r4,-559038737
+ 138:	af 65 00 00 00 00 00 00 	xor %r5,%r6
+ 140:	b7 02 00 00 9a 02 00 00 	mov %r2,666
+ 148:	b7 03 00 00 66 fd ff ff 	mov %r3,-666
+ 150:	b7 04 00 00 ef be ad de 	mov %r4,-559038737
+ 158:	bf 65 00 00 00 00 00 00 	mov %r5,%r6
+ 160:	c7 02 00 00 9a 02 00 00 	arsh %r2,666
+ 168:	c7 03 00 00 66 fd ff ff 	arsh %r3,-666
+ 170:	c7 04 00 00 ef be ad de 	arsh %r4,-559038737
+ 178:	cf 65 00 00 00 00 00 00 	arsh %r5,%r6
+ 180:	8f 02 00 00 00 00 00 00 	neg %r2
diff --git a/gas/testsuite/gas/bpf/alu64.s b/gas/testsuite/gas/bpf/alu64.s
new file mode 100644
index 0000000..eca6376
--- /dev/null
+++ b/gas/testsuite/gas/bpf/alu64.s
@@ -0,0 +1,51 @@
+# Tests for the ALU64 eBPF instructions
+        .text
+        add	%r2, 666
+        add	%r3, -666
+        add	%r4, 0xdeadbeef
+        add	%r5, %r6
+        sub	%r2, 666
+        sub	%r3, -666
+        sub	%r4, 0xdeadbeef
+        sub	%r5, %r6
+        mul	%r2, 666
+        mul	%r3, -666
+        mul	%r4, 0xdeadbeef
+        mul	%r5, %r6
+        div	%r2, 666
+        div	%r3, -666
+        div	%r4, 0xdeadbeef
+        div	%r5, %r6
+        or	%r2, 666
+        or	%r3, -666
+        or	%r4, 0xdeadbeef
+        or	%r5, %r6
+        and	%r2, 666
+        and	%r3, -666
+        and	%r4, 0xdeadbeef
+        and	%r5, %r6
+        lsh	%r2, 666
+        lsh	%r3, -666
+        lsh	%r4, 0xdeadbeef
+        lsh	%r5, %r6
+        rsh	%r2, 666
+        rsh	%r3, -666
+        rsh	%r4, 0xdeadbeef
+        rsh	%r5, %r6
+        mod	%r2, 666
+        mod	%r3, -666
+        mod	%r4, 0xdeadbeef
+        mod	%r5, %r6
+        xor	%r2, 666
+        xor	%r3, -666
+        xor	%r4, 0xdeadbeef
+        xor	%r5, %r6
+        mov	%r2, 666
+        mov	%r3, -666
+        mov	%r4, 0xdeadbeef
+        mov	%r5, %r6
+        arsh	%r2, 666
+        arsh	%r3, -666
+        arsh	%r4, 0xdeadbeef
+        arsh	%r5, %r6
+        neg     %r2
diff --git a/gas/testsuite/gas/bpf/bpf.exp b/gas/testsuite/gas/bpf/bpf.exp
new file mode 100644
index 0000000..fe481ec
--- /dev/null
+++ b/gas/testsuite/gas/bpf/bpf.exp
@@ -0,0 +1,25 @@
+# GAS testsuite for the Linux eBPF -*- Tcl -*-
+#
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# Contributed by Oracle, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  
+
+if {[istarget bpf*-*-*]} {
+    run_dump_test lddw
+    run_dump_test alu64
+    run_dump_test alu
+    run_dump_test mem
+}
diff --git a/gas/testsuite/gas/bpf/lddw.d b/gas/testsuite/gas/bpf/lddw.d
new file mode 100644
index 0000000..0d98402
--- /dev/null
+++ b/gas/testsuite/gas/bpf/lddw.d
@@ -0,0 +1,17 @@
+#as: --LE
+#objdump: -dr
+#name: eBPF LDDW
+
+.*: +file format .*ebpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+   0:	18 03 00 00 01 00 00 00 	lddw %r3,1
+   8:	00 00 00 00 00 00 00 00 
+  10:	18 04 00 00 ef be ad de 	lddw %r4, 3735928559
+  18:	00 00 00 00 00 00 00 00
+  20:	18 05 00 00 88 77 66 55 	lddw %r5,1234605616436508552
+  28:	44 33 22 11 00 00 00 00 
+  30:	18 06 00 00 fe ff ff ff 	lddw %r6,-1
+  38:	ff ff ff ff 00 00 00 00
diff --git a/gas/testsuite/gas/bpf/lddw.s b/gas/testsuite/gas/bpf/lddw.s
new file mode 100644
index 0000000..9e65e4a
--- /dev/null
+++ b/gas/testsuite/gas/bpf/lddw.s
@@ -0,0 +1,6 @@
+# Tests for the LDDW instruction
+        .text
+        lddw	%r3, 1
+        lddw	%r4, 0xdeadbeef
+        lddw	%r5, 0x1122334455667788
+        lddw	%r6, -2
diff --git a/gas/testsuite/gas/bpf/mem.d b/gas/testsuite/gas/bpf/mem.d
new file mode 100644
index 0000000..87c0e05
--- /dev/null
+++ b/gas/testsuite/gas/bpf/mem.d
@@ -0,0 +1,17 @@
+#as: --LE
+#objdump: -dr
+#name: eBPF MEM instructions, modulus lddw
+
+.*: +file format .*ebpf.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+   0:	20 23 00 00 ef be 00 00 	ldabsw %r2,%r3,48879
+   8:	28 45 00 00 ef be 00 00 	ldabsh %r4,%r5,48879
+  10:	30 67 00 00 ef be 00 00 	ldabsb %r6,%r7,48879
+  18:	38 89 00 00 ef be 00 00 	ldabsdw %r8,%r9,48879
+  20:	40 23 00 00 ef be 00 00 	ldindw %r2,%r3,48879
+  28:	48 45 00 00 ef be 00 00 	ldindh %r4,%r5,48879
+  30:	50 67 00 00 ef be 00 de 	ldindb %r6,%r7,48879
+  38:	58 89 00 00 ef be 00 00 	ldinddw %r8,%r9,48879
diff --git a/gas/testsuite/gas/bpf/mem.s b/gas/testsuite/gas/bpf/mem.s
new file mode 100644
index 0000000..151195b
--- /dev/null
+++ b/gas/testsuite/gas/bpf/mem.s
@@ -0,0 +1,12 @@
+# eBPF tests for MEM instructions, modulus lddw.
+
+        .text
+
+ 	ldabsw %r2, %r3, 0xbeef
+	ldabsh %r4, %r5, 0xbeef
+ 	ldabsb %r6, %r7, 0xbeef
+ 	ldabsdw %r8, %r9, 0xbeef
+	ldindw %r2, %r3, 0xbeef
+ 	ldindh %r4, %r5, 0xbeef
+ 	ldindb %r6, %r7, 0xbeef
+ 	ldinddw %r8, %r9, 0xbeef
diff --git a/include/ChangeLog b/include/ChangeLog
index e737525..b410b0f 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2018-11-26  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* elf/bpf.h: New file.
+
 2018-11-13  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
 	* opcode/arm.h (ARM_AEXT_V6M_ONLY): Merge into its use in ARM_AEXT_V6M.
diff --git a/include/elf/bpf.h b/include/elf/bpf.h
new file mode 100644
index 0000000..43c881c
--- /dev/null
+++ b/include/elf/bpf.h
@@ -0,0 +1,34 @@
+/* Linux eBPF support for BFD.
+   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Contributed by Embecosm on behalf of Adapteva, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _ELF_BPF_H
+#define _ELF_BPF_H
+
+#include "elf/reloc-macros.h"
+
+/* Relocations.  */
+START_RELOC_NUMBERS (elf_bpf_reloc_type)
+  RELOC_NUMBER (R_BPF_NONE,	0)
+  RELOC_NUMBER (R_BPF_64_64,	1)
+  RELOC_NUMBER (R_BPF_64_32,	2)
+  
+END_RELOC_NUMBERS (R_BPF_max)
+
+#endif /* _ELF_BPF_H  */
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index bfdca28..dc4a4df 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,16 @@
+2018-11-26  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* Makefile.am (HFILES): Add files for the bpf port.
+	(TARGET_LIBOPCODES_CFILES): Likewise.
+	(BPF_DEPS): Define.
+	Add rules to invoke CGEN.
+	* Makefile.in: Regenerate.
+	* aclocal.m4: Likewise.
+	* configure: Likewise.
+	* disassemble.h (print_insn_bpf): Prototype.
+	* disassemble.c (ARCH_bpf): Define.
+	(disassembler): Handle ARCH_bpf.
+
 2018-11-13  Francois H. Theron <francois.theron@netronome.com>
 
 	* nfp-dis.c: Fix crc[] disassembly if operands are swapped.
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index cf26ddf..ed7610f 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -59,6 +59,7 @@ BUILD_LIB_DEPS = @BUILD_LIB_DEPS@
 # Header files.
 HFILES = \
 	aarch64-asm.h aarch64-dis.h aarch64-opc.h aarch64-tbl.h \
+	bpf-desc.h bpf-opc.h \
 	epiphany-desc.h epiphany-opc.h \
 	fr30-desc.h fr30-opc.h \
 	frv-desc.h frv-opc.h \
[...]

[diff truncated at 100000 bytes]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]