public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] backends,bpf: add proper relocation support
@ 2018-06-16 20:02 Yonghong Song
  2018-06-20 11:41 ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2018-06-16 20:02 UTC (permalink / raw)
  To: elfutils-devel, ast, kafai, mark

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 <yhs@fb.com>
---
 backends/ChangeLog                  |   7 +++++
 backends/Makefile.am                |   2 +-
 backends/bpf_init.c                 |   1 +
 backends/bpf_reloc.def              |   3 +-
 backends/bpf_symbol.c               |  54 ++++++++++++++++++++++++++++++++++++
 libelf/elf.h                        |   3 +-
 tests/ChangeLog                     |   9 ++++++
 tests/Makefile.am                   |   5 +++-
 tests/run-reloc-bpf.sh              |  33 ++++++++++++++++++++++
 tests/testfile-bpf-reloc.expect.bz2 | Bin 0 -> 300 bytes
 tests/testfile-bpf-reloc.o.bz2      | Bin 0 -> 933 bytes
 11 files changed, 113 insertions(+), 4 deletions(-)
 create mode 100644 backends/bpf_symbol.c
 create mode 100755 tests/run-reloc-bpf.sh
 create mode 100644 tests/testfile-bpf-reloc.expect.bz2
 create mode 100644 tests/testfile-bpf-reloc.o.bz2

Note:
 I didn't add the Changelog to libelf/elf.h as I anticipate the
 change will come from sync'ing with glibc.
 If this patch version looks good, I can send another revision
 once the libelf/elf.h is synced.

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 0dde0ff3..1ffe5ba4 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,10 @@
+2018-06-16  Yonghong Song  <yhs@fb.com>
+
+	* Makefile.am (bpf_SRCS): Add bpf_symbol.c.
+	* bpf_init.c (bpf_init): Add reloc_simple_type HOOK.
+	* bpf_reloc.def: Add RELOC_TYPE 64_64 and 64_32.
+	* bpf_symbol.c: New file.
+
 2018-05-15  Andreas Schwab  <schwab@suse.de>
 
 	* riscv_init.c (riscv_init): Hook check_special_symbol.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 80aa00e7..b5e721d8 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -126,7 +126,7 @@ am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
 # an issue.
 m68k_corenote_no_Wpacked_not_aligned = yes
 
-bpf_SRCS = bpf_init.c bpf_regs.c
+bpf_SRCS = bpf_init.c bpf_regs.c bpf_symbol.c
 cpu_bpf = ../libcpu/libcpu_bpf.a
 libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
 am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
diff --git a/backends/bpf_init.c b/backends/bpf_init.c
index 8ea1bc1a..a046e069 100644
--- a/backends/bpf_init.c
+++ b/backends/bpf_init.c
@@ -53,6 +53,7 @@ bpf_init (Elf *elf __attribute__ ((unused)),
   bpf_init_reloc (eh);
   HOOK (eh, register_info);
   HOOK (eh, disasm);
+  HOOK (eh, reloc_simple_type);
 
   return MODVERSION;
 }
diff --git a/backends/bpf_reloc.def b/backends/bpf_reloc.def
index a410da97..59f519b5 100644
--- a/backends/bpf_reloc.def
+++ b/backends/bpf_reloc.def
@@ -28,4 +28,5 @@
 /*	    NAME,		REL|EXEC|DYN	*/
 
 RELOC_TYPE (NONE,		EXEC|DYN)
-RELOC_TYPE (MAP_FD,		REL|EXEC|DYN)
+RELOC_TYPE (64_64,		REL)
+RELOC_TYPE (64_32,		REL)
diff --git a/backends/bpf_symbol.c b/backends/bpf_symbol.c
new file mode 100644
index 00000000..c9856f26
--- /dev/null
+++ b/backends/bpf_symbol.c
@@ -0,0 +1,54 @@
+/* BPF specific symbolic name handling.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   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 copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <assert.h>
+#include <elf.h>
+#include <stddef.h>
+#include <string.h>
+
+#define BACKEND bpf_
+#include "libebl_CPU.h"
+
+
+/* Check for the simple reloc types.  */
+Elf_Type
+bpf_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+{
+  switch (type)
+    {
+    case R_BPF_64_64:
+      return ELF_T_XWORD;
+    case R_BPF_64_32:
+      return ELF_T_WORD;
+    default:
+      return ELF_T_NUM;
+    }
+}
diff --git a/libelf/elf.h b/libelf/elf.h
index f7748983..940e88dd 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -3848,7 +3848,8 @@ enum
 /* BPF specific declarations.  */
 
 #define R_BPF_NONE		0	/* No reloc */
