Skip to content

Commit

Permalink
tools lib bpf: Use official ELF e_machine value
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
Cc: Zefan Li <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
WangNan0 authored and acmel committed Jul 26, 2016
1 parent 674d2d6 commit 9b16137
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9b16137

Please sign in to comment.