diff options
| author | Wang Nan <wangnan0@huawei.com> | 2016-07-18 02:01:08 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-26 09:08:53 -0400 |
| commit | 9b16137ab0feec00f8c9b52a63d4034a6d199d30 (patch) | |
| tree | ec26a5f8b2c9ab6f3f08022792a668a1cf625dc4 | |
| parent | 674d2d69b14f677a771ceec4b48bfade94a0c5f1 (diff) | |
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>
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 32e6b6bc6f7d..b699aea9a025 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
| @@ -37,6 +37,10 @@ | |||
| 37 | #include "libbpf.h" | 37 | #include "libbpf.h" |
| 38 | #include "bpf.h" | 38 | #include "bpf.h" |
| 39 | 39 | ||
| 40 | #ifndef EM_BPF | ||
| 41 | #define EM_BPF 247 | ||
| 42 | #endif | ||
| 43 | |||
| 40 | #define __printf(a, b) __attribute__((format(printf, a, b))) | 44 | #define __printf(a, b) __attribute__((format(printf, a, b))) |
| 41 | 45 | ||
| 42 | __printf(1, 2) | 46 | __printf(1, 2) |
| @@ -439,7 +443,8 @@ static int bpf_object__elf_init(struct bpf_object *obj) | |||
| 439 | } | 443 | } |
| 440 | ep = &obj->efile.ehdr; | 444 | ep = &obj->efile.ehdr; |
| 441 | 445 | ||
| 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))) { | ||
| 443 | pr_warning("%s is not an eBPF object file\n", | 448 | pr_warning("%s is not an eBPF object file\n", |
| 444 | obj->path); | 449 | obj->path); |
| 445 | err = -LIBBPF_ERRNO__FORMAT; | 450 | err = -LIBBPF_ERRNO__FORMAT; |
