Re: [PATCH] readelf: Add optional "SECTION" argument for --notes.

2019-08-26 Thread Mark Wielaard
Hi,

On Wed, 2019-08-21 at 12:32 +0200, Mark Wielaard wrote:
> There are multiple sections that can contain ELF Notes. It is sometimes
> nice to just list the notes from a specific section.
> 
>   -n, --notes[=SECTION]  Display the ELF notes

Pushed to master.


Re: [PATCH] libdw: add thread-safety to dwarf_getabbrev()

2019-08-26 Thread Mark Wielaard
Hi Jonathon,

Thanks for checking our new mailinglist settings :)
You message was accepted now and the HTML attachment stripped.

On Sun, 2019-08-25 at 20:24 -0500, Jonathon Anderson wrote:
> The one extra line in dwarf_getcfi.c
> is to account for a failure in the test suite when Valgrind is
> enabled (didn't catch it the first time around).

That is an interesting catch. And obviously a latent bug. It works if
things are in the first memblock (as part of the larger Dwarf struct),
since that is allocated with calloc, and so zeroed out. But if the cfi
would get into a later memblock it would get a random value, since
those are malloced. In your patch the memblocks are always malloced,
and so the bug shows up immediately.

Lets just cherry-pick this fixup since it is a good fixup to have.

Does the attached look correct?

Thanks,

Mark
From 4bcc641d362de4236ae8f0f5bc933c6d84b6f105 Mon Sep 17 00:00:00 2001
From: Jonathon Anderson 
Date: Sun, 25 Aug 2019 10:07:00 -0500
Subject: [PATCH] libdw: fix latent bug in dwarf_getcfi.c not setting
 default_same_value.

Signed-off-by: Jonathon Anderson 
---
 libdw/ChangeLog  | 4 
 libdw/dwarf_getcfi.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index bf1f4857..1d3586f0 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-25  Jonathon Anderson  
+
+	* dwarf_getcfi.c (dwarf_getcfi): Set default_same_value to false.
+
 2019-08-12  Mark Wielaard  
 
 	* libdw.map (ELFUTILS_0.177): Add new version of dwelf_elf_begin.
diff --git a/libdw/dwarf_getcfi.c b/libdw/dwarf_getcfi.c
index 9aed403e..51932cd9 100644
--- a/libdw/dwarf_getcfi.c
+++ b/libdw/dwarf_getcfi.c
@@ -58,6 +58,7 @@ dwarf_getcfi (Dwarf *dbg)
 
   cfi->e_ident = (unsigned char *) elf_getident (dbg->elf, NULL);
   cfi->other_byte_order = dbg->other_byte_order;
+  cfi->default_same_value = false;
 
   cfi->next_offset = 0;
   cfi->cie_tree = cfi->fde_tree = cfi->expr_tree = NULL;
-- 
2.18.1



Re: [PATCH] libdw: add thread-safety to dwarf_getabbrev()

2019-08-26 Thread Jonathon Anderson
Looks correct to me (assuming it applies). I think there's another 
latent bug in there somewhere (tests that use libdwfl used to leak 
mem_tails, but now that dwarf_begin_elf doesn't do an initial malloc it 
doesn't trigger), I'll try hunting it down when I have the time.


Glad I could be of help testing the mailinglist :)

-Jonathon

On Mon, Aug 26, 2019 at 8:18 AM, Mark Wielaard  wrote:

Hi Jonathon,

Thanks for checking our new mailinglist settings :)
You message was accepted now and the HTML attachment stripped.

