diff options
| author | Yonghong Song <yhs@fb.com> | 2019-05-13 05:00:23 +0000 |
|---|---|---|
| committer | Yonghong Song <yhs@fb.com> | 2019-05-13 05:00:23 +0000 |
| commit | 98fe9c9869c45f2833d75b89eed3bb5096f718ca (patch) | |
| tree | 2a8f12b1db4aa0c3716afdcd9eb91d67744ae9ab /llvm/lib/Target/BPF | |
| parent | 45139290942c9124d14e77e1a0830032d5a5496f (diff) | |
| download | bcm5719-llvm-98fe9c9869c45f2833d75b89eed3bb5096f718ca.tar.gz bcm5719-llvm-98fe9c9869c45f2833d75b89eed3bb5096f718ca.zip | |
[BPF] emit BTF sections only if debuginfo available
Currently, without -g, BTF sections may still be emitted with
data sections, e.g., for linux kernel bpf selftest
test_tcp_check_syncookie_kern.c issue discovered by Martin
as shown below.
-bash-4.4$ bpftool btf dump file test_tcp_check_syncookie_kern.o
[1] VAR 'results' type_id=0, linkage=global-alloc
[2] VAR '_license' type_id=0, linkage=global-alloc
[3] DATASEC 'license' size=0 vlen=1
type_id=2 offset=0 size=4
[4] DATASEC 'maps' size=0 vlen=1
type_id=1 offset=0 size=28
Let disable BTF generation if no debuginfo, which is
the original design.
Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D61826
llvm-svn: 360556
Diffstat (limited to 'llvm/lib/Target/BPF')
| -rw-r--r-- | llvm/lib/Target/BPF/BPFAsmPrinter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp index fa114b257da..76b22056e5d 100644 --- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp +++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp @@ -54,7 +54,8 @@ public: bool BPFAsmPrinter::doInitialization(Module &M) { AsmPrinter::doInitialization(M); - if (MAI->doesSupportDebugInformation()) { + // Only emit BTF when debuginfo available. + if (MAI->doesSupportDebugInformation() && !empty(M.debug_compile_units())) { Handlers.emplace_back(llvm::make_unique<BTFDebug>(this), "emit", "Debug Info Emission", "BTF", "BTF Emission"); } |

