Squashed 'third_party/elfutils/' content from commit 555e15e

Change-Id: I61cde98949e47e5c8c09c33260de17f30921be79
git-subtree-dir: third_party/elfutils
git-subtree-split: 555e15ebe8bf1eb33d00747173cfc80cc65648a4
diff --git a/tests/run-disasm-bpf.sh b/tests/run-disasm-bpf.sh
new file mode 100755
index 0000000..8ca89d5
--- /dev/null
+++ b/tests/run-disasm-bpf.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2016 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils 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, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# This test file is created with
+#
+# #include <linux/bpf.h>
+# #include <stdio.h>
+#
+# int main()
+# {
+#   int i;
+#
+#   printf("\t.text\n");
+#
+#   for (i = 0; i < 256; ++i)
+#     if (i == (BPF_LD | BPF_IMM | BPF_DW))
+#       printf("\t.byte\t%d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n", i);
+#     else
+#       {
+#         int regs = 0;
+#         switch (BPF_CLASS(i))
+#           {
+#           case BPF_ALU:
+#           case BPF_ALU64:
+#             if (BPF_SRC(i) == BPF_X
+#                 && BPF_OP(i) != BPF_NEG
+#                 && BPF_OP(i) != BPF_END)
+#               regs = 0x21;
+#             break;
+#           case BPF_LDX:
+#           case BPF_STX:
+#             regs = 0x21;
+#             break;
+#           }
+#         printf("\t.byte\t%d, %d, 0, 0, 0, 0, 0, 0\n", i, regs);
+#       }
+#
+#   return 0;
+# }
+#
+# $ ./a.out | as -o z1.o
+# $ objcopy -j .text z1.o z2.o
+#
+# Then emacs hexl edit e_machine to 0xf7.
+
+testfiles testfile-bpf-dis1.o testfile-bpf-dis1.expect
+testrun_compare ${abs_top_builddir}/src/objdump -d testfile-bpf-dis1.o < testfile-bpf-dis1.expect