On Sun, 2019-08-25 at 20:24 -0500, Jonathon Anderson wrote:

 The one extra line in dwarf_getcfi.c
 is to account for a failure in the test suite when Valgrind is
 enabled (didn't catch it the first time around).


That is an interesting catch. And obviously a latent bug. It works if
things are in the first memblock (as part of the larger Dwarf struct),
since that is allocated with calloc, and so zeroed out. But if the cfi
would get into a later memblock it would get a random value, since
those are malloced. In your patch the memblocks are always malloced,
and so the bug shows up immediately.

Lets just cherry-pick this fixup since it is a good fixup to have.

Does the attached look correct?

Thanks,

Mark


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

2019-08-26 Thread Mark Wielaard
Hi Omar,

On Tue, 2019-07-09 at 12:25 -0700, Omar Sandoval wrote:
> On Tue, Jul 09, 2019 at 09:14:03PM +0200, Mark Wielaard wrote:
> > Then after the release, somewhere next week, we'll apply your patches
> > first and can then deal with any fallout and followups. I am thinking
> > of moving some of the functionality into libdw proper (as cleaned up,
> > exported api) to reduce the size increase a little. And add a mechanism
> > for only building some of the backends (or maybe just drop some old
> > ones that nobody uses anyway).
> 
> This works for me, thanks! I'll keep an eye out for any followups,
> and I'm happy to help clean things up on the ebl side.

Obviously next week, became next month, sorry about that.
But the release is out now and new patches are streaming in already.
Would you mind rebasing your ebl work on top of git master and
reposting it?

Thanks,

Mark


[Bug libelf/23903] Uses linux specifc mremap

2019-08-26 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=23903

--- Comment #14 from Mark Wielaard  ---
Hi Jean Michault,

I am still interested getting this patch in. Could you look at comment #13 to
see if the CONTRIBUTING text makes sense and if you could provide the
tests/test-suite.log file to analyze the results a bit better.

Thanks,

Mark

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

2019-08-26 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 f1eaf14b..91790bb9 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-07-13 Mao Han 
 
* Makefile.am: Add C-SKY.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 175468f6..6470a313 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -44,6 +44,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
@@ -51,7 +52,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)
 
@@ -62,7 +62,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)
 
@@ -128,7 +127,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)
 
