tools lib bpf: Use official ELF e_machine value
authorWang Nan <wangnan0@huawei.com>
Mon, 18 Jul 2016 06:01:08 +0000 (06:01 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 26 Jul 2016 13:08:53 +0000 (10:08 -0300)
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 <wangnan0@huawei.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
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 <acme@redhat.com>
tools/lib/bpf/libbpf.c

index 32e6b6bc6f7d918bc4ceb259021be1cedbceec38..b699aea9a02586903dc0d7a683e8ff995de3298b 100644 (file)
 #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;
This page took 0.025475 seconds and 5 git commands to generate.