Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Copyright (C) 2016 Red Hat, Inc. |
| 3 | # This file is part of elfutils. |
| 4 | # |
| 5 | # This file is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation; either version 3 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # elfutils is distributed in the hope that it will be useful, but |
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | . $srcdir/test-subr.sh |
| 19 | |
| 20 | # This test file is created with |
| 21 | # |
| 22 | # #include <linux/bpf.h> |
| 23 | # #include <stdio.h> |
| 24 | # |
| 25 | # int main() |
| 26 | # { |
| 27 | # int i; |
| 28 | # |
| 29 | # printf("\t.text\n"); |
| 30 | # |
| 31 | # for (i = 0; i < 256; ++i) |
| 32 | # if (i == (BPF_LD | BPF_IMM | BPF_DW)) |
| 33 | # printf("\t.byte\t%d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n", i); |
| 34 | # else |
| 35 | # { |
| 36 | # int regs = 0; |
| 37 | # switch (BPF_CLASS(i)) |
| 38 | # { |
| 39 | # case BPF_ALU: |
| 40 | # case BPF_ALU64: |
| 41 | # if (BPF_SRC(i) == BPF_X |
| 42 | # && BPF_OP(i) != BPF_NEG |
| 43 | # && BPF_OP(i) != BPF_END) |
| 44 | # regs = 0x21; |
| 45 | # break; |
| 46 | # case BPF_LDX: |
| 47 | # case BPF_STX: |
| 48 | # regs = 0x21; |
| 49 | # break; |
| 50 | # } |
| 51 | # printf("\t.byte\t%d, %d, 0, 0, 0, 0, 0, 0\n", i, regs); |
| 52 | # } |
| 53 | # |
| 54 | # return 0; |
| 55 | # } |
| 56 | # |
| 57 | # $ ./a.out | as -o z1.o |
| 58 | # $ objcopy -j .text z1.o z2.o |
| 59 | # |
| 60 | # Then emacs hexl edit e_machine to 0xf7. |
| 61 | |
| 62 | testfiles testfile-bpf-dis1.o testfile-bpf-dis1.expect |
| 63 | testrun_compare ${abs_top_builddir}/src/objdump -d testfile-bpf-dis1.o < testfile-bpf-dis1.expect |