Re: debuginfo server progress update

2019-07-05 Thread Mark Wielaard
Hi Aaron,

On Wed, Jul 03, 2019 at 03:59:46PM -0400, Aaron Merey wrote:
> The debuginfo server, a web service that offers lightweight on-demand lookups
> of debuginfo-related data, along with its elfutils client have begun to take
> shape so I want to provide an update on where we currently are in its
> development and how to use it.
> 
> We plan on shipping debuginfo server with elfutils and it is currently
> available on the branch 'fche/dbgserver' of the elfutils git repo.

And now also simply on 'dbgserver'.
https://sourceware.org/git/?p=elfutils.git;a=shortlog;h=refs/heads/dbgserver

> The
> http web server itself is able to scan a directory tree for any debuginfo,
> executable and source files and index them by build-id. The elfutils client
> hooks into libdwfl and provides a fallback so that if the library is not able
> to locate a debuginfo file, the client, if enabled, will attempt to query
> debuginfo servers for debuginfo containing a particular build-id.
> [...]
> This time systemtap successfully acquires the debuginfo and begins running
> the probe. Although in this example everything is running locally, the server
> and the debuginfo could just as well be on a remote host.
> 
> Debuginfo server development is ongoing. Some of the features we have planned
> include a gdb client that could query debuginfo servers for debuginfo or 
> source
> code and the ability for the server to automatically search rpms for any of 
> the
> files requested by a client. We also are planning a talk/demo at GNU Cauldron
> this September in Montréal, Canada (https://gcc.gnu.org/wiki/cauldron2019).
> 
> Hopefully this helped give you a sense of how to use debuginfo server, where 
> it
> is in its development, and what is to come. Feedback is always appreciated!

I think it would be nice if there was a dbgclient binary that could be
reused by multiple clients.  It could do most of what you currently do
in libdwfl/dbgserver-client.c. It would simply take a buildid and type
(exec, dbg, src) and return a file path to the resulting file when
found (or a well defined error number when not found).

Such a dbgclient executable would make writing other clients
easier. For example dbgserver_build_id_find would simply reduce to
spawning dbgclient with the right arguments and opening the resulting
file path. Other clients, like gdb, then also don't need to implement
the caching and quering, but can also simply call dbgclient 
 and just open the resulting file.

Cheers,

Mark


Re: debuginfo server progress update

2019-07-05 Thread Aaron Merey
Hi Mark,

On Fri, Jul 5, 2019 at 12:46 PM Mark Wielaard  wrote:
>
> Hi Aaron,
>
> On Wed, Jul 03, 2019 at 03:59:46PM -0400, Aaron Merey wrote:
> > The debuginfo server, a web service that offers lightweight on-demand 
> > lookups
> > of debuginfo-related data, along with its elfutils client have begun to take
> > shape so I want to provide an update on where we currently are in its
> > development and how to use it.
> >
> > We plan on shipping debuginfo server with elfutils and it is currently
> > available on the branch 'fche/dbgserver' of the elfutils git repo.
>
> And now also simply on 'dbgserver'.
> https://sourceware.org/git/?p=elfutils.git;a=shortlog;h=refs/heads/dbgserver
>
> > The
> > http web server itself is able to scan a directory tree for any debuginfo,
> > executable and source files and index them by build-id. The elfutils client
> > hooks into libdwfl and provides a fallback so that if the library is not 
> > able
> > to locate a debuginfo file, the client, if enabled, will attempt to query
> > debuginfo servers for debuginfo containing a particular build-id.
> > [...]
> > This time systemtap successfully acquires the debuginfo and begins running
> > the probe. Although in this example everything is running locally, the 
> > server
> > and the debuginfo could just as well be on a remote host.
> >
> > Debuginfo server development is ongoing. Some of the features we have 
> > planned
> > include a gdb client that could query debuginfo servers for debuginfo or 
> > source
> > code and the ability for the server to automatically search rpms for any of 
> > the
> > files requested by a client. We also are planning a talk/demo at GNU 
> > Cauldron
> > this September in Montréal, Canada (https://gcc.gnu.org/wiki/cauldron2019).
> >
> > Hopefully this helped give you a sense of how to use debuginfo server, 
> > where it
> > is in its development, and what is to come. Feedback is always appreciated!
>
> I think it would be nice if there was a dbgclient binary that could be
> reused by multiple clients.  It could do most of what you currently do
> in libdwfl/dbgserver-client.c. It would simply take a buildid and type
> (exec, dbg, src) and return a file path to the resulting file when
> found (or a well defined error number when not found).
>
> Such a dbgclient executable would make writing other clients
> easier. For example dbgserver_build_id_find would simply reduce to
> spawning dbgclient with the right arguments and opening the resulting
> file path. Other clients, like gdb, then also don't need to implement
> the caching and quering, but can also simply call dbgclient 
>  and just open the resulting file.

I really like this suggestion, even with just elfutils and gdb clients
there will
already be too much code duplication if we don't have the client code in its own
binary. This raises questions such as whether dbgclient should be a shared
library or a command line tool, but regardless of these implementation details
you bring up an issue that needs to be addressed as the client side of debuginfo
server grows. I appreciate the feedback!

Aaron


[PATCH 1/5] libebl: remove unnecessary variable in Makefile.am

2019-07-05 Thread Omar Sandoval
From: Omar Sandoval 

gen_SOURCES is assigned to libebl_a_SOURCES and never used again. Get
rid of it.

Signed-off-by: Omar Sandoval 
---
 libebl/ChangeLog   |  4 
 libebl/Makefile.am | 39 +++
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 8a7d177f..9510f9d5 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,7 @@
+2019-07-05  Omar Sandoval  
+
+   * Makefile.am (gen_SOURCES): Remove.
+
 2019-05-30  Mark Wielaard  
 
* eblopenbackend.c (try_dlopen): New function extracted from
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 737de6b0..ccc1a31a 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -37,26 +37,25 @@ lib_LIBRARIES = libebl.a
 
 pkginclude_HEADERS = libebl.h
 
-gen_SOURCES = eblopenbackend.c eblclosebackend.c \
- eblreloctypename.c eblsegmenttypename.c \
- eblsectiontypename.c eblmachineflagname.c \
- eblsymboltypename.c ebldynamictagname.c eblsectionname.c \
- eblsymbolbindingname.c eblbackendname.c eblosabiname.c \
- eblmachineflagcheck.c eblmachinesectionflagcheck.c \
- eblreloctypecheck.c eblrelocvaliduse.c eblrelocsimpletype.c \
- ebldynamictagcheck.c eblcorenotetypename.c eblobjnotetypename.c \
- eblcorenote.c eblobjnote.c ebldebugscnp.c \
- eblgotpcreloccheck.c eblcopyrelocp.c eblsectionstripp.c \
- eblelfclass.c eblelfdata.c eblelfmachine.c \
- ebl_check_special_symbol.c eblbsspltp.c eblretval.c \
- eblreginfo.c eblnonerelocp.c eblrelativerelocp.c \
- eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c \
- ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c \
- eblstother.c eblinitreg.c ebldwarftoregno.c eblnormalizepc.c \
- eblunwind.c eblresolvesym.c eblcheckreloctargettype.c \
- ebl_data_marker_symbol.c
-
-libebl_a_SOURCES = $(gen_SOURCES)
+libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c eblreloctypename.c \
+  eblsegmenttypename.c eblsectiontypename.c \
+  eblmachineflagname.c eblsymboltypename.c \
+  ebldynamictagname.c eblsectionname.c \
+  eblsymbolbindingname.c eblbackendname.c eblosabiname.c \
+  eblmachineflagcheck.c eblmachinesectionflagcheck.c \
+  eblreloctypecheck.c eblrelocvaliduse.c \
+  eblrelocsimpletype.c ebldynamictagcheck.c \
+  eblcorenotetypename.c eblobjnotetypename.c eblcorenote.c \
+  eblobjnote.c ebldebugscnp.c eblgotpcreloccheck.c \
+  eblcopyrelocp.c eblsectionstripp.c eblelfclass.c \
+  eblelfdata.c eblelfmachine.c ebl_check_special_symbol.c \
+  eblbsspltp.c eblretval.c eblreginfo.c eblnonerelocp.c \
+  eblrelativerelocp.c eblsysvhashentrysize.c eblauxvinfo.c \
+  eblcheckobjattr.c ebl_check_special_section.c \
+  ebl_syscall_abi.c eblabicfi.c eblstother.c eblinitreg.c \
+  ebldwarftoregno.c eblnormalizepc.c eblunwind.c \
+  eblresolvesym.c eblcheckreloctargettype.c \
+  ebl_data_marker_symbol.c
 
 noinst_HEADERS = libeblP.h ebl-hooks.h
 
-- 
2.22.0



[PATCH 0/5] elfutils: don't use dlopen() for libebl modules

2019-07-05 Thread Omar Sandoval
From: Omar Sandoval 

Hello,

This series is a followup to my RFC [1]. Compared to the RFC patches,
this series adds patch 1 as a trivial cleanup, patch 3 to fix an
oversight in the RFC w.r.t. PIC object files sneaking into libdw.a, and
patch 5 to implement my suggestion for reducing the size of the elfutils
binaries by exporting libebl symbols from libdw.so. After this series,
libebl no longer uses dlopen() to find backends, and the total size of
the package is actually smaller than before (2.1 MB):

44K ./libasm/libasm.so
672K./libdw/libdw.so
120K./libelf/libelf.so
52K ./src/nm
28K ./src/size
60K ./src/strip
116K./src/elflint
28K ./src/findtextrel
36K ./src/addr2line
32K ./src/elfcmp
40K ./src/objdump
32K ./src/strings
48K ./src/ar
60K ./src/unstrip
36K ./src/stack
40K ./src/elfcompress
32K ./src/ranlib
236K./src/readelf
1.7Mtotal

If there are no issues, I'd love to see this merged, as it greatly
simplifies using libdw in environments where dlopen() is not supported.

Thanks!

1: https://sourceware.org/ml/elfutils-devel/2019-q3/msg00010.html

Omar Sandoval (5):
  libebl: remove unnecessary variable in Makefile.am
  libcpu: merge libcpu_{i386,x86_64,bpf} into one library
  Add PIC and non-PIC variants of libcpu and libebl
  Don't use dlopen() for libebl modules
  libdw: export libebl symbols

 ChangeLog|   6 +
 Makefile.am  |   4 +-
 backends/ChangeLog   |   6 +
 backends/Makefile.am | 104 +++
 configure.ac |  12 +-
 libcpu/ChangeLog |   6 +
 libcpu/Makefile.am   |  24 ++--
 libdw/ChangeLog  |   9 ++
 libdw/Makefile.am|  21 ++-
 libdw/libdw.map  |  60 -
 libebl/ChangeLog |  12 ++
 libebl/Makefile.am   |  46 ---
 libebl/eblclosebackend.c |   4 -
 libebl/eblopenbackend.c  | 267 +++
 libebl/libebl.h  |   8 +-
 libebl/libeblP.h |   3 -
 src/ChangeLog|  17 +++
 src/Makefile.am  |  21 ++-
 tests/ChangeLog  |   5 +
 tests/Makefile.am|  36 +++---
 tests/test-subr.sh   |   4 +-
 21 files changed, 331 insertions(+), 344 deletions(-)

-- 
2.22.0



[PATCH 2/5] libcpu: merge libcpu_{i386,x86_64,bpf} into one library

2019-07-05 Thread Omar Sandoval
From: Omar Sandoval 

In preparation for combining the libebl backend modules, combine all of
the libcpu backends into libcpu.a.

Signed-off-by: Omar Sandoval 
---
 backends/ChangeLog   |  4 
 backends/Makefile.am | 12 +++-
 libcpu/ChangeLog |  4 
 libcpu/Makefile.am   | 12 +---
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 6c2b47a9..219e0702 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,7 @@
+2019-07-05  Omar Sandoval  
+
+   * Makefile.am: Replace libcpu_{i386,x86_64,bpf}.a with libcpu.a.
+
 2019-04-14  Mark Wielaard  
 
* riscv_cfi.c: Fix BACKEND define.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 2126a2ec..0307da07 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -43,6 +43,7 @@ noinst_LIBRARIES = $(libebl_pic)
 noinst_DATA = $(libebl_pic:_pic.a=.so)
 
 
+libcpu = ../libcpu/libcpu.a
 libelf = ../libelf/libelf.so
 libdw = ../libdw/libdw.so
 libeu = ../lib/libeu.a
@@ -50,7 +51,6 @@ libeu = ../lib/libeu.a
 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c \
i386_initreg.c i386_unwind.c
-cpu_i386 = ../libcpu/libcpu_i386.a
 libebl_i386_pic_a_SOURCES = $(i386_SRCS)
 am_libebl_i386_pic_a_OBJECTS = $(i386_SRCS:.c=.os)
 
@@ -61,7 +61,6 @@ am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os)
 x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c x86_64_cfi.c \
  x86_64_retval.c x86_64_regs.c i386_auxv.c x86_64_syscall.c \
  x86_64_initreg.c x86_64_unwind.c x32_corenote.c
-cpu_x86_64 = ../libcpu/libcpu_x86_64.a
 libebl_x86_64_pic_a_SOURCES = $(x86_64_SRCS)
 am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os)
 
@@ -127,7 +126,6 @@ am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
 m68k_corenote_no_Wpacked_not_aligned = yes
 
 bpf_SRCS = bpf_init.c bpf_regs.c bpf_symbol.c
-cpu_bpf = ../libcpu/libcpu_bpf.a
 libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
 am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
 
@@ -137,20 +135,16 @@ libebl_riscv_pic_a_SOURCES = $(riscv_SRCS)
 am_libebl_riscv_pic_a_OBJECTS = $(riscv_SRCS:.c=.os)
 
 
-libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libeu)
+libebl_%.so libebl_%.map: libebl_%_pic.a $(libcpu) $(libelf) $(libdw) $(libeu)
@rm -f $(@:.so=.map)
$(AM_V_at)echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: 
*; };' \
  > $(@:.so=.map)
$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $(@:.map=.so) \
-   -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
+   -Wl,--whole-archive $< $(libcpu) -Wl,--no-whole-archive \
-Wl,--version-script,$(@:.so=.map),--no-undefined \
-Wl,--as-needed $(libelf) $(libdw) $(libeu)
@$(textrel_check)
 
-libebl_i386.so: $(cpu_i386)
-libebl_x86_64.so: $(cpu_x86_64)
-libebl_bpf.so: $(cpu_bpf)
-
 install: install-am install-ebl-modules
 install-ebl-modules:
$(mkinstalldirs) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)
diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index adebbef8..c0ea72ec 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,3 +1,7 @@
+2019-07-05  Omar Sandoval  
+
+   * Makefile.am: Combine libcpu_{i386,x86_64,bpf}.a into libcpu.a.
+
 2018-11-04  Mark Wielaard  
 
* bpf_disasm.c (bpf_disasm): Recognize BPF_JLT, BPF_JLE, BPF_JSLT
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 4c8778d1..a7d9f6fd 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -35,20 +35,16 @@ LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) -P$( $@T
$(AM_V_at)mv -f $@T $@
@@ -86,6 +82,8 @@ i386_gendis_LDADD = $(libeu) -lm
 
 i386_parse.h: i386_parse.c ;
 
+bpf_disasm_CFLAGS = -Wno-format-nonliteral
+
 EXTRA_DIST = defs/i386
 
 CLEANFILES += $(foreach P,i386 x86_64,$P_defs $P.mnemonics)
-- 
2.22.0



[PATCH 3/5] Add PIC and non-PIC variants of libcpu and libebl

2019-07-05 Thread Omar Sandoval
From: Omar Sandoval 

Currently, libcpu and libebl are always compiled as PIC. An upcoming
change will add the objects from libcpu.a and libebl.a to libdw.a, which
should not be PIC unless configured that way. So, make libcpu.a and
libebl.a non-PIC and add libcpu_pic.a and libebl_pic.a.

Signed-off-by: Omar Sandoval 
---
 backends/ChangeLog   |  1 +
 backends/Makefile.am |  2 +-
 libcpu/ChangeLog |  2 ++
 libcpu/Makefile.am   | 18 +-
 libdw/ChangeLog  |  4 
 libdw/Makefile.am|  2 +-
 libebl/ChangeLog |  4 +++-
 libebl/Makefile.am   |  8 +++-
 8 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 219e0702..d631417f 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,6 +1,7 @@
 2019-07-05  Omar Sandoval  
 
* Makefile.am: Replace libcpu_{i386,x86_64,bpf}.a with libcpu.a.
+   Replace libcpu.a with libcpu_pic.a.
 
 2019-04-14  Mark Wielaard  
 
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 0307da07..d1275206 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -43,7 +43,7 @@ noinst_LIBRARIES = $(libebl_pic)
 noinst_DATA = $(libebl_pic:_pic.a=.so)
 
 
-libcpu = ../libcpu/libcpu.a
+libcpu = ../libcpu/libcpu_pic.a
 libelf = ../libelf/libelf.so
 libdw = ../libdw/libdw.so
 libeu = ../lib/libeu.a
diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index c0ea72ec..883896a2 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,6 +1,8 @@
 2019-07-05  Omar Sandoval  
 
* Makefile.am: Combine libcpu_{i386,x86_64,bpf}.a into libcpu.a.
+   Make libcpu.a non-PIC by default.
+   Add libcpu_pic.a.
 
 2018-11-04  Mark Wielaard  
 
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index a7d9f6fd..88717361 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -30,15 +30,22 @@
 include $(top_srcdir)/config/eu.am
 AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-I$(srcdir)/../libdw -I$(srcdir)/../libasm
-AM_CFLAGS += $(fpic_CFLAGS) -fdollars-in-identifiers
+if BUILD_STATIC
+AM_CFLAGS += $(fpic_CFLAGS)
+endif
+AM_CFLAGS += -fdollars-in-identifiers
 LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) -P$(
+
+   * Makefile.am (libdw_so_LIBS): Replace libebl.a with libebl_pic.a.
+
 2019-05-16  Mark Wielaard  
 
* dwarf.h: Add DW_AT_GNU_numerator, DW_AT_GNU_denominator and
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 7a3d5322..7dc4cec0 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -106,7 +106,7 @@ libdw_pic_a_SOURCES =
 am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
 
 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
- ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
+ ../libdwfl/libdwfl_pic.a ../libebl/libebl_pic.a
 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
 libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
 libdw_so_SOURCES =
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 9510f9d5..6fd83471 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,6 +1,8 @@
 2019-07-05  Omar Sandoval  
 
-   * Makefile.am (gen_SOURCES): Remove.
+   * Makefile.am: Make libebl.a non-PIC by default.
+   Add libebl_pic.a.
+   (gen_SOURCES): Remove.
 
 2019-05-30  Mark Wielaard  
 
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index ccc1a31a..b85ead01 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -28,12 +28,15 @@
 ## not, see .
 ##
 include $(top_srcdir)/config/eu.am
+if BUILD_STATIC
 AM_CFLAGS += $(fpic_CFLAGS)
+endif
 AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdw -I$(srcdir)/../libasm
 VERSION = 1
 LIBEBL_SUBDIR = @LIBEBL_SUBDIR@
 
 lib_LIBRARIES = libebl.a
+noinst_LIBRARIES = libebl_pic.a
 
 pkginclude_HEADERS = libebl.h
 
@@ -57,6 +60,9 @@ libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c 
eblreloctypename.c \
   eblresolvesym.c eblcheckreloctargettype.c \
   ebl_data_marker_symbol.c
 
+libebl_pic_a_SOURCES =
+am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=.os)
+
 noinst_HEADERS = libeblP.h ebl-hooks.h
 
-CLEANFILES += $(am_libebl_pic_a_OBJECTS)
+MOSTLYCLEANFILES = $(am_libebl_pic_a_OBJECTS)
-- 
2.22.0



[PATCH 4/5] Don't use dlopen() for libebl modules

2019-07-05 Thread Omar Sandoval
From: Omar Sandoval 

Currently, architecture-specific code for libebl exists in separate
libebl_$ARCH.so libraries which libebl loads with dlopen() at runtime.
This makes it impossible to have standalone, statically-linked binaries
which use libdwfl if they depend on any architecture-specific
functionality. Additionally, when these libraries cannot be found, the
failure modes are non-obvious. So, let's get rid of libebl_$arch.so and
move it all into libdw.so/libdw.a, which simplifies things considerably.

Signed-off-by: Omar Sandoval 
---
 ChangeLog|   6 +
 Makefile.am  |   4 +-
 backends/ChangeLog   |   1 +
 backends/Makefile.am |  98 +++---
 configure.ac |  12 +-
 libdw/ChangeLog  |   4 +
 libdw/Makefile.am|  21 ++-
 libebl/ChangeLog |   6 +
 libebl/Makefile.am   |   1 -
 libebl/eblclosebackend.c |   4 -
 libebl/eblopenbackend.c  | 267 +++
 libebl/libebl.h  |   8 +-
 libebl/libeblP.h |   3 -
 src/ChangeLog|   7 +
 src/Makefile.am  |  20 +--
 tests/ChangeLog  |   5 +
 tests/Makefile.am|  36 +++---
 tests/test-subr.sh   |   4 +-
 18 files changed, 200 insertions(+), 307 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5c45cccf..49e7c858 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-05  Omar Sandoval  
+
+   * configure.ac: Get rid of --enable-libebl-subdir.
+   * Makefile.am (SUBDIRS): Reorder backends and libcpu before libebl to
+   satisfy build dependencies.
+
 2019-02-14  Mark Wielaard  
 
* configure.ac: Set version to 0.176.
diff --git a/Makefile.am b/Makefile.am
index 2ff444e7..51f54552 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,8 +27,8 @@ AM_MAKEFLAGS = --no-print-directory
 pkginclude_HEADERS = version.h
 
 # Add doc back when we have some real content.
-SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \
- backends src po tests
+SUBDIRS = config m4 lib libelf libcpu backends libebl libdwelf libdwfl libdw \
+ libasm src po tests
 
 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
 COPYING COPYING-GPLV2 COPYING-LGPLV3
diff --git a/backends/ChangeLog b/backends/ChangeLog
index d631417f..f104e8ec 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -2,6 +2,7 @@
 
* Makefile.am: Replace libcpu_{i386,x86_64,bpf}.a with libcpu.a.
Replace libcpu.a with libcpu_pic.a.
+   Combine libebl_CPU.so modules into libebl_backends{,_pic}.a.
 
 2019-04-14  Mark Wielaard  
 
diff --git a/backends/Makefile.am b/backends/Makefile.am
index d1275206..f0ecc405 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -28,95 +28,60 @@
 ## the GNU Lesser General Public License along with this program.  If
 ## not, see .
 include $(top_srcdir)/config/eu.am
