From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754798AbcG0KlY (ORCPT ); Wed, 27 Jul 2016 06:41:24 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39356 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753024AbcG0KlU (ORCPT ); Wed, 27 Jul 2016 06:41:20 -0400 Date: Wed, 27 Jul 2016 03:40:58 -0700 From: tip-bot for Wang Nan Message-ID: Cc: linux-kernel@vger.kernel.org, wangnan0@huawei.com, hpa@zytor.com, ast@kernel.org, lizefan@huawei.com, mingo@kernel.org, acme@redhat.com, tglx@linutronix.de Reply-To: tglx@linutronix.de, acme@redhat.com, mingo@kernel.org, lizefan@huawei.com, hpa@zytor.com, wangnan0@huawei.com, ast@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1468821668-60088-1-git-send-email-wangnan0@huawei.com> References: <1468821668-60088-1-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] tools lib bpf: Use official ELF e_machine value Git-Commit-ID: 9b16137ab0feec00f8c9b52a63d4034a6d199d30 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 9b16137ab0feec00f8c9b52a63d4034a6d199d30 Gitweb: http://git.kernel.org/tip/9b16137ab0feec00f8c9b52a63d4034a6d199d30 Author: Wang Nan AuthorDate: Mon, 18 Jul 2016 06:01:08 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 26 Jul 2016 10:08:53 -0300 tools lib bpf: Use official ELF e_machine value New LLVM will issue newly assigned EM_BPF machine code. The new code will be propagated to glibc and libelf. This patch introduces the new machine code to libbpf. Signed-off-by: Wang Nan Acked-by: Alexei Starovoitov Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1468821668-60088-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/bpf/libbpf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 32e6b6b..b699aea 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -37,6 +37,10 @@ #include "libbpf.h" #include "bpf.h" +#ifndef EM_BPF +#define EM_BPF 247 +#endif + #define __printf(a, b) __attribute__((format(printf, a, b))) __printf(1, 2) @@ -439,7 +443,8 @@ static int bpf_object__elf_init(struct bpf_object *obj) } ep = &obj->efile.ehdr; - if ((ep->e_type != ET_REL) || (ep->e_machine != 0)) { + /* Old LLVM set e_machine to EM_NONE */ + if ((ep->e_type != ET_REL) || (ep->e_machine && (ep->e_machine != EM_BPF))) { pr_warning("%s is not an eBPF object file\n", obj->path); err = -LIBBPF_ERRNO__FORMAT;