Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1445229 > unrolled thread
| Started by | Wang Nan <wangnan0@huawei.com> |
|---|---|
| First post | 2016-07-18 08:10 +0200 |
| Last post | 2016-07-18 23:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] tools lib bpf: Use official ELF e_machine value Wang Nan <wangnan0@huawei.com> - 2016-07-18 08:10 +0200
Re: [PATCH] tools lib bpf: Use official ELF e_machine value Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-07-18 23:40 +0200
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-07-18 08:10 +0200 |
| Subject | [PATCH] tools lib bpf: Use official ELF e_machine value |
| Message-ID | <rW9UC-2uF-7@gated-at.bofh.it> |
New LLVM will issue newly assigned EM_BPF machine code. The new code
will be propogated to glibc and libelf.
This patch introduces the new machine code to libbpf.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
tools/lib/bpf/libbpf.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 32e6b6b..b699aea 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -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)
@@ -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;
--
1.8.3.4
[toc] | [next] | [standalone]
| From | Alexei Starovoitov <alexei.starovoitov@gmail.com> |
|---|---|
| Date | 2016-07-18 23:40 +0200 |
| Message-ID | <rWoqB-3fj-21@gated-at.bofh.it> |
| In reply to | #1445229 |
On Mon, Jul 18, 2016 at 06:01:08AM +0000, Wang Nan wrote:
> New LLVM will issue newly assigned EM_BPF machine code. The new code
> will be propogated to glibc and libelf.
>
> This patch introduces the new machine code to libbpf.
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Zefan Li <lizefan@huawei.com>
> Cc: pi3orama@163.com
> ---
> tools/lib/bpf/libbpf.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 32e6b6b..b699aea 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -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)
> @@ -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))) {
Thanks for the fix. Didn't realize we already check for zero here.
btw EM_BPF will be in llvm 3.9 release.
Acked-by: Alexei Starovoitov <ast@kernel.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web