-#define R_BPF_MAP_FD		1	/* Map fd to pointer */
+#define R_BPF_64_64		1
+#define R_BPF_64_32		10
 
 /* Imagination Meta specific relocations. */
 
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  <yhs@fb.com>
+
+	* 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  <mark@klomp.org>
 
 	* 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
new file mode 100644
index 0000000000000000000000000000000000000000..0ff8cc4cce9180c8dc17c52d9dd417c04cf0628e
GIT binary patch
literal 300
zcmV+{0n`3MT4*^jL0KkKSz!M=9{>TbUw{FcKm&j9KPBHPzvtgzFabCe8kAu$L4h#?
zCIAxwl3{?*007Vc0000HQ2`oE$R>uEjTr`I02*mBrw_?KNzzFRv_=vU7`$+c(3A{9
z`U+SsK-!e1)YzD=qTM<q#~8pS(=Fa9j!ac$ctQbsA&^nZsi<9A`z0<G79=1c0|a$6
zOdQY<oymUW)oN}^1UIIX&X%RA5jCXA+MCj04T(y5B<X5nOH!1=mnEVU34tg`2wapU
zNm6f23BfR>Dc*Dbn#3v)%m@Yku;M~|@M6PmsAFl%fF)6kfC|!iOnE>EyUlcUG0+J5
yLir{49e`P$a#xI`NM<uila<1bQxuZdCFhWCyc*`LfD@&E;_gVN3K9$-=VRc>X?uA9

literal 0
HcmV?d00001

diff --git a/tests/testfile-bpf-reloc.o.bz2 b/tests/testfile-bpf-reloc.o.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..295634f909b2b58f6a3e3ffc729507cd7e7e1fce
GIT binary patch
literal 933
zcmV;W16uq-T4*^jL0KkKSx{G18vp~3|NsC0`~64x|NGNqa9h9s-}TWE0zg9G1ONy{
zP|!dC0Ej>X1C#=3X@;hn3VI2tsiXBHPe{?|*+~6S=``}2(vMJPpdORd$OF`905s9$
zOv-wgH8h0HG@5Ct<u;Q927#fV0MGyc0001J8UO=;000000000000000000>RMH5M&
zO#wYaJyGgt0j7-spa9XPfHY~K4F-)e83xp3)$MAuIh0=s+XxN}y=nw9<Ukk(MU-tZ
zp;J0$@$)mM?rL52{O)C<T+|G#aR6jCieeWtIU|se`xta_-=9g_SG%uv76d7zaS{`M
z2JiQKe-0?$vt#{4BTWF(7CJS#=BI3sz3A3oOYOP8OS3EeCL(r=jLOW7i?wG!U4#Wy
zf(>}*M9Yi~3{1N6kl8jIyEp{%<G&wIO7HTer+EgbNi0_}GlFoMARYz;l}jzUs#0+}
zgr_Akm37C=$fvD6H&}rnA`(IX5D-8b<N`b_B*g|nf=H7RTMY+o+rffMzR+*p(Sd@&
z25j&`Ex9x{g+mg|VnT}nWi+J4*VZ*hXH3ccX3!YUcAgfTYB`wZ^u{{YVnvszC#C;x
zcd4FM;uwup0%<^DC@YM_l+lB(Fk6;I(Z+@{WoFqXWM_Oea&{-?FsSWSf#$UY1X)eu
ziU@$(N#F7apkAh5Ifk@#C4F{Eqp<VcbAt?KXfl?Zppk|+G>jU;P@$sK`cVV?$m(<A
zNsesrj9Nimsbs(_?7bEg%~_jf0gt`E3W%)l>8WO9S%@hJA%IKQX^gf!U00GPqkm)a
zzA-GM9welkot--y1-+3Nf$F1f>`H`~aMyq@2qFXu8%Qt&focb+f3fmAa5B)qt~<17
z-0(iU2&9Th_&Q*Y)c8X<@h8KU(=g?@!c=wGt2YV768YAR({+mwFdAynRYb|beuf;H
z2K9U@53X_-lRznEu`RMf5;9}Z7_;+cr>~<}CJ`Wqme^{n6ddez3p@cZCaS1_A2zbs
z9$4`Z0H$~@+~+_CQVT{Y%r(&>#z+ej%ua4|f>{Oxa1gvLmoaVN6Kw04vsk_|FoM4p
z_QEJAuoZ)95vR)SSB#I-EMgJF)4o5XhEg9wq=i>7WhRQb7@BoMF1gA0L`ggvB;ZsK
zn97EI2naHvpxnSf2y&wU%#}`tV_9U)Y{e+#ptT#^1Z?_SXaTCyBq6O)yM$fI6yZWa
HL0wdAEl8b`

literal 0
HcmV?d00001

-- 
2.14.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] backends,bpf: add proper relocation support
  2018-06-16 20:02 [PATCH v2] backends,bpf: add proper relocation support Yonghong Song
@ 2018-06-20 11:41 ` Mark Wielaard
  2018-06-20 14:18   ` Yonghong Song
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Wielaard @ 2018-06-20 11:41 UTC (permalink / raw)
  To: Yonghong Song, elfutils-devel, ast, kafai

On Sat, 2018-06-16 at 13:02 -0700, Yonghong Song wrote:
> 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 <yhs@fb.com>
> ---
>  backends/ChangeLog                  |   7 +++++
>  backends/Makefile.am                |   2 +-
>  backends/bpf_init.c                 |   1 +
>  backends/bpf_reloc.def              |   3 +-
>  backends/bpf_symbol.c               |  54
> ++++++++++++++++++++++++++++++++++++
>  libelf/elf.h                        |   3 +-
>  tests/ChangeLog                     |   9 ++++++
>  tests/Makefile.am                   |   5 +++-
>  tests/run-reloc-bpf.sh              |  33 ++++++++++++++++++++++
>  tests/testfile-bpf-reloc.expect.bz2 | Bin 0 -> 300 bytes
>  tests/testfile-bpf-reloc.o.bz2      | Bin 0 -> 933 bytes
>  11 files changed, 113 insertions(+), 4 deletions(-)
>  create mode 100644 backends/bpf_symbol.c
>  create mode 100755 tests/run-reloc-bpf.sh
>  create mode 100644 tests/testfile-bpf-reloc.expect.bz2
>  create mode 100644 tests/testfile-bpf-reloc.o.bz2
> 
> Note:
>  I didn't add the Changelog to libelf/elf.h as I anticipate the
>  change will come from sync'ing with glibc.
>  If this patch version looks good, I can send another revision
>  once the libelf/elf.h is synced.

The patch looks perfect. And the new testcase is good. I used the
testfile to quickly test eu-readelf --debug-dump also got the
relocations right, and it did of course.

Just waiting for the glibc elf.h update/sync and then I'll push this to
master.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] backends,bpf: add proper relocation support
  2018-06-20 11:41 ` Mark Wielaard
@ 2018-06-20 14:18   ` Yonghong Song
  2018-06-21 18:58     ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2018-06-20 14:18 UTC (permalink / raw)
  To: Mark Wielaard, elfutils-devel, ast, kafai



On 6/20/18 4:41 AM, Mark Wielaard wrote:
> On Sat, 2018-06-16 at 13:02 -0700, Yonghong Song wrote:
>> 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://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_rL326505&d=DwIFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=BipW-mskUvazgUra_yLXaDDQuxRPN7odXPkQGoyQPCY&s=o2hBnG4NsHUyYJPq0YMC9vTjoTet5flJ1AnhjW8tDBw&e=).
>> The pahole related discussion is in linux netdev
>> mailing list (https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openwall.net_netdev_2018_06_15_38&d=DwIFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=BipW-mskUvazgUra_yLXaDDQuxRPN7odXPkQGoyQPCY&s=oqLz1O0PLduCn5Y2DVhr5yIpsLrSZ4GoRbHcZs5ZocA&e=, 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 <yhs@fb.com>
>> ---
>>   backends/ChangeLog                  |   7 +++++
>>   backends/Makefile.am                |   2 +-
>>   backends/bpf_init.c                 |   1 +
>>   backends/bpf_reloc.def              |   3 +-
>>   backends/bpf_symbol.c               |  54
>> ++++++++++++++++++++++++++++++++++++
>>   libelf/elf.h                        |   3 +-
>>   tests/ChangeLog                     |   9 ++++++
>>   tests/Makefile.am                   |   5 +++-
>>   tests/run-reloc-bpf.sh              |  33 ++++++++++++++++++++++
>>   tests/testfile-bpf-reloc.expect.bz2 | Bin 0 -> 300 bytes
>>   tests/testfile-bpf-reloc.o.bz2      | Bin 0 -> 933 bytes
>>   11 files changed, 113 insertions(+), 4 deletions(-)
>>   create mode 100644 backends/bpf_symbol.c
>>   create mode 100755 tests/run-reloc-bpf.sh
>>   create mode 100644 tests/testfile-bpf-reloc.expect.bz2
>>   create mode 100644 tests/testfile-bpf-reloc.o.bz2
>>
>> Note:
>>   I didn't add the Changelog to libelf/elf.h as I anticipate the
>>   change will come from sync'ing with glibc.
>>   If this patch version looks good, I can send another revision
>>   once the libelf/elf.h is synced.
> 
> The patch looks perfect. And the new testcase is good. I used the
> testfile to quickly test eu-readelf --debug-dump also got the
> relocations right, and it did of course.
> 
> Just waiting for the glibc elf.h update/sync and then I'll push this to
> master.

This looks perfect. Thanks!

> 
> Thanks,
> 
> Mark
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] backends,bpf: add proper relocation support
  2018-06-20 14:18   ` Yonghong Song
@ 2018-06-21 18:58     ` Mark Wielaard
  2018-06-21 20:24       ` Yonghong Song
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Wielaard @ 2018-06-21 18:58 UTC (permalink / raw)
  To: Yonghong Song; +Cc: elfutils-devel, ast, kafai

On Wed, Jun 20, 2018 at 07:18:22AM -0700, Yonghong Song wrote:
> On 6/20/18 4:41 AM, Mark Wielaard wrote:
> > The patch looks perfect. And the new testcase is good. I used the
> > testfile to quickly test eu-readelf --debug-dump also got the
> > relocations right, and it did of course.
> > 
> > Just waiting for the glibc elf.h update/sync and then I'll push this to
> > master.
> 
> This looks perfect. Thanks!

Pushed both. Thanks for the patch and testcase.

BTW. The following now also just works in case you have tools that
cannot handle the BPF relocations, but can handle separate .debug
files:

eu-strip --reloc-debug-sections -f testfile-bpf-reloc.o.debug \
	testfile-bpf-reloc.o

That puts the debuginfo with all (simple) relocations resolved
into the .debug file.

  --reloc-debug-sections Resolve all trivial relocations between debug
                         sections if the removed sections are placed in
                         a debug file (only relevant for ET_REL files,
                         operation is not reversable, needs -f)

This is used by some distros for the kernel .ko modules (which are
also ET_REL files) to safe space. But also might be applicable to
these BPF elf files in case they are packaged.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] backends,bpf: add proper relocation support
  2018-06-21 18:58     ` Mark Wielaard
@ 2018-06-21 20:24       ` Yonghong Song
  2018-06-22  6:38         ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2018-06-21 20:24 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel, ast, kafai



On 6/21/18 11:58 AM, Mark Wielaard wrote:
> On Wed, Jun 20, 2018 at 07:18:22AM -0700, Yonghong Song wrote:
>> On 6/20/18 4:41 AM, Mark Wielaard wrote:
>>> The patch looks perfect. And the new testcase is good. I used the
>>> testfile to quickly test eu-readelf --debug-dump also got the
>>> relocations right, and it did of course.
>>>
>>> Just waiting for the glibc elf.h update/sync and then I'll push this to
>>> master.
>>
>> This looks perfect. Thanks!
> 
> Pushed both. Thanks for the patch and testcase.

Thanks for the below tip!
Don't know you release schedule, but could you cut a release
soon so this can be picked up by dist/pahole?

Yonghong

> 
> BTW. The following now also just works in case you have tools that
> cannot handle the BPF relocations, but can handle separate .debug
> files:
> 
> eu-strip --reloc-debug-sections -f testfile-bpf-reloc.o.debug \
> 	testfile-bpf-reloc.o
> 
> That puts the debuginfo with all (simple) relocations resolved
> into the .debug file.
> 
>    --reloc-debug-sections Resolve all trivial relocations between debug
>                           sections if the removed sections are placed in
>                           a debug file (only relevant for ET_REL files,
>                           operation is not reversable, needs -f)
> 
> This is used by some distros for the kernel .ko modules (which are
> also ET_REL files) to safe space. But also might be applicable to
> these BPF elf files in case they are packaged.
> 
> Cheers,
> 
> Mark
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] backends,bpf: add proper relocation support
  2018-06-21 20:24       ` Yonghong Song
@ 2018-06-22  6:38         ` Mark Wielaard
  2018-06-22 14:15           ` Yonghong Song
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Wielaard @ 2018-06-22  6:38 UTC (permalink / raw)
  To: Yonghong Song; +Cc: elfutils-devel, ast, kafai

On Thu, Jun 21, 2018 at 01:24:41PM -0700, Yonghong Song wrote:
> Don't know you release schedule, but could you cut a release
> soon so this can be picked up by dist/pahole?

I'll push a new 0.173 release next week.

We recently added DWARF5 support, but running all the new data
parsers under the afl-fuzzer found some issues (hangs and crashes
on bad data). I already backported most fixes to the Fedora package.
But it would be better to have it all in a real release. Just letting
the fuzzer run for a couple more days to make sure we caught everything.

As long as the buildbot https://builder.wildebeest.org/buildbot/
keeps green on all arches, we should be good to go for a new release.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] backends,bpf: add proper relocation support
  2018-06-22  6:38         ` Mark Wielaard
@ 2018-06-22 14:15           ` Yonghong Song
  0 siblings, 0 replies; 7+ messages in thread
From: Yonghong Song @ 2018-06-22 14:15 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel, ast, kafai



On 6/21/18 11:37 PM, Mark Wielaard wrote:
> On Thu, Jun 21, 2018 at 01:24:41PM -0700, Yonghong Song wrote:
>> Don't know you release schedule, but could you cut a release
>> soon so this can be picked up by dist/pahole?
> 
> I'll push a new 0.173 release next week.
> 
> We recently added DWARF5 support, but running all the new data
> parsers under the afl-fuzzer found some issues (hangs and crashes
> on bad data). I already backported most fixes to the Fedora package.
> But it would be better to have it all in a real release. Just letting
> the fuzzer run for a couple more days to make sure we caught everything.

This sounds great.

Thanks a lot!

Yonghong

> 
> As long as the buildbot https://urldefense.proofpoint.com/v2/url?u=https-3A__builder.wildebeest.org_buildbot_&d=DwIBAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=Gg3Iao4nlT8T_FfpkzF8rtcxrNXj4xOCKntInTPwyB4&s=63Ho-WkVwykJHqY8u7Wt_2AFjFexwxG6NUCiz7cZaL0&e=
> keeps green on all arches, we should be good to go for a new release.
> 
> Cheers,
> 
> Mark
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-22 14:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-16 20:02 [PATCH v2] backends,bpf: add proper relocation support Yonghong Song
2018-06-20 11:41 ` Mark Wielaard
2018-06-20 14:18   ` Yonghong Song
2018-06-21 18:58     ` Mark Wielaard
2018-06-21 20:24       ` Yonghong Song
2018-06-22  6:38         ` Mark Wielaard
2018-06-22 14:15           ` Yonghong Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).