Blame tests/run-disasm-bpf.sh

Packit 032894
#! /bin/sh
Packit 032894
# Copyright (C) 2016 Red Hat, Inc.
Packit 032894
# This file is part of elfutils.
Packit 032894
#
Packit 032894
# This file is free software; you can redistribute it and/or modify
Packit 032894
# it under the terms of the GNU General Public License as published by
Packit 032894
# the Free Software Foundation; either version 3 of the License, or
Packit 032894
# (at your option) any later version.
Packit 032894
#
Packit 032894
# elfutils is distributed in the hope that it will be useful, but
Packit 032894
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
# GNU General Public License for more details.
Packit 032894
#
Packit 032894
# You should have received a copy of the GNU General Public License
Packit 032894
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
# This test file is created with
Packit 032894
#
Packit 032894
# #include <linux/bpf.h>
Packit 032894
# #include <stdio.h>
Packit 032894
#
Packit 032894
# int main()
Packit 032894
# {
Packit 032894
#   int i;
Packit 032894
#
Packit 032894
#   printf("\t.text\n");
Packit 032894
#
Packit 032894
#   for (i = 0; i < 256; ++i)
Packit 032894
#     if (i == (BPF_LD | BPF_IMM | BPF_DW))
Packit 032894
#       printf("\t.byte\t%d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n", i);
Packit 032894
#     else
Packit 032894
#       {
Packit 032894
#         int regs = 0;
Packit 032894
#         switch (BPF_CLASS(i))
Packit 032894
#           {
Packit 032894
#           case BPF_ALU:
Packit 032894
#           case BPF_ALU64:
Packit 032894
#             if (BPF_SRC(i) == BPF_X
Packit 032894
#                 && BPF_OP(i) != BPF_NEG
Packit 032894
#                 && BPF_OP(i) != BPF_END)
Packit 032894
#               regs = 0x21;
Packit 032894
#             break;
Packit 032894
#           case BPF_LDX:
Packit 032894
#           case BPF_STX:
Packit 032894
#             regs = 0x21;
Packit 032894
#             break;
Packit 032894
#           }
Packit 032894
#         printf("\t.byte\t%d, %d, 0, 0, 0, 0, 0, 0\n", i, regs);
Packit 032894
#       }
Packit 032894
#
Packit 032894
#   return 0;
Packit 032894
# }
Packit 032894
#
Packit 032894
# $ ./a.out | as -o z1.o
Packit 032894
# $ objcopy -j .text z1.o z2.o
Packit 032894
#
Packit 032894
# Then emacs hexl edit e_machine to 0xf7.
Packit 032894
Packit 032894
testfiles testfile-bpf-dis1.o testfile-bpf-dis1.expect
Packit 032894
testrun_compare ${abs_top_builddir}/src/objdump -d testfile-bpf-dis1.o < testfile-bpf-dis1.expect