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 <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Zefan Li <[email protected]>
Cc: [email protected]
---
  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 <[email protected]>



Reply via email to