[PATCH] backends: Don't depend on linux/bpf.h to compile bpf disassembler.

2017-07-18 Thread Mark Wielaard
We only need a few constants and one structure definition from linux/bpf.
Just define those in a local lib/bpf.h file. This makes sure the bpf
disassembler is always build and included even when elfutils is build
on older GNU/Linux systems (and even on other platforms).

Signed-off-by: Mark Wielaard 
---
 ChangeLog|  5 
 NEWS |  2 ++
 backends/ChangeLog   |  7 +
 backends/Makefile.am |  5 
 backends/bpf_init.c  |  2 --
 backends/bpf_regs.c  |  6 +---
 configure.ac |  4 ---
 lib/ChangeLog|  5 
 lib/Makefile.am  |  2 +-
 lib/bpf.h| 82 
 libcpu/ChangeLog |  6 
 libcpu/Makefile.am   |  2 --
 libcpu/bpf_disasm.c  |  7 +
 tests/ChangeLog  |  4 +++
 tests/Makefile.am|  5 +---
 15 files changed, 115 insertions(+), 29 deletions(-)
 create mode 100644 lib/bpf.h

diff --git a/ChangeLog b/ChangeLog
index c9db732..b5f7095 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-18  Mark Wielaard  
+
+   * configure.ac: Don't check for linux/bpf.h.
+   * NEWS: Mention always build bpf backend.
+
 2017-07-14  Mark Wielaard  
 
* NEWS: Add 0.170 section and new strip options.
diff --git a/NEWS b/NEWS
index b69aef4..045d579 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Version 0.170
 
 strip: Add -R, --remove-section=SECTION and --keep-section=SECTION.
 
+backends: The bpf disassembler is now always build on all platforms.
+
 Version 0.169
 
 backends: Add support for EM_PPC64 GNU_ATTRIBUTES.
diff --git a/backends/ChangeLog b/backends/ChangeLog
index d628245..8ba7756 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,10 @@
+2017-07-18  Mark Wielaard  
+
+   * Makefile.am (cpu_bpf): Always define.
+   * bpf_init.c (disasm): Always hook.
+   * bpf_regs.c: Include bpf.h instead of linux/bpf.h. Don't define
+   MAX_BPF_REG.
+
 2017-06-17  Mark Wielaard  
 
* s390_initreg.c: Swap sys/ptrace.h and asm/ptrace.h include order.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index ac45a45..1193d0c 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -119,12 +119,7 @@ libebl_m68k_pic_a_SOURCES = $(m68k_SRCS)
 am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
 
 bpf_SRCS = bpf_init.c bpf_regs.c
-# The disam hook depends on this if we have linux/bpf.h.
-if HAVE_LINUX_BPF_H
 cpu_bpf = ../libcpu/libcpu_bpf.a
-else
-cpu_bpf = 
-endif
 libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
 am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
 
diff --git a/backends/bpf_init.c b/backends/bpf_init.c
index 22842e2..8ea1bc1 100644
--- a/backends/bpf_init.c
+++ b/backends/bpf_init.c
@@ -52,9 +52,7 @@ bpf_init (Elf *elf __attribute__ ((unused)),
   eh->name = "BPF";
   bpf_init_reloc (eh);
   HOOK (eh, register_info);
-#ifdef HAVE_LINUX_BPF_H
   HOOK (eh, disasm);
-#endif
 
   return MODVERSION;
 }
diff --git a/backends/bpf_regs.c b/backends/bpf_regs.c
index 180af83..1863a16 100644
--- a/backends/bpf_regs.c
+++ b/backends/bpf_regs.c
@@ -32,11 +32,7 @@
 #include 
 #include 
 
-#ifdef HAVE_LINUX_BPF_H
-#include 
-#else
-#define MAX_BPF_REG 10
-#endif
+#include "bpf.h"
 
 #define BACKEND bpf_
 #include "libebl_CPU.h"
diff --git a/configure.ac b/configure.ac
index c2c1d90..bb58f4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -385,10 +385,6 @@ else
 fi
 AC_SUBST([argp_LDADD])
 
-dnl Check if we have  for EM_BPF disassembly.
-AC_CHECK_HEADERS(linux/bpf.h)
-AM_CONDITIONAL(HAVE_LINUX_BPF_H, [test "x$ac_cv_header_linux_bpf_h" = "xyes"])
-
 dnl The directories with content.
 
 dnl Documentation.
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 1fc1a38..1f16228 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-18  Mark Wielaard  
+
+   * bpf.h: New file.
+   * Makefile.am (noinst_HEADERS): Add bpf.h
+
 2017-05-05  Mark Wielaard  
 
* printversion.c (print_version): Update copyright year.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7a65eb9..ada2030 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -38,7 +38,7 @@ libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c 
\
  color.c printversion.c
 
 noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
-md5.h sha1.h eu-config.h color.h printversion.h
+md5.h sha1.h eu-config.h color.h printversion.h bpf.h
 EXTRA_DIST = dynamicsizehash.c
 
 if !GPROF
diff --git a/lib/bpf.h b/lib/bpf.h
new file mode 100644
index 000..db80a51
--- /dev/null
+++ b/lib/bpf.h
@@ -0,0 +1,82 @@
+/* Minimal extended BPF constants as alternative for linux/bpf.h.  */
+
+#ifndef _ELFUTILS_BPF_H
+#define _ELFUTILS_BPF_H 1
+
+#include 
+
+#define BPF_CLASS(code) ((code) & 0x07)
+
+#define BPF_LD0x00
+#define BPF_LDX   0x01
+#define BPF_ST0x02
+#define BPF_STX   0x03
+#define BPF_ALU   0x04
+#define BPF_JMP   0x05
+#define BPF_RET   0x06
+#define BPF_MISC  0x07
+
+#define BPF_ALU64 0x07
+
+#d

FDE augmentation data

2017-07-18 Thread Sasha Da Rocha Pinheiro
Hi, how do I get FDE augmentation data?