From patchwork Mon Jul 18 06:01:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 72188 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp237432qga; Sun, 17 Jul 2016 23:03:26 -0700 (PDT) X-Received: by 10.98.90.193 with SMTP id o184mr43652255pfb.101.1468821806387; Sun, 17 Jul 2016 23:03:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j190si1649435pfc.151.2016.07.17.23.03.26; Sun, 17 Jul 2016 23:03:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751676AbcGRGDY (ORCPT + 29 others); Mon, 18 Jul 2016 02:03:24 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:40444 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbcGRGDV (ORCPT ); Mon, 18 Jul 2016 02:03:21 -0400 Received: from 172.24.1.36 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DNW20708; Mon, 18 Jul 2016 14:01:20 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Mon, 18 Jul 2016 14:01:12 +0800 From: Wang Nan To: , CC: , , Wang Nan , Alexei Starovoitov , "Arnaldo Carvalho de Melo" Subject: [PATCH] tools lib bpf: Use official ELF e_machine value Date: Mon, 18 Jul 2016 06:01:08 +0000 Message-ID: <1468821668-60088-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.578C70B1.0128, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b490d5b4cb4785813b408c0023862fff Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org New LLVM will issue newly assigned EM_BPF machine code. The new code will be propogated to glibc and libelf. This patch introduces the new machine code to libbpf. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Arnaldo Carvalho de Melo Cc: Zefan Li Cc: pi3orama@163.com --- tools/lib/bpf/libbpf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 1.8.3.4 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;