diff options
| author | Yonghong Song <[email protected]> | 2018-06-16 13:02:43 -0700 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2018-06-21 20:33:32 +0200 |
| commit | c1990d36cfe37a30bcc49422c37a6767fd190559 (patch) | |
| tree | fd16623796936526ef3de10feac44e50cdb47864 /tests | |
| parent | 3e4f78a7be8faec96f89da58ce9849a274aef0c4 (diff) | |
backends,bpf: add proper relocation support
Due to libdw does not have proper BPF relocation support,
the pahole cannot display filenames correctly for objects
with default llvm options. So we have to invent
a special option "llc -march=bpf -mattr=dwarfris" to
prevent llvm from generating cross-section dwarf relocation
records (https://reviews.llvm.org/rL326505).
The pahole related discussion is in linux netdev
mailing list (http://lists.openwall.net/netdev/2018/06/15/38, etc.)
We would like to add proper BPF relocation support
to libdw so eventually we could retire the special llc bpf
flag "-mattr=dwarfris".
The bpf relocations are defined in
llvm_repo:include/llvm/BinaryFormat/ELFRelocs/BPF.def:
ELF_RELOC(R_BPF_NONE, 0)
ELF_RELOC(R_BPF_64_64, 1)
ELF_RELOC(R_BPF_64_32, 10)
Removed the relocation type R_BPF_MAP_FD whoes name does not
confirm to llvm definition and replaced it with R_BPF_64_64.
The BPF object is just a relocatible object, not an executable or
a shared library, so assign ELF type to REL only in bpf_reloc.def.
Signed-off-by: Yonghong Song <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 9 | ||||
| -rw-r--r-- | tests/Makefile.am | 5 | ||||
| -rwxr-xr-x | tests/run-reloc-bpf.sh | 33 | ||||
| -rw-r--r-- | tests/testfile-bpf-reloc.expect.bz2 | bin | 0 -> 300 bytes | |||
| -rw-r--r-- | tests/testfile-bpf-reloc.o.bz2 | bin | 0 -> 933 bytes |
5 files changed, 46 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 4abbd125..c4942860 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,12 @@ +2018-06-16 Yonghong Song <[email protected]> + + * run-reloc-bpf.sh: New test. + * testfile-bpf-reloc.o.bz2: New test file. + * testfile-bpf-reloc.expect.bz2: New test file. + * Makefile.am (TESTS): Add run-reloc-bpf.sh. + (EXTRA_DIST): Add run-reloc-bpf.sh, testfile-bpf-reloc.o.bz2 and + testfile-bpf-reloc.expect.bz2. + 2018-06-13 Mark Wielaard <[email protected]> * run-readelf-const-values.sh: New test. diff --git a/tests/Makefile.am b/tests/Makefile.am index 2d63da6a..bdb82fc0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -146,7 +146,8 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-dwarf-die-addr-die.sh \ run-get-units-invalid.sh run-get-units-split.sh \ run-attr-integrate-skel.sh \ - run-all-dwarf-ranges.sh run-unit-info.sh + run-all-dwarf-ranges.sh run-unit-info.sh \ + run-reloc-bpf.sh if !BIARCH export ELFUTILS_DISABLE_BIARCH = 1 @@ -376,6 +377,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ run-zstrptr.sh run-compress-test.sh \ run-disasm-bpf.sh \ testfile-bpf-dis1.expect.bz2 testfile-bpf-dis1.o.bz2 \ + run-reloc-bpf.sh \ + testfile-bpf-reloc.expect.bz2 testfile-bpf-reloc.o.bz2 \ testfile-m68k-core.bz2 testfile-m68k.bz2 testfile-m68k-s.bz2 \ run-dwarf-die-addr-die.sh \ run-get-units-invalid.sh run-get-units-split.sh \ diff --git a/tests/run-reloc-bpf.sh b/tests/run-reloc-bpf.sh new file mode 100755 index 00000000..feb75575 --- /dev/null +++ b/tests/run-reloc-bpf.sh @@ -0,0 +1,33 @@ +#! /bin/sh +# Copyright (C) 2018 Facebook, 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 +# $ cat t.c +# struct tt { +# int a; +# char b; +# }; +# int test(struct tt *t) { +# return t->a; +# } +# $ clang -O2 -g -emit-llvm -c t.c -o - | llc -march=bpf -filetype=obj -o t.o +# $ mv t.o testfile-bpf-reloc.o + +testfiles testfile-bpf-reloc.o testfile-bpf-reloc.expect +testrun_compare ${abs_top_builddir}/src/objdump -r testfile-bpf-reloc.o < testfile-bpf-reloc.expect diff --git a/tests/testfile-bpf-reloc.expect.bz2 b/tests/testfile-bpf-reloc.expect.bz2 Binary files differnew file mode 100644 index 00000000..0ff8cc4c --- /dev/null +++ b/tests/testfile-bpf-reloc.expect.bz2 diff --git a/tests/testfile-bpf-reloc.o.bz2 b/tests/testfile-bpf-reloc.o.bz2 Binary files differnew file mode 100644 index 00000000..295634f9 --- /dev/null +++ b/tests/testfile-bpf-reloc.o.bz2 |
