Skip to content

Commit 9b16137

Browse files
WangNan0acmel
authored andcommitted
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>
1 parent 674d2d6 commit 9b16137

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎tools/lib/bpf/libbpf.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
#include "libbpf.h"
3838
#include "bpf.h"
3939

40+
#ifndef EM_BPF
41+
#define EM_BPF 247
42+
#endif
43+
4044
#define __printf(a, b) __attribute__((format(printf, a, b)))
4145

4246
__printf(1, 2)
@@ -439,7 +443,8 @@ static int bpf_object__elf_init(struct bpf_object *obj)
439443
}
440444
ep = &obj->efile.ehdr;
441445

442-
if ((ep->e_type != ET_REL) || (ep->e_machine != 0)) {
446+
/* Old LLVM set e_machine to EM_NONE */
447+
if ((ep->e_type != ET_REL) || (ep->e_machine && (ep->e_machine != EM_BPF))) {
443448
pr_warning("%s is not an eBPF object file\n",
444449
obj->path);
445450
err = -LIBBPF_ERRNO__FORMAT;

0 commit comments

Comments
 (0)