public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools lib bpf: Use official ELF e_machine value
@ 2016-07-18  6:01 Wang Nan
  2016-07-18 21:37 ` Alexei Starovoitov
  2016-07-27 10:40 ` [tip:perf/urgent] " tip-bot for Wang Nan
  0 siblings, 2 replies; 4+ messages in thread
From: Wang Nan @ 2016-07-18  6:01 UTC (permalink / raw)
  To: acme, lizefan
  Cc: linux-kernel, pi3orama, Wang Nan, Alexei Starovoitov,
	Arnaldo Carvalho de Melo

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools lib bpf: Use official ELF e_machine value
  2016-07-18  6:01 [PATCH] tools lib bpf: Use official ELF e_machine value Wang Nan
@ 2016-07-18 21:37 ` Alexei Starovoitov
  2016-07-26  2:15   ` Wangnan (F)
  2016-07-27 10:40 ` [tip:perf/urgent] " tip-bot for Wang Nan
  1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2016-07-18 21:37 UTC (permalink / raw)
  To: Wang Nan
  Cc: acme, lizefan, linux-kernel, pi3orama, Alexei Starovoitov,
	Arnaldo Carvalho de Melo, Daniel Borkmann

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools lib bpf: Use official ELF e_machine value
  2016-07-18 21:37 ` Alexei Starovoitov
@ 2016-07-26  2:15   ` Wangnan (F)
  0 siblings, 0 replies; 4+ messages in thread
From: Wangnan (F) @ 2016-07-26  2:15 UTC (permalink / raw)
  To: acme; +Cc: lizefan, linux-kernel, pi3orama

Hi Arnaldo,

Please don't forget this patch.

Thank you.

On 2016/7/19 5:37, Alexei Starovoitov wrote:
> 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>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/urgent] tools lib bpf: Use official ELF e_machine value
  2016-07-18  6:01 [PATCH] tools lib bpf: Use official ELF e_machine value Wang Nan
  2016-07-18 21:37 ` Alexei Starovoitov
@ 2016-07-27 10:40 ` tip-bot for Wang Nan
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Wang Nan @ 2016-07-27 10:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, wangnan0, hpa, ast, lizefan, mingo, acme, tglx

Commit-ID:  9b16137ab0feec00f8c9b52a63d4034a6d199d30
Gitweb:     http://git.kernel.org/tip/9b16137ab0feec00f8c9b52a63d4034a6d199d30
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Mon, 18 Jul 2016 06:01:08 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 26 Jul 2016 10:08:53 -0300

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>
---
 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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-27 10:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-18  6:01 [PATCH] tools lib bpf: Use official ELF e_machine value Wang Nan
2016-07-18 21:37 ` Alexei Starovoitov
2016-07-26  2:15   ` Wangnan (F)
2016-07-27 10:40 ` [tip:perf/urgent] " tip-bot for Wang Nan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox