Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Wang Nan and committed by
Arnaldo Carvalho de Melo
9b16137a 674d2d69

+6 -1
+6 -1
tools/lib/bpf/libbpf.c
··· 37 37 #include "libbpf.h" 38 38 #include "bpf.h" 39 39 40 + #ifndef EM_BPF 41 + #define EM_BPF 247 42 + #endif 43 + 40 44 #define __printf(a, b) __attribute__((format(printf, a, b))) 41 45 42 46 __printf(1, 2) ··· 443 439 } 444 440 ep = &obj->efile.ehdr; 445 441 446 - if ((ep->e_type != ET_REL) || (ep->e_machine != 0)) { 442 + /* Old LLVM set e_machine to EM_NONE */ 443 + if ((ep->e_type != ET_REL) || (ep->e_machine && (ep->e_machine != EM_BPF))) { 447 444 pr_warning("%s is not an eBPF object file\n", 448 445 obj->path); 449 446 err = -LIBBPF_ERRNO__FORMAT;