elfutils 0.193 released

2025-04-25 Thread Aaron Merey
: Improved handling of corrupt ELF data. --section-headers output now includes a "Key to Flags" explaining section flag meanings. * GIT SHORTLOG * Aaron Merey (22): configure.ac: Fix ENABLE_IMA_VERIFICATION conditional tests/.gitignore: Add newzdata strip: Ignore --reloc

Re: [PATCH v6 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-25 Thread Aaron Merey
On Fri, Apr 25, 2025 at 10:56 AM Serhei Makarov wrote: > > Changes for v6: > > - Minor fixes as requested. > > Changes for v2: > > - Merged commit 11 into commit 1 (both sample_base_addr/sample_pc and > set_initial_registers_sample make sense to introduce in the same > commit). > > - Added i38

Re: [PATCH v5 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-25 Thread Aaron Merey
On Fri, Apr 25, 2025 at 9:56 AM Serhei Makarov wrote: > > > > On Fri, Apr 25, 2025, at 1:57 AM, Aaron Merey wrote: > > Also if you haven't done so already, please run any manual tests under > > valgrind memcheck (and helgrind if you are able to test this with

Re: [PATCH v5 12/12] eu-stacktrace [12/12]: use dwflst_perf_sample_getframes

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:52 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > Changes for v3: > > - Fix initialization of elf in sysprof_init_dwfl > (previously triggered -Wmaybe-uninitialized). > > * * * > > Remove the code from src/stacktrac

Re: [PATCH v5 11/12] libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:53 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > Changes for v3: > > - use const void *stack, not void *, to allow users > to pass a const stack sample > > Changes for v2: > > - use renamed __libdwfl_set_initial_re

Re: [PATCH v5 10/12] eu-stacktrace [10/12]: use dwflst_tracker_find_pid

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:49 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > * * * > > Initial minimal change to ensure dwflst_tracker_find_pid is > tested. For now, we keep the additional dwfltab implementation in > stacktrace.c, since it's be

Re: [PATCH v5 09/12] libdwfl_stacktrace [9/12]: add dwflst_tracker_find_pid

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:49 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > Changes for v2: > > - Add locking for dwfltab. > > * * * > > New function that retrieves the Dwfl for a particular PID, or, > if the Dwfl is absent, creates it via a p

Re: [PATCH v5 08/12] libdwfl_stacktrace [8/12]: Dwfl* caching via Dwflst_Process_Tracker

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:52 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > Changes for v3: > > - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. > > * * * > > The Dwflst_Process_Tracker also includes a dynamicsizehash

Re: [PATCH v5 07/12] eu-stacktrace [7/12]: use Dwflst_Process_Tracker for Elf * caching

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:50 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > * * * > > * src/Makefile.am (AM_CPPFLAGS): Include headers from > ../libdwfl_stacktrace. > * src/stacktrace.c (tracker): New global variable. > (sample_callbacks):

Re: [PATCH v5 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:52 PM Serhei Makarov wrote: > > Changes for v5: > > - Bugfixes in dwflst_tracker_find_elf.c. > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() > interface instead of editing the

Re: [PATCH v5 05/12] libdwfl_stacktrace [5/12]: introduce Dwflst_Process_Tracker

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:48 PM Serhei Makarov wrote: > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > * * * > > New data structure to coordinate caching Elf data among multiple Dwfl > structs attached to different processes. Meant to reduce the overhead > for profilers

Re: [PATCH v5 04/12] libdwfl_stacktrace [4/12]: intro library, add dwflst_perf_sample_preferred_regs_mask

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:50 PM Serhei Makarov wrote: > > Changes for v5: > > - Separate ELFUTILS_0.193_EXPERIMENTAL namespace, mark library experimental. > > Changes for v4: > > - Separate out libdwfl_stacktrace, as requested. > > Changes for v2: > > - guard the linux/perf_events.h include proper

Re: [PATCH v5 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:48 PM Serhei Makarov wrote: > > Changes for v4: > > - Since __libdwfl_set_initial_registers_thread is now private to > libdwfl, the modified code in this patch has been disabled. > > * * * > > Dummy commit to show how the sample_set_initial_registers callback in > eu-st

Re: [PATCH v5 02/12] libdwfl [2/12]: expose setfunc callback for libdwflP+libebl clients

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:48 PM Serhei Makarov wrote: > > Changes for v2: > > - No longer exposing this in public libdwfl.h api. > > * * * > > Renaming pid_set_initial_registers to > __libdwfl_set_initial_registers_thread and adding to libdwflP.h. > > This callback was private to one file, but now

Re: [PATCH v5 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-24 Thread Aaron Merey
On Thu, Apr 24, 2025 at 5:49 PM Serhei Makarov wrote: > > Changes for v2: > > - Merged commit 11 into commit 1 (both sample_base_addr/sample_pc and > set_initial_registers_sample make sense to introduce in the same > commit). > > - Added i386 backend and factored out common code. > > * * * > >

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Aaron Merey
On Tue, Apr 22, 2025 at 10:24 AM Serhei Makarov wrote: > > On Tue, Apr 22, 2025, at 10:17 AM, Aaron Merey wrote: > >> One question this raises re: the Dwfl_Process_Tracker structure and where > >> its implementation should be located. In the patches, the Dwfl struct >

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Aaron Merey
On Tue, Apr 22, 2025 at 9:53 AM Serhei Makarov wrote: > On Tue, Apr 22, 2025, at 9:45 AM, Aaron Merey wrote: > > > > Let's move the process_tracker interface as well for additional > > flexibility to modify if needed. As for a name, I like > > libdwfl_stacktr

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Aaron Merey
Hi Serhei, On Tue, Apr 22, 2025 at 9:27 AM Serhei Makarov wrote: > > On Mon, Apr 21, 2025, at 12:29 AM, Aaron Merey wrote:. > > > > I know we're close to the next release and I do want this work to be > > included. My proposal is to move the current API out of libdw

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-20 Thread Aaron Merey
Hi Serhei, On Thu, Mar 20, 2025 at 9:24 AM Serhei Makarov wrote: > > On Wed, Mar 19, 2025, at 5:36 PM, Mark Wielaard wrote: > > > > On Sun, Mar 16, 2025 at 07:14:11PM -0400, Serhei Makarov wrote: > >> Since libebl is a private interface, subsequent patches in the series > >> introduce another api

[PATCH] libdw: Fix eu_search_tree TOCTOU bugs

2025-04-15 Thread Aaron Merey
f): Update macro_lock comment. (struct Dwarf_CU): Declare new mutex. libdw_findcu.c (__libdw_intern_next_unit): Initialize intern_lock. (__libdw_findcu): Adjust locking so that the first eu_tfind can be done without extra lock overhead. Signed-off-by: Aaron Merey

Re: [PATCH] libdw: Add Nim language and dwarf_srclang tests

2025-04-10 Thread Aaron Merey
Hi Mark, On Wed, Apr 2, 2025 at 8:50 AM Mark Wielaard wrote: > > DW_LANG_Nim and DW_LNAME_Nim were added to the DWARF languages. > > While adding them, and the default lower bounds, I noticed DW_LANG_V > and DW_LANG_Algol68 where missing in srclang_to_language an internal > helper function. > > T

Re: [PATCH v2] libdwfl: resolve all paths relative to sysroot

2025-04-10 Thread Aaron Merey
Hi Michal, On Tue, Apr 1, 2025 at 2:56 PM Michal Sekletar wrote: > > Whenever possible, resolve all symlinks as if the sysroot path were a > chroot environment. This prevents potential interactions with files from > the host filesystem. > > Signed-off-by: Michal Sekletar > --- > configure.ac

[PATCH] src/readelf.c: Access symbol and version data only if available

2025-04-10 Thread Aaron Merey
ed-by: Constantine Bytensky Signed-off-by: Aaron Merey --- src/readelf.c | 50 +++--- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index 5b0e7b47..0452977f 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -30

[PATCH 3/5] doc: Add elf_getbase.3

2025-04-05 Thread Aaron Merey
Signed-off-by: Aaron Merey --- doc/Makefile.am | 3 ++- doc/elf_getbase.3 | 55 +++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 doc/elf_getbase.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index 0dec1fc7..56c56b7b

Preparing for the 0.193 release on Friday April 25

2025-04-01 Thread Aaron Merey
Hi everyone, We are planning to do the 0.193 release on Friday April 25. Since the 0.192 release last October there have been 66 commits. Among these are some important bug fixes and new features. If your patch is still under review [1] or you have other patches you'd like merged before the rel

Re: [PATCH 2/3] src/readelf.c: Support concurrency for -w, --debug-dump

2025-03-31 Thread Aaron Merey
Hi Frank, On Mon, Mar 31, 2025 at 6:29 PM Frank Ch. Eigler wrote: > > > Due to significant lock contention, running eu-readelf when configured > > with --enable-thread-safety causes a major performance degradation. > > Currently, concurrency may double the runtime of eu-readelf. > > > However I t

[PATCH 4/5] doc: Add elf_hash.3

2025-03-31 Thread Aaron Merey
Signed-off-by: Aaron Merey --- doc/Makefile.am | 3 ++- doc/elf_hash.3 | 49 + 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 doc/elf_hash.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index 56c56b7b..260a3f09 100644

[PATCH 5/5] doc: Add elf_kind.3

2025-03-31 Thread Aaron Merey
Signed-off-by: Aaron Merey --- doc/Makefile.am | 3 ++- doc/elf_kind.3 | 71 + 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 doc/elf_kind.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index 260a3f09..8028acb0 100644

[PATCH 1/5] doc: Add elf_end.3

2025-03-31 Thread Aaron Merey
Signed-off-by: Aaron Merey --- doc/Makefile.am | 3 ++- doc/elf_end.3 | 71 + 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 doc/elf_end.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index c95369e9..36f1855f 100644

[PATCH 2/5] doc: Add elf_fill.3

2025-03-31 Thread Aaron Merey
Signed-off-by: Aaron Merey --- doc/Makefile.am | 3 ++- doc/elf_fill.3 | 53 + 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 doc/elf_fill.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index 36f1855f..0dec1fc7 100644

[PATCH 2/3] src/readelf.c: Support concurrency for -w, --debug-dump

2025-03-29 Thread Aaron Merey
* function pointers and args to schedule_job. Also call run_jobs if thread safety is enabled. Signed-off-by: Aaron Merey --- Due to significant lock contention, running eu-readelf when configured with --enable-thread-safety causes a major performance degradation. Currently

[PATCH 1/3] src: Add threadlib library for parallel job execution

2025-03-29 Thread Aaron Merey
. * src/threadlib.h: New file. Declares functions add_job and run_jobs. Signed-off-by: Aaron Merey --- src/Makefile.am | 17 src/threadlib.c | 253 src/threadlib.h | 34 +++ 3 files changed, 304 insertions(+) create mode

Re: [COMMITTED] libdw/libdw_findcu.c: Fix TOCTOU race condition in __libdw_findcu

2025-03-27 Thread Aaron Merey
Hi Mark, On Thu, Mar 27, 2025 at 4:51 AM Mark Wielaard wrote: > > Hi Aaron, > > On Thu, Mar 27, 2025 at 12:07:18AM -0400, Aaron Merey wrote: > > Ensure that dwarf_lock is held before accessing next_tu_offset and > > next_cu_offset. > > > > This fixes a TOCT

[COMMITTED] tests/.gitignore: Add dwarf_language_lower_bound, test-manyfuncs

2025-03-26 Thread Aaron Merey
Signed-off-by: Aaron Merey --- tests/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/.gitignore b/tests/.gitignore index f8869b40..6ae12adb 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -41,6 +41,7 @@ /dwarf_default_lower_bound /dwarfcfi

[COMMITTED] libdw/libdw_findcu.c: Fix TOCTOU race condition in __libdw_findcu

2025-03-26 Thread Aaron Merey
Ensure that dwarf_lock is held before accessing next_tu_offset and next_cu_offset. This fixes a TOCTOU bug in __libdw_findcu that causes NULL to be incorrectly returned. Signed-off-by: Aaron Merey --- libdw/libdw_findcu.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff

Re: [PATCH 3/4] libdw: Make dwarf_srclang forward compatible with DW_AT_language_name

2025-03-26 Thread Aaron Merey
Hi Mark, On Tue, Mar 11, 2025 at 6:00 AM Mark Wielaard wrote: > > For programs which use dwarf_srclang it might be useful to translate a > DW_LNAME (plus version) into a DW_LANG constant if there is no > DW_AT_language constant, but there is a DW_AT_language_name (and > DW_AT_language_version). >

Re: [PATCH 4/4] readelf: Add support for printing DW_AT_language_name DW_LNAMEs

2025-03-26 Thread Aaron Merey
Hi Mark, On Tue, Mar 11, 2025 at 6:01 AM Mark Wielaard wrote: > > Add a testfile using GCC 15 (experimental). > > * libdw/dwarf.h: Add DW_LNAME_lo_user and DW_LNAME_hi_user. > * src/readelf.c (dwarf_lname_string): New function. > (dwarf_lname_name): Likewise. >

Re: [PATCH 2/4] libdw: Add dwarf_language and dwarf_language_lower_bound functions.

2025-03-26 Thread Aaron Merey
Hi Mark, On Tue, Mar 11, 2025 at 5:59 AM Mark Wielaard wrote: > > dwarf_language returns a DW_LNAME constant for a CU Die. If the CU Die > has a DW_AT_language_name attribute dwarf_language will return it and > the DW_AT_language_version attribute value. Otherwise dwarf_language > will lookup the

Re: [PATCH 1/4] dwarf.h: Add DWARF v6 langauge attributes and DW_LNAME constants

2025-03-26 Thread Aaron Merey
Hi Mark, On Tue, Mar 11, 2025 at 5:59 AM Mark Wielaard wrote: > > https://dwarfstd.org/languages-v6.html defines the DWARF v6 language > attributes, DW_AT_language_name, DW_AT_language_version and DW_LNAME > constants as usable by pre-DWARF v6 producers and consumers. > > Also add new DW_LANG_V a

Re: [PATCH] libdwfl: resolve all paths relative to sysroot

2025-03-25 Thread Aaron Merey
Hi Michal, On Wed, Mar 19, 2025 at 2:33 PM Michal Sekletar wrote: > > Whenever possible, resolve all symlinks as if the sysroot path were a > chroot environment. This prevents potential interactions with files from > the host filesystem. > > Signed-off-by: Michal Sekletar > --- > configure.ac

[PATCH 3/9 v4] libdwP.h: Add locking to str_offsets_base_off

2025-03-17 Thread Aaron Merey
: Aaron Merey --- v3: https://patchwork.sourceware.org/project/elfutils/patch/20250220043644.2058519-3-ame...@redhat.com/ v4: simplify unlocking in str_offsets_base_off. libdw/dwarf_end.c| 1 + libdw/libdwP.h | 17 +++-- libdw/libdw_findcu.c | 1 + 3 files changed, 17

[PATCH 2/9 v4] libdw: Add locking to dwarf_getsrcfiles, dwarf_getsrclines, dwarf_macro_getsrcfiles

2025-03-16 Thread Aaron Merey
. * libdw/dwarf_macro_getsrclines.c (dwarf_macro_getsrclines): Use macro_lock. * libdw/libdwP.h (struct Dwarf): Define macro_lock. (struct Dwarf_CU): Define src_lock. * libdw/libdw_findcu.c (__libdw_intern_next_unit): Init src_lock. Signed-off-by: Aaron Merey

Re: [patch] PR31862: debuginfod client should cache received x-debuginfod-* headers

2025-03-05 Thread Aaron Merey
On Mon, Mar 3, 2025 at 10:02 PM Frank Ch. Eigler wrote: > > Hi - > > Thanks for the review! > > > On my machine memcheck reports leaks due to target_cachehdr_path > > missing a free. [...] > > Sorry! I must have sent an immediately prior version of the patch; > the following one has the missing

Re: [PATCH] libelf: Rewrite elf_scnshndx, extended index table handling

2025-02-28 Thread Aaron Merey
Hi Mark, On Sun, Feb 23, 2025 at 6:31 PM Mark Wielaard wrote: > > elf_scnshndx is a elfutils extension to libelf that given a SHT_SYMTAB > section returns the index to the corresponding SHT_SYMTAB_SHNDX > section, if it exists. This is needed when there are more than 64K > sections and there are

Re: [patch] PR31862: debuginfod client should cache received x-debuginfod-* headers

2025-02-27 Thread Aaron Merey
Hi Frank, On Fri, Feb 21, 2025 at 3:07 PM Frank Ch. Eigler wrote: > > > commit 082c0a94eed6706753e8019ce348be095deb72f9 (HEAD -> main) > Author: Frank Ch. Eigler > Date: Fri Feb 21 14:33:49 2025 -0500 > > PR31862: debuginfod: client to cache x-debuginfod-* headers > > This feature allo

[PATCH 9/9 v6] Add tests/run-eu-search-die.sh

2025-02-19 Thread Aaron Merey
From: Heather McIntyre * tests/.gitignore: Add eu_search_die. * tests/Makefile.am: Add eu_search_die, run-eu-search-die.sh. * tests/eu_search_die.c: New file. * tests/run-eu-search-die.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey

[PATCH 8/9 v6] Add tests/run-eu-search-lines.sh

2025-02-19 Thread Aaron Merey
-by: Aaron Merey Signed-off-by: Mark Wielaard --- No changes in v6. tests/.gitignore | 1 + tests/Makefile.am| 9 +- tests/eu_search_lines.c | 211 +++ tests/run-eu-search-lines.sh | 31 + 4 files changed, 249 insertions(+), 3

[PATCH 7/9 v6] Add tests/run-eu-search-macros.sh

2025-02-19 Thread Aaron Merey
Signed-off-by: Aaron Merey Signed-off-by: Mark Wielaard --- No changes in v6. tests/.gitignore | 1 + tests/Makefile.am | 8 +- tests/eu_search_macros.c | 175 ++ tests/run-eu-search-macros.sh | 28 ++ 4 files changed, 209

[PATCH 3/9 v3] libdwP.h: Add locking to str_offsets_base_off

2025-02-19 Thread Aaron Merey
: Aaron Merey --- v3 changes: This patch replaces v2 04/10. 04/10 added a lock to dwarf_offdie that was unnecessary but happened to prevent the reporting of a race condition in str_offsets_base_off. This patch addresses the source of the race condition. libdw/dwarf_end.c| 1 + libdw/libdwP.h

[PATCH 1/9 v3] Change type of dwarf_lock from rwlock to mutex

2025-02-19 Thread Aaron Merey
: Aaron Merey --- v3 changes: More specific comment for dwarf_lock declaration. lib/locks.h | 16 libdw/dwarf_begin_elf.c | 2 +- libdw/dwarf_end.c | 2 +- libdw/dwarf_formref_die.c | 4 ++-- libdw/dwarf_getalt.c | 10 +- libdw/dwarf_setalt.c

[PATCH 6/9 v6] Add tests/run-eu-search-cfi.sh

2025-02-19 Thread Aaron Merey
From: Heather McIntyre * tests/.gitignore: Add eu_search_cfi. * tests/Makefile.am: Add eu_search_cfi, run-eu-search-cfi.sh. * tests/eu_search_cfi.c: New file. * tests/run-eu-search-cfi.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey

[PATCH 4/9 v3] Add configure option --enable-helgrind

2025-02-19 Thread Aaron Merey
USE_HELGRIND is true, then include --tool=helgrind in the valgrind command that tests are run under. Signed-off-by: Aaron Merey --- v3 changes: Add --track-fds to valgrind_cmd when USE_HELGRIND is true. configure.ac | 16 ++-- tests/Makefile.am | 4 2 files

[PATCH 2/9 v3] libdw: Add locking to dwarf_getsrcfiles, dwarf_getsrclines, dwarf_macro_getsrcfiles

2025-02-19 Thread Aaron Merey
* libdw/dwarf_getsrcfiles.c (dwarf_getsrcfiles): Use dwarf_lock. * libdw/dwarf_getsrclines.c (dwarf_getsrclines): Ditto. * libdw/dwarf_macro_getsrclines.c (dwarf_macro_getsrclines): Ditto. Signed-off-by: Aaron Merey --- v3 changes: This patch replaces v2 02/10

[PATCH 5/9 v3] Add tests/thread-safety-subr.sh

2025-02-19 Thread Aaron Merey
thread-safety-subr.sh contains subroutine check_thread_safety_enabled which skips further testing when USE_LOCKS is false. * tests/Makefile.am (EXTRA_DIST): Add thread-safety-subr.sh. * tests/thread-safety-subr.sh: New file. Signed-off-by: Aaron Merey --- No changes in v3

Re: [PATCH] libdw: Simplify __libdw_getabbrev and fix dwarf_offabbrev issue

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 10:49 AM Mark Wielaard wrote: > > __libdw_getabbrev could crash on reading a bad abbrev by trying to > deallocate memory it didn't allocate itself. This could happen because > dwarf_offabbrev would supply its own memory when calling > __libdw_getabbrev. No other c

Re: [PATCH] strip: Verify symbol table is a real symbol table

2025-02-13 Thread Aaron Merey
Hi Mark, On Thu, Feb 13, 2025 at 9:04 AM Mark Wielaard wrote: > > We didn't check the symbol table referenced from the relocation table > was a real symbol table. This could cause a crash if that section > happened to be an SHT_NOBITS section without any data. Fix this by > adding an explicit che

Re: [PATCH] libelf: Handle elf_strptr on section without any data

2025-02-13 Thread Aaron Merey
Hi Mark, On Wed, Feb 12, 2025 at 6:16 PM Mark Wielaard wrote: > > In the unlikely situation that elf_strptr was called on a section with > sh_size already set, but that doesn't have any data yet we could crash > trying to verify the string to return. > > This could happen for example when a new s

Re: [PATCH] readelf: Skip trying to uncompress sections without a name

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 1:37 PM Mark Wielaard wrote: > > When combining eu-readelf -z with -x or -p to dump the data or strings > in an (corrupted ELF) unnamed numbered section eu-readelf could crash > trying to check whether the section name starts with .zdebug. Fix this > by skipping s

Re: [PATCH] readelf: Handle NULL phdr in handle_dynamic_symtab

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 1:32 PM Mark Wielaard wrote: > > A corrupt ELF file can have broken program headers, in which case > gelf_getphdr returns NULL. This could crash handle_dynamic_symtab > while searching for the PT_DYNAMIC phdr. Fix this by checking whether > gelf_phdr returns NULL.

Re: [PATCH] libelf, readelf: Use validate_str also to check dynamic symstr data

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 1:27 PM Mark Wielaard wrote: > > When dynsym/str was read through eu-readelf --dynamic by readelf > process_symtab the string data was not validated, possibly printing > unallocated memory past the end of the symstr data. Fix this by > truning the elf_strptr valid

[PATCH 06/10 v2] Add tests/thread-safety-subr.sh

2025-02-04 Thread Aaron Merey
thread-safety-subr.sh contains subroutine check_thread_safety_enabled which skips further testing when USE_LOCKS is false. * tests/Makefile.am (EXTRA_DIST): Add thread-safety-subr.sh. * tests/thread-safety-subr.sh: New file. Signed-off-by: Aaron Merey --- v2 changes: Removed

[PATCH 05/10 v2] Add configure option --enable-helgrind

2025-02-04 Thread Aaron Merey
USE_HELGRIND is true, then include --tool=helgrind in the valgrind command that tests are run under. Signed-off-by: Aaron Merey --- v2 changes: Enabing helgrind now requires enabling annotations configure.ac | 16 ++-- tests/Makefile.am | 6 +- 2 files

Re: [PATCH 4/5] tests/test-elf_cntl_gelf_getshdr.c: Close fd unconditionally

2025-02-04 Thread Aaron Merey
Hi Mark, On Mon, Feb 3, 2025 at 8:36 AM Mark Wielaard wrote: > > I think this subtly changes what is being tested here. If I remember > correctly this tests that gelf_getshdr works correctly even when the > underlying fd is closed and the file is either mmapped or elf_cntl > with ELF_C_FDREAD is

Re: [PATCH 09/10 v5] Add tests/run-eu-search-lines.sh

2025-02-04 Thread Aaron Merey
Hi Mark, On Mon, Feb 3, 2025 at 7:40 AM Mark Wielaard wrote: > > Found the issue with the patches not showing up on the list. > They were sent to elfutils-patches@ which doesn't exists... > Add elfutils-devel to the CC now. Apologies, I mixed up elfutils-devel@ and gdb-patches@. I've reposted th

[PATCH 09/10 v5] Add tests/run-eu-search-lines.sh

2025-02-04 Thread Aaron Merey
* tests/.gitignore: Add eu_search-lines. * tests/Makefile.am: Add eu_search_lines, run-eu-search-lines.sh. * tests/eu_search_lines.c: New file. tests/run-eu-search-lines.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey Signed

[PATCH 08/10 v5] Add tests/run-eu-search-macros.sh

2025-02-04 Thread Aaron Merey
* tests/.gitignore: Add eu_search_macros.sh * tests/Makefile.am: Add eu_search_macros, run-eu-search-macros.sh. * tests/eu_search_macros.c: New file. * tests/run-eu-search-macros.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey

[PATCH 07/10 v5] Add tests/run-eu-search-cfi.sh

2025-02-04 Thread Aaron Merey
From: Heather McIntyre * tests/.gitignore: Add eu_search_cfi. * tests/Makefile.am: Add eu_search_cfi, run-eu-search-cfi.sh. * tests/eu_search_cfi.c: New file. * tests/run-eu-search-cfi.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey

[PATCH 10/10 v5] Add tests/run-eu-search-die.sh

2025-02-04 Thread Aaron Merey
* tests/.gitignore: Add eu_search_die. * tests/Makefile.am: Add eu_search_die, run-eu-search-die.sh. * tests/eu_search_die.c: New file. * tests/run-eu-search-die.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey Signed-off-by: Mark

[PATCH 03/10 v2] libdw: Add locking to dwarf_getsrcfiles and dwarf_getsrclines

2025-02-04 Thread Aaron Merey
* libdw/dwarf_getsrcfiles.c (dwarf_getsrcfiles): Use dwarf_lock. * libdw/dwarf_getsrclines.c (dwarf_getsrclines): Use dwarf_lock. Signed-off-by: Aaron Merey --- v2 changes: Combined from v1 patches 04/15 and 05/15. libdw/dwarf_getsrcfiles.c | 11 +++ libdw

[PATCH 04/10 v2] dwarf_offdie.c: Add locking

2025-02-04 Thread Aaron Merey
* libdw/dwarf_offdie.c (__libdw_offdie): Use dwarf_lock. Signed-off-by: Aaron Merey --- v2 changes: Lock only for the duration of __libdw_findcu. libdw/dwarf_offdie.c | 4 1 file changed, 4 insertions(+) diff --git a/libdw/dwarf_offdie.c b/libdw/dwarf_offdie.c index 883720de

[PATCH 01/10 v2] Change type of dwarf_lock from rwlock to mutex

2025-02-04 Thread Aaron Merey
/libdw_findcu.c (__libdw_findcu): Ditto. Signed-off-by: Aaron Merey --- v2 changes: Add comments to libdwP.h locks describing which functions they're intended to cover. lib/locks.h | 16 libdw/dwarf_begin_elf.c | 2 +- libdw/dwarf_end.c | 2 +-

[PATCH 02/10 v2] dwarf_filesrc.c: Add locking

2025-02-04 Thread Aaron Merey
* libdw/dwarf_getsrclines.c (read_srcfiles): Initialize Dwarf member. * libdw/dwarf_filesrc.c (dwarf_filesrc): Use dwarf_lock. * libdw/libdwP.h (struct Dwarf_Files_s): Add Dwarf member. Signed-off-by: Aaron Merey --- v2 changes: Combined v1 patches 03/15 and 06/15

[PATCH 1/5] tests/Makefile.am: Add --track-fds=yes to valgrind_cmd

2025-01-30 Thread Aaron Merey
`valgrind --track-fds=yes` will report errors for file descriptor leaks and attempts at closing invalid file descriptors. Signed-off-by: Aaron Merey --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 8f087798

[PATCH 5/5] tests: Avoid leaking file descriptors

2025-01-30 Thread Aaron Merey
Add calls to close for all test programs that leak file descriptors in order to prevent test failures when run under valgrind --track-fds=yes. Signed-off-by: Aaron Merey --- tests/all-dwarf-ranges.c| 2 ++ tests/alldts.c | 1 + tests/dwarf-getmacros.c | 3 ++- tests/dwarf

[PATCH 3/5] tests/backtrace-subr.sh: Avoid valgrind track-fds in check_native_core

2025-01-30 Thread Aaron Merey
valgrind --track-fds=yes might incorrectly report an error due to the use of inherited file descriptors in check_native_core. Prevent this false positive by temporarily removing "--track-fds=yes" from $VALGRIND_CMD for the duration of the testrun in check_native_core. Signed-off-by: A

[PATCH 4/5] tests/test-elf_cntl_gelf_getshdr.c: Close fd unconditionally

2025-01-30 Thread Aaron Merey
test-elf_cntl_gelf_getshdr conditionally closes a file descriptor depending on a command line argument. This causes an error when run under valgrind --track-fds=yes. Fix this by unconditionally closing the fd. Signed-off-by: Aaron Merey --- tests/test-elf_cntl_gelf_getshdr.c | 20

[PATCH 2/5] libdwfl/offline.c: Avoid closing invalid fd

2025-01-30 Thread Aaron Merey
process_archive may be called with an fd argument of -1, which libelf interprets as "no file opened". However when closing the fd process_archive does not check whether the fd is valid and may attempt to close an fd of -1. Signed-off-by: Aaron Merey --- libdwfl/offline.c | 3 +

[PATCH] debuginfod-client.c: Avoid freeing uninitialized value

2025-01-24 Thread Aaron Merey
debuginfod_validate_imasig might call free on an uninitialized sig_buf due to a goto that can occur before sig_buf is set to NULL. Fix this by setting sig_buf to NULL before the goto. Signed-off-by: Aaron Merey --- debuginfod/debuginfod-client.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH] src/readelf.c: Close skel_fd

2025-01-24 Thread Aaron Merey
skel_fd is passed to create_dwfl, which calls dup() on skel_fd. create_dwfl handles closing the dup'ed fd but not the original. Ensure the original skel_fd is closed after it's passed to create_dwfl. Signed-off-by: Aaron Merey --- src/readelf.c | 8 +++- 1 file changed, 7 insert

Re: [PATCH 04/15] dwarf_getsrcfiles.c: Add locking

2025-01-23 Thread Aaron Merey
Hi Mark, > On Sun, Jan 19, 2025 at 10:20:30PM -0500, Aaron Merey wrote: > > res = __libdw_getsrcfiles (cu->dbg, debug_line_offset, > >__libdw_getcompdir (cudie), > > So is the lock to protect all paths through __libdw_getsrcf

Re: [PATCH 09/15] dwarf_onesrcline.c: Add locking

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 7:15 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:35PM -0500, Aaron Merey wrote: > > * libdw/dwarf_onesrcline.c (dwarf_onesrcline): Use dwarf_lock. > > Is this really necessary? When the user calls dwarf_onesrcline > would

Re: [PATCH 08/15] dwarf_offdie.c: Add locking

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 7:12 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:34PM -0500, Aaron Merey wrote: > > * libdw/dwarf_offdie.c (__libdw_offdie): Use dwarf_lock. > > What exactly is "protected" here? If it is just the __libdw_findcu &g

Re: [PATCH 07/15] dwarf_lineaddr.c: Add locking

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 7:08 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:33PM -0500, Aaron Merey wrote: > > * libdw/dwarf_lineaddr.c (dwarf_lineaddr): Use dwarf_lock. > > Why is this necessary? It seems this function can only be called wit

Re: [PATCH 06/15] Add Dwarf member to Dwarf_Lines and Dwarf_Files

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 7:06 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:32PM -0500, Aaron Merey wrote: > > * libdw/dwarf_getsrclines.c (read_srcfiles): Initialize dbg > > member. > > * libdw/libdwP.h (struct Dwarf_Fi

Re: [PATCH 05/15] dwarf_getsrclines.c: Add locking

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 6:35 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:31PM -0500, Aaron Merey wrote: > >else if (cu->lines == (void *) -1l) > > return -1; > > Aren't we still holding the lock here? You're right, will fix in v2. Aaron

Re: [PATCH 03/15] dwarf_filesrc.c: Add locking

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 5:10 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:29PM -0500, Aaron Merey wrote: > > * libdw/dwarf_filesrc.c (dwarf_filesrc): Use dwarf_lock. > > I didn't got this patch till I saw 06/15 Add Dwarf member to > Dwarf

Re: [PATCH 02/15] Change type of dwarf_lock from rwlock to mutex

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 4:55 PM Mark Wielaard wrote: > > On Sun, Jan 19, 2025 at 10:20:28PM -0500, Aaron Merey wrote: > > Change type of dwarf_lock to mutex in order to take advantage of > > built-in support for recursive locking. > > When/where do we need

Re: [PATCH 01/15] Add eu_search_tree_init

2025-01-23 Thread Aaron Merey
Hi Mark, On Wed, Jan 22, 2025 at 10:23 AM Mark Wielaard wrote: > On Sun, 2025-01-19 at 22:20 -0500, Aaron Merey wrote: > > * libdw/dwarf_begin_elf.c (dwarf_begin_elf): Initialize > > eu_search_trees. > > I see the same are already eu_search_tree_fini in

Re: [PATCH] libdwfl/argp-std.c: Set offline_next_address for a.out default

2025-01-21 Thread Aaron Merey
On Tue, Jan 21, 2025 at 9:02 AM Mark Wielaard wrote: > > Hi Aaron, > > On Mon, 2025-01-20 at 19:38 -0500, Aaron Merey wrote: > > If none of -e, -p or -k is given as a command line option, libdwfl > > parse_opt will use '-e a.out' as the default. > > >

[PATCH] libdwfl/argp-std.c: Set offline_next_address for a.out default

2025-01-20 Thread Aaron Merey
0. This can result in eu-addr2line failing to correctly output the line information for a given address. Fix this by setting dwfl->offline_next_address to 0 when setting up the default '-e a.out' dwfl. https://sourceware.org/bugzilla/show_bug.cgi?id=32538 Signed-off-by: Aaron Me

[PATCH 13/15 v4] Add tests/run-eu-search-macros.sh

2025-01-19 Thread Aaron Merey
Signed-off-by: Aaron Merey Signed-off-by: Mark Wielaard --- v3: https://patchwork.sourceware.org/project/elfutils/patch/20240802233847.690564-9-ame...@redhat.com/ Changes in v4: run-eu-search-tests.sh dropped and macros search_tree tests moved to run-eu-search-macros.sh. Formatting changes and

[PATCH 08/15] dwarf_offdie.c: Add locking

2025-01-19 Thread Aaron Merey
* libdw/dwarf_offdie.c (__libdw_offdie): Use dwarf_lock. Signed-off-by: Aaron Merey --- libdw/dwarf_offdie.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdw/dwarf_offdie.c b/libdw/dwarf_offdie.c index 883720de..74eac420 100644 --- a/libdw/dwarf_offdie.c +++ b/libdw

[PATCH 12/15 v4] Add tests/run-eu-search-cfi.sh

2025-01-19 Thread Aaron Merey
From: Heather McIntyre * tests/.gitignore: Add eu_search_cfi. * tests/Makefile.am: Add eu_search_cfi, run-eu-search-cfi.sh. * tests/eu_search_cfi.c: New file. * tests/run-eu-search-cfi.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey

[PATCH 09/15] dwarf_onesrcline.c: Add locking

2025-01-19 Thread Aaron Merey
* libdw/dwarf_onesrcline.c (dwarf_onesrcline): Use dwarf_lock. Signed-off-by: Aaron Merey --- libdw/dwarf_onesrcline.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libdw/dwarf_onesrcline.c b/libdw/dwarf_onesrcline.c index 5d3c3ded..1a16269a 100644 --- a

[PATCH 14/15 v4] Add tests/run-eu-search-lines.sh

2025-01-19 Thread Aaron Merey
-by: Aaron Merey Signed-off-by: Mark Wielaard --- v3: https://patchwork.sourceware.org/project/elfutils/patch/20240802233847.690564-9-ame...@redhat.com/ Changes in v4: run-eu-search-tests.sh dropped and lines search_tree tests moved to run-eu-search-lines.sh. Formatting changes and improved

[PATCH 07/15] dwarf_lineaddr.c: Add locking

2025-01-19 Thread Aaron Merey
* libdw/dwarf_lineaddr.c (dwarf_lineaddr): Use dwarf_lock. Signed-off-by: Aaron Merey --- libdw/dwarf_lineaddr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdw/dwarf_lineaddr.c b/libdw/dwarf_lineaddr.c index 4e1952d3..bf81966c 100644 --- a/libdw/dwarf_lineaddr.c +++ b

[PATCH 15/15 v4] Add tests/run-eu-search-die.sh

2025-01-19 Thread Aaron Merey
From: Heather McIntyre * tests/.gitignore: Add eu_search_die. * tests/Makefile.am: Add eu_search_die, run-eu-search-die.sh. * tests/eu_search_die.c: New file. * tests/run-eu-search-die.sh: New file. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey

[PATCH 11/15] Add tests/thread-safety-subr.sh

2025-01-19 Thread Aaron Merey
-safety-subr.sh: New file. Signed-off-by: Aaron Merey --- tests/Makefile.am | 1 + tests/thread-safety-subr.sh | 53 + 2 files changed, 54 insertions(+) create mode 100644 tests/thread-safety-subr.sh diff --git a/tests/Makefile.am b/tests

[PATCH 10/15] Add configure option --enable-helgrind

2025-01-19 Thread Aaron Merey
in the valgrind command that tests are run under. Signed-off-by: Aaron Merey --- configure.ac | 10 -- tests/Makefile.am | 6 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1da2a12c..a78cd36f 100644 --- a/configure.ac

[PATCH 06/15] Add Dwarf member to Dwarf_Lines and Dwarf_Files

2025-01-19 Thread Aaron Merey
* libdw/dwarf_getsrclines.c (read_srcfiles): Initialize dbg member. * libdw/libdwP.h (struct Dwarf_Files_s): Add Dwarf member. (struct Dwarf_Lines_s): Ditto. Signed-off-by: Aaron Merey --- libdw/dwarf_getsrclines.c | 4 libdw/libdwP.h| 2 ++ 2

  1   2   3   4   >