+if BUILD_STATIC
+AM_CFLAGS += $(fpic_CFLAGS)
+endif
 AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
   -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw
 
+noinst_LIBRARIES = libebl_backends.a libebl_backends_pic.a
 
 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
  tilegx m68k bpf riscv
-libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a\
-libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a\
-libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
-libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
-libebl_m68k_pic.a libebl_bpf_pic.a libebl_riscv_pic.a
-noinst_LIBRARIES = $(libebl_pic)
-noinst_DATA = $(libebl_pic:_pic.a=.so)
-
-
-libcpu = ../libcpu/libcpu_pic.a
-libelf = ../libelf/libelf.so
-libdw = ../libdw/libdw.so
-libeu = ../lib/libeu.a
 
 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c \
i386_initreg.c i386_unwind.c
-libebl_i386_pic_a_SOURCES = $(i386_SRCS)
-am_libebl_i386_pic_a_OBJECTS = $(i386_SRCS:.c=.os)
 
 sh_SRCS = sh_init.c sh_symbol.c sh_corenote.c sh_regs.c sh_retval.c
-libebl_sh_pic_a_SOURCES = $(sh_SRCS)
-am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os)
 
 x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c x86_64_cfi.c \
- x86_64_retval.c x86_64_regs.c i386_auxv.c x86_64_syscall.c \
- x86_64_initreg.c x86_64_unwind.c x32_corenote.c
-libebl_x86_64_pic_a_SOURCES = $(x86_64_SRCS)
-am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os)
+ x86_64_retval.c x86_64_regs.c x86_64_syscall.c x86_64_initreg.c \
+ x86_64_unwind.c x32_corenote.c
+
 
 ia64_SRCS = ia64_init.c ia64_symbol.c ia64_regs.c ia64_retval.c
-libebl_ia64_pic_a_SOURCES = $(ia64_SRCS)
-am_libebl_ia64_pic_a_OBJECTS = $(ia64_SRCS:.c=.os)
 
 alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c alpha_regs.c \
 alpha_corenote.c alpha_auxv.c
-libebl_alpha_pic_a_SO

[PATCH 5/5] libdw: export libebl symbols

2019-07-05 Thread Omar Sandoval
From: Omar Sandoval 

The main downside of the previous change to build in all libebl backend
modules statically is that the total installed size of elfutils
increased (from 2.1 MB to 3.5 MB in my case). This is because we have to
statically link libebl and its backends into every binary. Instead,
since libebl is already linked into libdw.so, we can simply export the
libebl symbols in libdw.so for the binaries to use. This shrinks the
total size to 1.7 MB, which is smaller than where we started.

This doesn't change the status of libebl: it is still considered
internal and the API/ABI are still subject to change.

