From 2d8620469b1c48b3c363c15f95ffd0f91dcaf494 Mon Sep 17 00:00:00 2001 From: Brenden Blanco Date: Thu, 5 Jan 2017 11:13:12 -0800 Subject: [PATCH] Fixes for LLVM 4.0 and python3 Avoid conflicting [no]inline attributes in function annotation. This was probably always there but now 4.0 is treating this as an error. Also, explicitly inline several functions in helpers.h. Turn off unwind tables in the flags passed to clang. This was generating calls to the elf relocator, which doesn't work for the BPF target. It is unclear which change in LLVM 4.0 altered this behavior. On python3, handle byte strings in the usual way for supporting backwards compatibility. Signed-off-by: Brenden Blanco --- src/cc/bpf_module.cc | 3 ++- src/cc/export/helpers.h | 4 ++-- src/cc/frontends/clang/loader.cc | 2 ++ tools/execsnoop.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc index ee39c00e573f..77abe72179d1 100644 --- a/src/cc/bpf_module.cc +++ b/src/cc/bpf_module.cc @@ -345,7 +345,8 @@ int BPFModule::load_includes(const string &text) { int BPFModule::annotate() { for (auto fn = mod_->getFunctionList().begin(); fn != mod_->getFunctionList().end(); ++fn) - fn->addFnAttr(Attribute::AlwaysInline); + if (!fn->hasFnAttribute(Attribute::NoInline)) + fn->addFnAttr(Attribute::AlwaysInline); // separate module to hold the reader functions auto m = make_unique("sscanf", *ctx_); diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h index c14085131057..dce8b2c915ed 100644 --- a/src/cc/export/helpers.h +++ b/src/cc/export/helpers.h @@ -284,7 +284,7 @@ static inline void bpf_store_dword(void *skb, u64 off, u64 val) { #define MASK(_n) ((_n) < 64 ? (1ull << (_n)) - 1 : ((u64)-1LL)) #define MASK128(_n) ((_n) < 128 ? ((unsigned __int128)1 << (_n)) - 1 : ((unsigned __int128)-1)) -static unsigned int bpf_log2(unsigned int v) +static inline unsigned int bpf_log2(unsigned int v) { unsigned int r; unsigned int shift; @@ -297,7 +297,7 @@ static unsigned int bpf_log2(unsigned int v) return r; } -static unsigned int bpf_log2l(unsigned long v) +static inline unsigned int bpf_log2l(unsigned long v) { unsigned int hi = v >> 32; if (hi) diff --git a/src/cc/frontends/clang/loader.cc b/src/cc/frontends/clang/loader.cc index 33d0e5083c3d..bfd9f6a5b7e6 100644 --- a/src/cc/frontends/clang/loader.cc +++ b/src/cc/frontends/clang/loader.cc @@ -137,6 +137,8 @@ int ClangLoader::parse(unique_ptr *mod, unique_ptr 0 else "?", event.retval, - ' '.join(argv[event.pid]))) + b' '.join(argv[event.pid]).decode())) del(argv[event.pid])