@@ -142,20 +140,16 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c 
csky_cfi.c \
 libebl_csky_pic_a_SOURCES = $(csky_SRCS)
 am_libebl_csky_pic_a_OBJECTS = $(csky_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.23.0



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

2019-08-26 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 | 100 +++
 configure.ac |  12 +-
 libdw/ChangeLog  |   4 +
 libdw/Makefile.am|  21 ++--
 libebl/ChangeLog |   6 +
 libebl/Makefile.am   |   1 -
 libebl/eblclosebackend.c |   4 -
 libebl/eblopenbackend.c  | 266 +++
 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(+), 308 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bed3999f..911cf354 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-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-08-13  Mark Wielaard  
 
* configure.ac: Set version to 0.177.
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 3faee13e..3f5f9bb0 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-07-13 Mao Han 
 
diff --git a/backends/Makefile.am b/backends/Makefile.am
index be470528..f4052125 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -28,96 +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 csky
-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\
-libebl_csky_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

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

2019-08-26 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 bb91c152..a772ffa3 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,7 @@
+2019-07-05  Omar Sandoval  
+
+   * Makefile.am (gen_SOURCES): Remove.
+
 2019-04-29 Mao Han 
 
* eblopenbackend.c: Add C-SKY.
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.23.0



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

2019-08-26 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 91790bb9..3faee13e 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-07-13 Mao Han 
 
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 6470a313..be470528 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -44,7 +44,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-08-25  Jonathon Anderson  
 
* dwarf_getcfi.c (dwarf_getcfi): Set default_same_value to false.
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 a772ffa3..3a836c89 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-04-29 Mao Han 
 
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.23.0



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

2019-08-26 Thread Omar Sandoval
From: Omar Sandoval 

This is a rebase of my previously posted series [1][2].

Besides the rebase, the only other change is dropping patch 5, which we
agreed is not necessary.

Thanks!

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

Omar Sandoval (4):
  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

 ChangeLog|   6 +
 Makefile.am  |   4 +-
 backends/ChangeLog   |   6 +
 backends/Makefile.am | 106 +++-
 configure.ac |  12 +-
 libcpu/ChangeLog |   6 +
 libcpu/Makefile.am   |  24 ++--
 libdw/ChangeLog  |   8 ++
 libdw/Makefile.am|  21 ++--
 libebl/ChangeLog |  12 ++
 libebl/Makefile.am   |  46 +++
 libebl/eblclosebackend.c |   4 -
 libebl/eblopenbackend.c  | 266 +++
 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 +-
 20 files changed, 261 insertions(+), 343 deletions(-)

-- 
2.23.0



[PATCH] Add elfclassify to .gitignore

2019-08-26 Thread Omar Sandoval
From: Omar Sandoval 

The tool was just added, but it's missing the ignore entry.

Signed-off-by: Omar Sandoval 
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index e8201dcc..72f22855 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ Makefile.in
 /po/stamp-po
 /src/addr2line
 /src/ar
+/src/elfclassify
 /src/elfcmp
 /src/elfcompress
 /src/elflint
-- 
2.23.0



Re: [PATCH] libdw: add thread-safety to dwarf_getabbrev()

2019-08-26 Thread Jonathon Anderson

Hello Mark,

Just finished some modifications to the patch series, git request-pull 
output below. This rebases onto the latest master and does a little 
diff cleaning, the major change is that I swapped out the memory 
management to use the pthread_key_* alternative mentioned before. I did 
some performance testing and found it to be notably faster in a 
high-stress microbenchmark (and no measurable difference in an 
application), and it makes the result easier to read overall. I've also 
removed the Valgrind configuration options patch since it doesn't add 
anything at the moment, if it becomes useful I'll submit it separately.


Thanks for taking the time to read through everything.

-Jonathon

The following changes since commit 
4bcc641d362de4236ae8f0f5bc933c6d84b6f105:


 libdw: fix latent bug in dwarf_getcfi.c not setting 
default_same_value. (2019-08-26 15:15:34 +0200)


are available in the Git repository at:

 https://github.com/blue42u/elfutils.git parallel-pr-v2

for you to fetch changes up to 1191d9ed292b508d732973a318a01051053e0f61:

 lib + libdw: Add and use a concurrent version of the dynamic-size 
hash table. (2019-08-26 22:29:45 -0500)



Jonathon Anderson (2):
 Add some supporting framework for C11-style atomics.
 libdw: Rewrite the memory handler to be thread-safe.

Srđan Milaković (1):
 lib + libdw: Add and use a concurrent version of the dynamic-size 
hash table.


configure.ac |  12 ++
lib/ChangeLog|  11 ++
lib/Makefile.am  |   5 +-
lib/atomics.h|  37 +
lib/dynamicsizehash_concurrent.c | 522 
++

lib/dynamicsizehash_concurrent.h | 118 +
lib/stdatomic-fbsd.h | 442 
+

libdw/ChangeLog  |  12 ++
libdw/Makefile.am|   4 +-
libdw/dwarf_abbrev_hash.c|   2 +-
libdw/dwarf_abbrev_hash.h|   2 +-
libdw/dwarf_begin_elf.c  |  12 +-
libdw/dwarf_end.c|   7 +-
libdw/libdwP.h   |  59 ---
libdw/libdw_alloc.c  |   5 +-
15 files changed, 1210 insertions(+), 40 deletions(-)
create mode 100644 lib/atomics.h
create mode 100644 lib/dynamicsizehash_concurrent.c
create mode 100644 lib/dynamicsizehash_concurrent.h
create mode 100644 lib/stdatomic-fbsd.h

On Mon, Aug 26, 2019 at 8:37 AM, Jonathon Anderson  
wrote:
Looks correct to me (assuming it applies). I think there's another 
latent bug in there somewhere (tests that use libdwfl used to leak 
mem_tails, but now that dwarf_begin_elf doesn't do an initial malloc 
it doesn't trigger), I'll try hunting it down when I have the time.


Glad I could be of help testing the mailinglist :)

-Jonathon

On Mon, Aug 26, 2019 at 8:18 AM, Mark Wielaard  wrote:

Hi Jonathon,

Thanks for checking our new mailinglist settings :)
You message was accepted now and the HTML attachment stripped.

On Sun, 2019-08-25 at 20:24 -0500, Jonathon Anderson wrote:

 The one extra line in dwarf_getcfi.c
 is to account for a failure in the test suite when Valgrind is
 enabled (didn't catch it the first time around).


That is an interesting catch. And obviously a latent bug. It works if
things are in the first memblock (as part of the larger Dwarf 
struct),
since that is allocated with calloc, and so zeroed out. But if the 
cfi

would get into a later memblock it would get a random value, since
those are malloced. In your patch the memblocks are always malloced,
and so the bug shows up immediately.

Lets just cherry-pick this fixup since it is a good fixup to have.

Does the attached look correct?

Thanks,

Mark