Signed-off-by: Omar Sandoval 
---
 libdw/ChangeLog |  1 +
 libdw/libdw.map | 60 -
 src/ChangeLog   | 10 +
 src/Makefile.am | 19 
 4 files changed, 79 insertions(+), 11 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 4e088688..84e03699 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -5,6 +5,7 @@
(libdw_so_LDLIBS): Remove -ldl.
(libdw.so): Remove -rpath.
(libdw_a_LIBADD): Add libebl, libebl_backends, and libcpu objects.
+   * libdw.map (ELFUTILS_0.177): New section. Add libebl symbols.
 
 2019-05-16  Mark Wielaard  
 
diff --git a/libdw/libdw.map b/libdw/libdw.map
index 55482d58..c9f69d32 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -360,4 +360,62 @@ ELFUTILS_0.173 {
 ELFUTILS_0.175 {
   global:
 dwelf_elf_begin;
-} ELFUTILS_0.173;
\ No newline at end of file
+} ELFUTILS_0.173;
+
+ELFUITLS_0.177 {
+  global:
+ebl_openbackend;
+ebl_openbackend_machine;
+ebl_openbackend_emulation;
+ebl_closebackend;
+ebl_get_elfmachine;
+ebl_get_elfclass;
+ebl_get_elfdata;
+ebl_backend_name;
+ebl_reloc_type_name;
+ebl_reloc_type_check;
+ebl_reloc_valid_use;
+ebl_reloc_simple_type;
+ebl_gotpc_reloc_check;
+ebl_segment_type_name;
+ebl_section_type_name;
+ebl_section_name;
+ebl_machine_flag_name;
+ebl_machine_flag_check;
+ebl_machine_section_flag_check;
+ebl_check_special_section;
+ebl_symbol_type_name;
+ebl_symbol_binding_name;
+ebl_dynamic_tag_name;
+ebl_dynamic_tag_check;
+ebl_check_special_symbol;
+ebl_data_marker_symbol;
+ebl_check_st_other_bits;
+ebl_osabi_name;
+ebl_core_note_type_name;
+ebl_object_note_type_name;
+ebl_object_note;
+ebl_check_object_attribute;
+ebl_check_reloc_target_type;
+ebl_debugscn_p;
+ebl_copy_reloc_p;
+ebl_none_reloc_p;
+ebl_relative_reloc_p;
+ebl_section_strip_p;
+ebl_bss_plt_p;
+ebl_sysvhash_entrysize;
+ebl_return_value_location;
+ebl_register_info;
+ebl_syscall_abi;
+ebl_abi_cfi;
+ebl_core_note;
+ebl_auxv_info;
+ebl_set_initial_registers_tid;
+ebl_frame_nregs;
+ebl_ra_offset;
+ebl_func_addr_mask;
+ebl_dwarf_to_regno;
+ebl_normalize_pc;
+ebl_unwind;
+ebl_resolve_sym_value;
+} ELFUTILS_0.175;
diff --git a/src/ChangeLog b/src/ChangeLog
index a8b1e267..2ce39db0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,9 +1,19 @@
 2019-07-05  Omar Sandoval  
 
* Makefile.am: Remove -ldl.
+   Remove libebl definition.
+   (readelf_LDADD): Remove $(libebl).
+   (nm_LDADD): Remove $(libebl).
+   (strip_LDADD): Remove $(libebl).
(elflint_LDADD): Add $(libdw).
+   Remove $(libebl).
(elfcmp_LDADD): Add $(libdw).
+   Remove $(libebl).
(objdump_LDADD): Add $(libdw).
+   Remove $(libebl).
+   (unstrip_LDADD): Remove $(libebl).
+   (stack_LDADD): Remove $(libebl).
+   (elfcompress_LDADD): Remove $(libebl).
 
 2019-06-25  Mark Wielaard  
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 42970da3..d219e8fe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,7 +47,6 @@ libasm = ../libasm/libasm.so
 libdw = ../libdw/libdw.so
 libelf = ../libelf/libelf.so
 endif
-libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a
 libeu = ../lib/libeu.a
 
 if DEMANGLE
@@ -67,22 +66,22 @@ ranlib_no_Wstack_usage = yes
 ar_no_Wstack_usage = yes
 unstrip_no_Wstack_usage = yes
 
-readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
+readelf_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+nm_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) \
   $(demanglelib)
 size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
-strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
-elflint_LDADD  = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+strip_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+elflint_LDADD  = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
 findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
 addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
-elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
-objdump_LDADD  = $(libasm) $(l