Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b16137a authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarWang Nan <wangnan0@huawei.com>
Acked-by: default avatarAlexei 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 674d2d69
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -37,6 +37,10 @@
#include "libbpf.h"
#include "libbpf.h"
#include "bpf.h"
#include "bpf.h"


#ifndef EM_BPF
#define EM_BPF 247
#endif

#define __printf(a, b)	__attribute__((format(printf, a, b)))
#define __printf(a, b)	__attribute__((format(printf, a, b)))


__printf(1, 2)
__printf(1, 2)
@@ -439,7 +443,8 @@ static int bpf_object__elf_init(struct bpf_object *obj)
	}
	}
	ep = &obj->efile.ehdr;
	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",
		pr_warning("%s is not an eBPF object file\n",
			obj->path);
			obj->path);
		err = -LIBBPF_ERRNO__FORMAT;
		err = -LIBBPF_ERRNO__FORMAT;