]> git.ipfire.org Git - thirdparty/elfutils.git/log
thirdparty/elfutils.git
32 hours agoelfcompress: Handle shstrtab/symtab names more consistently main
Mark Wielaard [Tue, 26 May 2026 16:18:25 +0000 (18:18 +0200)] 
elfcompress: Handle shstrtab/symtab names more consistently

We track the shstrtab and symtab section names in case they need to be
renamed. These names are sometimes assigned a static string (from the
shstrtab string pool), sometimes created as a copy of an existing
string name and sometimes created by constructing a new string. This
means they might leak because they are never freed.

Fix this leak by defining the variables early (as NULL) before looping
over all sections, making sure to always assign a allocated (copy) of
the (new) name and explicitly free them at cleanup (run both on
success and failure).

This makes it easier to reason about allocation status and string
"ownership" making it easy to see there are no memory issues even in
the rare case of a .[z]debug section being used as a symtab or
shstrtab table (which is why there is no testcase, because it is
questionable whether such a file is actually valid).

* src/elfcompress.c (process_file): Define shstrtab_name,
shstrtab_newname, symtab_name and symtab_newname
early. xstrdup shstrtab_name and symtab_name if they were
assigned to a static string. Free all four strings at
cleanup.

Signed-off-by: Mark Wielaard <mark@klomp.org>
8 days agolibelf: Get orig_addralign the same way for 32/64 bit ELF in elf_compress
Mark Wielaard [Mon, 18 May 2026 16:47:21 +0000 (18:47 +0200)] 
libelf: Get orig_addralign the same way for 32/64 bit ELF in elf_compress

Depending on whether the ELF was 32 or 64 bit elf_compress would get
the original sh_addralign, as embedded in the Chdr, differenly. For
64bit ELF we would simply get the sh_addralign from the Shdr. For
32bit ELF we would take the (max) alignment of the underlying
Elf_Data, provided by __libelf_compress. Use the second method for
both since the Shdr might not have been setup yet, so what counts is
the Elf_Data alignment.

* libelf/elf_compress.c (elf_compress): Remove sh_addralign.
Set chdr.ch_addralign to orig_addralign in 64bit case.

Signed-off-by: Mark Wielaard <mark@klomp.org>
8 days agoelfcompress: Fix off-by-one sanity check
Mark Wielaard [Mon, 18 May 2026 18:14:44 +0000 (20:14 +0200)] 
elfcompress: Fix off-by-one sanity check

The elf ndx should not be bigger than, or equal to shnum. This really
should never trigger unless elf_ndx and/or elf_getshdrnum is buggy.

* src/elfcompress.c (process_file): Check ndx >= shnum.

Signed-off-by: Mark Wielaard <mark@klomp.org>
8 days agoelfcompress: Don't over allocate sections bitmap
Mark Wielaard [Mon, 18 May 2026 17:33:26 +0000 (19:33 +0200)] 
elfcompress: Don't over allocate sections bitmap

In process_file we allocate a bitmap sections to track which sections
we want to (de)compress. This allocates shnum / 8 + 1 unsigned
ints. But an unsigned int can contain more bits than just 8. In all
other places we use WORD_BITS defined as 8U * sizeof (unsigned int).
Also use WORD_BITS to calculate how many unsigned ints we need for the
sections bitmap.

* src/elfcompress.c (process_file): Use shnum / WORD_BITS + 1
to allocate sections.

Signed-off-by: Mark Wielaard <mark@klomp.org>
8 days agolibelf: Check uncompressed gnu size fits into d_size for ELF class
Mark Wielaard [Mon, 18 May 2026 15:25:18 +0000 (17:25 +0200)] 
libelf: Check uncompressed gnu size fits into d_size for ELF class

32bit ELF can only represent up to UINT32_MAX bytes in d_size. Sanity
check that the uncompressed size isn't bigger so we don't silently
truncate it.

* libelf/elf_compress_gnu.c (elf_compress_gnu): Check gsize
fits UINT32_MAX for ELFCLASS32.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 weeks agodwarf_getsrclines.c: Restore initialization of debug_str_offset
Aaron Merey [Thu, 14 May 2026 21:12:59 +0000 (17:12 -0400)] 
dwarf_getsrclines.c: Restore initialization of debug_str_offset

Prior to commit d4b0848b ("libdw: dwarf_getsrcfiles should not imply
dwarf_getsrclines") debug_str_offset was initialized with a default
value of 0.  This default initialization was removed as part of the
refactor introduced in d4b0848b.

Restore debug_str_offset's default initialization to 0.  For a
well-formed binary, it wasn't possible to use debug_str_offset
uninitialized.  The value is only relevant for line headers using
NVIDIA's CUBIN extension, in which case the real offset was always
stored in debug_str_offset before use.  However it's possible for a
malformed binary to cause uninitialized use and static analyzers
may complain about this.

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 weeks agodebuginfod: Don't trust x-debuginfod-size in debuginfod_validate_imasig
Mark Wielaard [Wed, 13 May 2026 15:56:18 +0000 (17:56 +0200)] 
debuginfod: Don't trust x-debuginfod-size in debuginfod_validate_imasig

Double check file size the server sent against the file size we
actually got in debuginfod_validate_imasig. So we check the signature
over the whole file size as we received it. Otherwise we might be
creating a hash over a shorter (possibly zero sized) data. This makes
sure the server sents a signature that should match the full file (and
not just an arbitrary shorter prefix).

* debuginfod/debuginfod-client.c (debuginfod_validate_imasig):
Call fstat on fd and check x-debuginfod-size equals received
file size.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 weeks agodebuginfod-client: Use CURLOPT_MAXREDIRS
Mark Wielaard [Wed, 13 May 2026 13:57:57 +0000 (15:57 +0200)] 
debuginfod-client: Use CURLOPT_MAXREDIRS

Guard against bad servers. Older libcurl allowed unlimited
redirects. Newer libcurl default to max 30. Explicitly set
CURLOPT_MAXREDIRS to 6 (twice the number of redirects that seems
"reasonable"). This guards against badly setup servers that keep
redirecting. https://curl.se/libcurl/c/CURLOPT_MAXREDIRS.html

* debuginfod/debuginfod-client.c (init_handle): Add
CURLOPT_MAXREDIRS curl_easy_setopt_ck.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 weeks agotests/Makefile.am: Add --track-destroy=yes to valgrind_cmd
Aaron Merey [Fri, 1 May 2026 17:11:47 +0000 (13:11 -0400)] 
tests/Makefile.am: Add --track-destroy=yes to valgrind_cmd

Add --track-destroy=yes to valgrind_cmd when --tool=helgrind.  This
reports missing pthread_{mutex,rwlock}_destroy calls when a lock is
initialized at the address of a live rwlock or mutex.

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 weeks agosrc/strip.c: Unconditionally re-iterate when preserving sh_link/sh_info
Aaron Merey [Sun, 10 May 2026 20:13:02 +0000 (16:13 -0400)] 
src/strip.c: Unconditionally re-iterate when preserving sh_link/sh_info

handle_elf may perform multiple iterations over section headers to
ensure that if a section is included in the debug file, then its
sh_link and sh_info sections are also included in the debug file.

handle_elf contains an optimization where an additional iteration may
be avoided if the sh_link or sh_info of a section marked for inclusion
in the main elf file have yet to be investigated by the current iteration.
The additional iteration is scheduled only if the loop index 'cnt' has
already passed the sh_link or sh_info.

This optimization can cause a bug where the sh_link or sh_info of
a section in the debug file may not be present in the debug file.

sh_link/sh_info cross references between .symtab and .rel.* sections
might be ordered such that .symtab is marked for stripping while iterating
over all the .rel.debug_* sections that reference .symtab in their sh_link,
resulting in no additional debug-preservation handling for .symtab.
However, it's possible later in the loop for a .rel.* section to refer
to an allocated section via sh_info and .symtab via sh_link.  In this case,
.symtab gets marked for preservation in the main elf file.  If no other
.rel.debug_* sections are encountered for the rest of the iteration, then
debug-preservation isn't triggered for .symtab.  This results in the debug
file containing a NOBITS .symtab despite .rel.debug_* sections referencing
.symtab in their sh_link.  If --reloc-debug-sections is given, a segfault
or error may occur when attempting to resolve these relocations.

Fix this by unconditionally scheduling another iteration across section
headers when an sh_link or sh_info gets flagged for inclusion in the main
elf file.

For the above case, the additional iteration will trigger debug-preservation
for .symtab upon detection that a .rel.debug_* sh_link is being kept in the
main elf file.  .symtab will then be present in both the main elf file and
debug file.

https://sourceware.org/bugzilla/show_bug.cgi?id=34097

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 weeks agobackends/i386_reloc.def: Fix entry for R_386_TLS_DESC
Sergei Zimmerman [Tue, 12 May 2026 21:11:51 +0000 (21:11 +0000)] 
backends/i386_reloc.def: Fix entry for R_386_TLS_DESC

This dynamic relocation can appear in shared libraries.

Fixes run-elflint-self.sh and run-reverse-sections-self.sh self-tests
when built with -mtls-dialect=gnu2 on i386.

Signed-off-by: Sergei Zimmerman <sergei@zimmerman.foo>
2 weeks agolibebl: Handle calloc failure in ebl_sample_perf_regs_mapping
Mark Wielaard [Mon, 4 May 2026 15:55:03 +0000 (17:55 +0200)] 
libebl: Handle calloc failure in ebl_sample_perf_regs_mapping

* libebl/eblinitreg_sample.c (ebl_sample_perf_regs_mapping):
Return false when calloc fails and only set
cached_perf_regs_mask on success.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 weeks agolibdw: Check .debug_line header field minimum_instr_len fits unit data
Mark Wielaard [Sat, 9 May 2026 16:33:36 +0000 (18:33 +0200)] 
libdw: Check .debug_line header field minimum_instr_len fits unit data

* libdw/dwarf_getsrclines.c (read_line_header): Add lineendp
check before reading minimum_instr_len byte.

Reported-by: Karan Kurani <karankurani3k@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
3 weeks agopo: Add Georgian (ka) translation
Ekaterine Papava [Tue, 5 May 2026 14:23:01 +0000 (16:23 +0200)] 
po: Add Georgian (ka) translation

ChangeLog:
* po/ka.po: New file, Georgian translation.
* po/LINGUAS: Add ka.

Signed-off-by: Ekaterine Papava <papava.e@gtu.ge>
3 weeks agolibdwfl: Fix out of memory handling in link_map.c report_r_debug
Mark Wielaard [Mon, 4 May 2026 15:26:14 +0000 (17:26 +0200)] 
libdwfl: Fix out of memory handling in link_map.c report_r_debug

In report_r_debug we don't fully handle an out of memory condition
when trying to allocate memory for the r_debug_info_module struct.
Deallocated allocated buffers and return -1 immediately instead of
trying to continue.

* libdwfl/link_map.c (report_r_debug): Call release_buffer
with -1 and return on malloc failure.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 weeks agoconfig: Remove empty /* */ comment from known-dwarf.awk
Mark Wielaard [Mon, 20 Apr 2026 10:40:50 +0000 (12:40 +0200)] 
config: Remove empty /* */ comment from known-dwarf.awk

gawk 5.4 doesn't like C++ style comments.

gawk: ../config/known-dwarf.awk:29: error: ? * + or {interval} not
      preceded by valid subpattern: /* */

It was an empty comment anyway, so just remove it.

* config/known-dwarf.awk: Remove empty C++ style comment.

Reviewed-by: Sam James <sam@gentoo.org>
Signed-off-by: Mark Wielaard <mark@klomp.org>
6 weeks agoPrepare for 0.195 elfutils-0.195
Aaron Merey [Wed, 15 Apr 2026 21:06:12 +0000 (17:06 -0400)] 
Prepare for 0.195

Set version to 0.195.
Update NEWS, elfutils.spec.in, configure.ac and printversion.c.
Regenerate po/*.po files

Signed-off-by: Aaron Merey <amerey@redhat.com>
6 weeks agoconfig/elfutils.spec.in: package gelf.3 in %files
Aaron Merey [Wed, 15 Apr 2026 17:39:00 +0000 (13:39 -0400)] 
config/elfutils.spec.in: package gelf.3 in %files

"gelf_*.3*" is the glob intended to include all gelf man pages in %files.
Man page gelf.3 was recently added and does not match the glob.  Fix
this by also including "gelf.3*" in %files.

Signed-off-by: Aaron Merey <amerey@redhat.com>
6 weeks agodoc: Update libelf.3 with gelf.h information
Aaron Merey [Mon, 10 Nov 2025 04:40:01 +0000 (23:40 -0500)] 
doc: Update libelf.3 with gelf.h information

Signed-off-by: Aaron Merey <amerey@redhat.com>
6 weeks agosrc/stacktrace.c: Enable ARM support
Serhei Makarov [Mon, 23 Mar 2026 18:53:56 +0000 (14:53 -0400)] 
src/stacktrace.c: Enable ARM support

Since we plan to replace stacktrace with stackprof (& the associated
test case) in a subsequent patchset, this is a minimal patch to
illustrate where the existing code using libdwfl_stacktrace needs to
generalize.

* configure.ac: Expand ac_cv_has_asm_x86_perf_regs_h
  to ac_cv_has_compat_asm_perf_regs_h also allowing arm/arm64.
* src/stacktrace.c: Enable for ARM architectures.
  (expected_frame_nregs): New function.
  (sp_reg_index): New function.
  (sysprof_find_dwfl): Replace hardcoded SP index with new functions.
  (sysprof_unwind_frame_cb): Likewise.
  (main): Open default_ebl backend appropriate to the current arch.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
6 weeks agobackends/: add 32-bit ARM sample_regs support
Serhei Makarov [Fri, 6 Mar 2026 20:49:45 +0000 (15:49 -0500)] 
backends/: add 32-bit ARM sample_regs support

After developing the common pieces in prior patches, adding register
sample support for another architecture is fairly predictable. Here we
add support for 32-bit ARM.

* backends/Makefile.am (arm_SRCS): Add arm_initreg_sample.c.
* backends/arm_init.c (arm_init): Add hooks for
  sample_sp_pc, perf_frame_regs_mask.
* backends/arm_initreg_sample.c: New file. Use default
  arm_set_initial_registers_sample implementation.
* backends/libebl_PERF_FLAGS.h (PERF_FRAME_REGISTERS_ARM): New
  constant describing registers needed for 32-bit arm unwinding.  Also
  define it on 64-bit arm to allow profiling programs running in 32-bit
  compatibility mode.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
6 weeks agobackends/: should use size_t n_regs_mapping for *_sample_sp_pc
Serhei Makarov [Fri, 6 Mar 2026 20:25:16 +0000 (15:25 -0500)] 
backends/: should use size_t n_regs_mapping for *_sample_sp_pc

These should have been size_t all along, matching the public
libdwfl_stacktrace dwflst_sample_getframes interface. Fix.

* backends/aarch64_initreg_sample.c (aarch64_sample_sp_pc): Fixup
  argument type for n_regs_mapping.
* backends/i386_initreg_sample.c (i386_sample_sp_pc): Fixup argument
  type for n_regs_mapping.
* backends/libebl_PERF_FLAGS.h (generic_sample_sp_pc): Fixup argument
  type for n_regs_mapping, adjust loop index var accordingly.
* backends/x86_64_initreg_sample.c (x86_64_sample_sp_pc): Fixup
  argument type for n_regs_mapping.
* libebl/ebl-hooks.h (sample_sp_pc): Fixup argument type for
  n_regs_mapping.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
6 weeks agolibebl/eblinitreg_sample.c: fix a potential off-by-one error
Serhei Makarov [Fri, 6 Mar 2026 17:21:47 +0000 (12:21 -0500)] 
libebl/eblinitreg_sample.c: fix a potential off-by-one error

I believe the way things were setup on x86 meant this never triggered
(since n_regs == n_regs_mapping, the for loop would stop at the
correct moment), but the logic here looks clearly incorrect for the
general case. Fix.

* libebl/eblinitreg_sample.c (ebl_set_initial_registers_sample):
  Be sure to break when i == n_regs_mapping, which is out of range.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
6 weeks agobackends/: fixup x86 initreg_sample to share code with aarch64
Serhei Makarov [Fri, 6 Mar 2026 17:33:49 +0000 (12:33 -0500)] 
backends/: fixup x86 initreg_sample to share code with aarch64

A bunch of x86 sample_regs code should be common across
architectures. In particular, sample_sp_pc() implementation looks to
be universally applicable apart from the register positions.

* backends/x86_initreg_sample.c (x86_sample_sp_pc): Remove in favour
  of generic_sample_sp_pc (added to libebl_PERF_FLAGS.h in prev patch).
  (x86_sample_perf_regs_mapping): This should have been an inline
  function. Fix.
* backends/i386_init.c (i386_init): Use
  __libebl_init_cached_regs_mapping.
* backends/x86_64_init.c (x86_64_init): Use
  __libebl_init_cached_regs_mapping.
* backends/i386_initreg_sample.c (i386_sample_sp_pc): Use
  generic_sample_sp_pc.
* backends/x86_64_init.c (x86_64_initreg_sample): Use
  generic_sample_sp_pc.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
6 weeks agobackends/: add aarch64 sample_regs support
Serhei Makarov [Fri, 6 Mar 2026 17:10:29 +0000 (12:10 -0500)] 
backends/: add aarch64 sample_regs support

Expanding the libdwflst support for handling perf sample_regs register
files to other architectures. First, add the pieces for aarch64.

* backends/Makefile.am (aarch64_SRCS): Add aarch64_initreg_sample.c.
* backends/aarch64_init.c (aarch64_init): Add hooks for
  set_initial_registers_sample, sample_sp_pc, perf_frame_regs_mask.
* backends/aarch64_initreg_sample.c: New file. Implement
  aarch64_set_initial_registers_sample mirroring the ptrace->dwarf_regs
  logic in aarch64_initreg.c.
* backends/libebl_PERF_FLAGS.h (PERF_FRAME_REGISTERS_AARCH64): New
  constant describing registers needed for aarch64 unwinding.
  (generic_sample_sp_pc): New inline function generalizing existing
  x86_sample_sp_pc code to any arch given sp_index and pc_index.
* libebl/eblinitreg_sample.c (ebl_sample_perf_regs_mapping): Update
  with a default implementation for arches where perf_regs and
  dwarf_regs order coincides (we just need the mapping to account for
  present/absent registers in perf_regs mask).
* libebl/eblopenbackend.c (__libebl_init_cached_regs_mapping): New
  function generalizing a bit of ARCH_init regs_mapping boilerplate.
* libebl/eblopenbackend.c (__libebl_init_cached_regs_mapping):
  Implement new function.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
6 weeks agolibdw: Recognize .debug_dwp section in scn_dwarf_type as TYPE_DWO
Mark Wielaard [Mon, 13 Apr 2026 21:30:45 +0000 (23:30 +0200)] 
libdw: Recognize .debug_dwp section in scn_dwarf_type as TYPE_DWO

dwarf_begin_elf tries to guess what type of Dwarf we have. When it
sees a .debug_dwp section it assumed it was TYPE_PLAIN instead of
TYPE_DWO and would try to find more "plain" .debug sections (ignoring
other .dwo sections). This would cause it to not detect any debug
sections in a .dwp file containing a .debug_dwp section.

* libdw/dwarf_begin_elf.c (scn_dwarf_type): Recognize
.debug_dwp or .zdebug_dwp sections.

Signed-off-by: Mark Wielaard <mark@klomp.org>
6 weeks agoelf_newdata: Make sure to set d_type to ELF_T_BYTE and d_align to one
Mark Wielaard [Mon, 13 Apr 2026 12:29:27 +0000 (14:29 +0200)] 
elf_newdata: Make sure to set d_type to ELF_T_BYTE and d_align to one

If d_align isn't explicitly set in elf_newdata it will default to
zero. This confuses elf_update when more than one Elf_Data has been
added to a (new) Elf_Section. Only the last will appear to be added.
ELF_T_BYTE happens to be zero and so d_type did appear to be setup
correctly. Also set it explicitly to show the defaults.

The elf_newdata test happened to pass because it set d_align to 1
explicitly. But would fail if it wouldn't set it. Add some extra
checks.

Also update the elf_newdata man page with the new defaults.

* libelf/elf_newdata.c (elf_newdata): Explicitly set d_type
and d_align.
* tests/newdata.c (add_section_data): Check d_buf, d_size,
d_type, d_align and d_version default values.
* doc/elf_newdata.3: Document d_align defaults to one.

Signed-off-by: Mark Wielaard <mark@klomp.org>
6 weeks agoconfig: Make known-dwarf work for DW_SECT
Mark Wielaard [Thu, 26 Mar 2026 13:43:11 +0000 (14:43 +0100)] 
config: Make known-dwarf work for DW_SECT

DW_SECT enum names end in all UPPERCASE which confuses the awk script.

* config/known-dwarf.awk: Recognize DW_SECT_ as SECT set.

Signed-off-by: Mark Wielaard <mark@klomp.org>
7 weeks agoelflint: Recognize debug dwo sections
Mark Wielaard [Thu, 9 Apr 2026 12:40:44 +0000 (14:40 +0200)] 
elflint: Recognize debug dwo sections

.debug dwo sections can include the SHF_EXCLUDE flag to indicate that
the linker shouldn't process them. Also a .debug_str.dwo section is
like a normal .debug_str section. There is no .debug_line_str.dwo
section, so that doesn't need special casing.

Add some dwo files to run-elflint-test.sh to make sure debug files
with .dwo sections aren't flagged by eu-elflint with --gnu --debug.

* src/elflint.c (special_sections): Add .debug_str.dwo.
(IS_DEBUG_DWO): New macro.
(check_sections): For IS_DEBUG_DWO files allow SHF_EXCLUDE.
* tests/run-elflint-test.sh: Add .dwo testfiles.

Signed-off-by: Mark Wielaard <mark@klomp.org>
7 weeks agodebuginfod: Add a flag to limit scan depth
Roman Bolshakov [Wed, 8 Apr 2026 02:19:56 +0000 (07:19 +0500)] 
debuginfod: Add a flag to limit scan depth

As of now the scanner may consume a lot of time, descending deep into
irrelevant directories where no build artifacts are known to be stored.

The change introduces --max-depth flag that has semantics similar to
-maxdepth in GNU find.

Signed-off-by: Roman Bolshakov <rbolshakov@ddn.com>
7 weeks agolibebl: Explicitly check Ehdr can be used in eblopenbackend
Mark Wielaard [Tue, 7 Apr 2026 13:25:53 +0000 (15:25 +0200)] 
libebl: Explicitly check Ehdr can be used in eblopenbackend

Make sure Ehdr is really read into memory, don't use internal elf
state.

* libebl/eblopenbackend.c (openbackend): Use gelf_getehdr
instead of accessing elf state ehdr field directly.

https://sourceware.org/bugzilla/show_bug.cgi?id=34007

Signed-off-by: Mark Wielaard <mark@klomp.org>
8 weeks agoreadelf: print .debug_cu_index and .debug_tu_index sections
Mark Wielaard [Mon, 23 Mar 2026 18:01:53 +0000 (19:01 +0100)] 
readelf: print .debug_cu_index and .debug_tu_index sections

DWARF Package files (.dwp) might contain a .debug_cu_index and/or
.debug_tu_index section. Print the contents of these sections. Handles
version 2 (DWARF4 + GNU Debugfission extension), version 5
(standardized) and version 6 (prelimenary, adds 64bit offsets).  Use
the existing dwp4 and dwp5 testfiles.

* src/readelf.c (options): Add cu_index to debug-dump docs.
(section_e): Add section_cu_index.
(section_all): Likewise.
(parse_opt): handle "cu_index" arg for debug-dump.
(dwarf_section_short_string): New static function.
(print_cu_index_section): Likewise.
(print_debug): Move up implicit_info and explicit_info. Only
search for skeleton file if .debug_info is needed. Handle both
.debug_cu_index and .debug_tu_index through
print_cu_index_section.
* tests/run-readelf-cu-index.sh: New test.
* tests/Makefile.am (TESTS): Add run-readelf-cu-index.sh.
(EXTRA_DIST): Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 months agodebuginfod: add metadata query by buildid
Josef Cejka [Wed, 18 Mar 2026 11:02:13 +0000 (12:02 +0100)] 
debuginfod: add metadata query by buildid

This patch extends current metadata by search by buildid.
It allows clients to query for all packages (with exact versions)
and files associated with a specific buildid.

I'd like to use the exact package versions during core dump
analysis to match them with already known issues/bugs,
to check that involved packages are reasonable up-to-date
and to identify other invalid setup, such as mixing packages
from different Linux distros.

Search by buildid prepares alternative db query, handling
of results incl. gathering results from federated servers
remains the same.
It does not search for source files or source file archives.

Signed-off-by: Josef Cejka <jcejka@suse.de>
2 months agodebuginfod: Make sure PATH_MAX exists in debuginfod-client.c
Mark Wielaard [Thu, 26 Mar 2026 12:32:18 +0000 (13:32 +0100)] 
debuginfod: Make sure PATH_MAX exists in debuginfod-client.c

Some systems (Hurd) don't define PATH_MAX (which is optional according
to POSIX). Make sure it is defined and no special linux specific
headers are used in debuginfod-client.c.

* debuginfod/debuginfod-client.c: Include limits.h instead of
linux/limits. If PATH_MAX isn't define it to 4K (the default
on GNU/Linux).

https://sourceware.org/bugzilla/show_bug.cgi?id=34016

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 months agoreadelf: Print split DWARF CU version, unit type and id
Mark Wielaard [Sat, 21 Mar 2026 22:56:58 +0000 (23:56 +0100)] 
readelf: Print split DWARF CU version, unit type and id

When printing the split units we reused the version, unit type and id
found in the skeleton unit. The version and id really should match,
but the unit type shouldn't. We could hard code the expected values,
but it is better to look them up explicitly. One testcase needed
updating to show the correct split_compile unit type.

* src/readelf.c (print_debug_units): Call dwarf_cu_die and
dwarf_cu_info to explicitly fetch split_version,
split_unit_type and split_unit_id.
* tests/run-readelf-loc.sh: Adjust Unit type.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 months agoelflint: add additional lints to LOAD, INTERP and PHDR segments
Fabian Rast [Fri, 20 Mar 2026 13:50:35 +0000 (14:50 +0100)] 
elflint: add additional lints to LOAD, INTERP and PHDR segments

* src/elflint.c (check_program_header):
- PT_PHDR may not occur more than once
- PT_INTERP must precede any loadable segment entry
- PT_LOAD entries must be sorted on the p_vaddr member

Signed-off-by: Fabian Rast <fabian.rast@tum.de>
2 months agolibdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non...
Serhei Makarov [Fri, 13 Mar 2026 15:06:03 +0000 (11:06 -0400)] 
libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non-Linux

libdwfl_stacktrace uses __libdwfl_set_initial_registers_thread but it
is wrapped by #ifdef __linux__, causing build errors on non-Linux
platforms.

* linux-pid-attach.c (__libdwfl_set_initial_registers_thread):
  Remove from inside the '#ifdef __linux__'.
* dwfl_frame_regs.c (__libdwfl_set_initial_registers_thread):
  Move here.

Tested-by: Sam James <sam@gentoo.org>
Signed-off-by: Serhei Makarov <serhei@serhei.io>
2 months agodebuginfod-client.c: Add dummy debuginfod_default_progressfn
Aaron Merey [Thu, 19 Mar 2026 14:12:18 +0000 (10:12 -0400)] 
debuginfod-client.c: Add dummy debuginfod_default_progressfn

debuginfod_default_progressfn was added without a corresponding dummy
variant, causing an error when building with --disable-debuginfod and
--enable-libdebuginfod=dummy.

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodebuginfod-find: Restore DEBUGINFOD_PROGRESS behaviour
Aaron Merey [Wed, 11 Mar 2026 14:13:54 +0000 (10:13 -0400)] 
debuginfod-find: Restore DEBUGINFOD_PROGRESS behaviour

Commit d7cb72f7 changed debuginfod-find to always set a progress
callback function in order to handle interrupts during downloading.

Previously debuginfod-find set a progressfn only when the -v command
line option was given.  If the DEBUGINFOD_PROGRESS environment variable
is set, libdebuginfod automatically sets a default progressfn as long as
no other progressfn has been set using debuginfod_set_progressfn.

Commit d7cb72f7 therefore resulted in DEBUGINFOD_PROGRESS no longer
affecting debuginfod-find when invoked without -v.

This patch restores the old behaviour: when DEBUGINFOD_PROGRESS is set
and -v is not given, the default progressfn will trigger during
downloading.

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agolibdebuginfod: Add the default progress callback function to the public API
Aaron Merey [Wed, 11 Mar 2026 14:01:38 +0000 (10:01 -0400)] 
libdebuginfod: Add the default progress callback function to the public API

Rename default_progressfn to debuginfod_default_progressfn and expose it
in libdebuginfod's public API.  Previously this function could only be
indirectly invoked by clients by setting the DEBUGINFOD_PROGRESS
environment variable and not explicitly setting a progress callback
function with debuginfod_set_progressfn.

The purpose of this change is to make debuginfod_default_progressfn
directly callable so that custom progress callback functions can
delegate progress reporting to it.

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agogelf_update_move.c: Handle ELFCLASS32 and ELFCLASS64 separately
Aaron Merey [Fri, 13 Mar 2026 21:46:48 +0000 (17:46 -0400)] 
gelf_update_move.c: Handle ELFCLASS32 and ELFCLASS64 separately

Similar to commit c460e2088, gelf_update_move does not distinguish
between ELFCLASS32 and ELFCLASS64 binaries.

The code assumes that Elf32_Move and Elf64_Move structs are the same
size but they are not. The m_info and m_poffset fields have type
uint32_t for Elf32_Move but uint64_t for Elf64_Move.

Fix this by handling ELFCLASS32 and ELFCLASS64 cases separately.

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_checksum.3
Aaron Merey [Thu, 1 Jan 2026 02:50:45 +0000 (21:50 -0500)] 
doc: Add gelf_checksum.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_auxv.3
Aaron Merey [Thu, 1 Jan 2026 02:50:44 +0000 (21:50 -0500)] 
doc: Add gelf_update_auxv.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getauxv.3
Aaron Merey [Thu, 1 Jan 2026 02:50:43 +0000 (21:50 -0500)] 
doc: Add gelf_getauxv.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getnote.3
Aaron Merey [Thu, 1 Jan 2026 02:50:42 +0000 (21:50 -0500)] 
doc: Add gelf_getnote.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_lib.3
Aaron Merey [Thu, 1 Jan 2026 02:50:41 +0000 (21:50 -0500)] 
doc: Add gelf_update_lib.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getlib.3
Aaron Merey [Thu, 1 Jan 2026 02:50:40 +0000 (21:50 -0500)] 
doc: Add gelf_getlib.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_move.3
Aaron Merey [Thu, 1 Jan 2026 02:50:39 +0000 (21:50 -0500)] 
doc: Add gelf_update_move.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getmove.3
Aaron Merey [Thu, 1 Jan 2026 02:50:38 +0000 (21:50 -0500)] 
doc: Add gelf_getmove.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_dyn.3
Aaron Merey [Thu, 1 Jan 2026 02:50:37 +0000 (21:50 -0500)] 
doc: Add gelf_update_dyn.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getdyn.3
Aaron Merey [Thu, 1 Jan 2026 02:50:36 +0000 (21:50 -0500)] 
doc: Add gelf_getdyn.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_syminfo.3
Aaron Merey [Thu, 1 Jan 2026 02:50:35 +0000 (21:50 -0500)] 
doc: Add gelf_update_syminfo.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getsyminfo.3
Aaron Merey [Thu, 1 Jan 2026 02:50:34 +0000 (21:50 -0500)] 
doc: Add gelf_getsyminfo.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_symshndx.3
Aaron Merey [Thu, 1 Jan 2026 02:50:33 +0000 (21:50 -0500)] 
doc: Add gelf_update_symshndx.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getsymshndx.3
Aaron Merey [Thu, 1 Jan 2026 02:50:32 +0000 (21:50 -0500)] 
doc: Add gelf_getsymshndx.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_update_sym.3
Aaron Merey [Thu, 1 Jan 2026 02:50:31 +0000 (21:50 -0500)] 
doc: Add gelf_update_sym.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agodoc: Add gelf_getsym.3
Aaron Merey [Thu, 1 Jan 2026 02:50:30 +0000 (21:50 -0500)] 
doc: Add gelf_getsym.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
2 months agolibelf: elf_update should make sure section zero exists
Mark Wielaard [Sat, 7 Mar 2026 14:55:48 +0000 (15:55 +0100)] 
libelf: elf_update should make sure section zero exists

elf_update might crash for 65280+ sections when section zero headers
aren't loaded. Make sure section zero is loaded before trying to write
to it.

Add testcase to tests/test-manyfuncs.c but use ELF_C_READ_MMAP_PRIVATE
to workaround https://sourceware.org/bugzilla/show_bug.cgi?id=33968

* libelf/elf32_updatenull.c (updatenull_wrlock): Call
getshdr_wrlock to load shdr.
* tests/test-manyfuncs.c (check_elf): Use elf_begin with
        ELF_C_READ_MMAP_PRIVATE if use_mmap. Call elf_update early.

https://sourceware.org/bugzilla/show_bug.cgi?id=33967

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 months agoReplace assert with eu_static_assert where possible.
Mark Wielaard [Thu, 5 Mar 2026 15:25:11 +0000 (16:25 +0100)] 
Replace assert with eu_static_assert where possible.

This moves the assert from being checked at runtime to being checked
at compile time.

* libdwfl/dwfl_segment_report_module.c (dwfl_segment_report_module):
Replace asserts with eu_static_assert.
* libdwfl/linux-core-attach.c (core_set_initial_registers):
Likewise.
* libdwfl/linux-kernel-modules.c (check_notes): Likewise.
* libebl/eblopenbackend.c (openbackend): Likewise.
* libelf/elf_begin.c (file_read_elf): Likewise.
(write_file): Likewise.
* libelf/elf_clone.c (elf_clone): Likewise.
* libelf/elf_getshdrstrndx.c (elf_getshdrstrndx): Likewise.
* libelf/elf_newscn.c (elf_newscn): Likewise.
* libelf/gelf_getauxv.c (gelf_getauxv): Likewise.
* libelf/gelf_getdyn.c (gelf_getdyn): Likewise.
* libelf/gelf_getlib.c (gelf_getlib): Likewise.
* libelf/gelf_getsym.c (gelf_getsym): Likewise.
* libelf/gelf_getsyminfo.c (gelf_getsyminfo): Likewise.
* libelf/gelf_getsymshndx.c (gelf_getsymshndx): Likewise.
* libelf/gelf_getverdaux.c (gelf_getverdaux): Likewise.
* libelf/gelf_getverdef.c (gelf_getverdef): Likewise.
* libelf/gelf_getvernaux.c (gelf_getvernaux): Likewise.
* libelf/gelf_getverneed.c (gelf_getverneed): Likewise.
* libelf/gelf_getversym.c (gelf_getversym): Likewise.
* libelf/gelf_update_syminfo.c (gelf_update_syminfo): Likewise.
* libelf/gelf_update_verdaux.c (gelf_update_verdaux): Likewise.
* libelf/gelf_update_verdef.c (gelf_update_verdef): Likewise.
* libelf/gelf_update_vernaux.c (gelf_update_vernaux): Likewise.
* libelf/gelf_update_verneed.c (gelf_update_verneed): Likewise.
* libelf/gelf_update_versym.c (gelf_update_versym): Likewise.
* libelf/note_xlate.h (elf_cvt_note): Likewise.
* libelf/version_xlate.h (elf_cvt_Verdef): Likewise.
(elf_cvt_Verneed): Likewise.
* src/arlib.c (arlib_init): Likewise.
(arlib_add_symref): Likewise.
* src/strip.c (handle_elf): Likewise.
* src/unstrip.c (adjust_relocs): Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 months agolibdwfl: Work around ET_REL files with sh_addr fields set to non-zero
Mark Wielaard [Mon, 2 Mar 2026 14:51:48 +0000 (15:51 +0100)] 
libdwfl: Work around ET_REL files with sh_addr fields set to non-zero

libdwfl tries to model the loading of modules (executables, shared
libraries, the linux kernel and/or kernel modules) in
memory. Depending on the (offline) load address it then also applies
(simple) relocations for ET_REL (object files or kernel modules). Load
addresses are normally represented through phdr segments for ET_EXEC
or ET_DYN, but for ET_REL files (which don't have phdrs) the Elf
section sh_addr fields are used.

The sh_addr fields of the ET_REL Elf images are updated in two places
__libdwfl_elf_address_range (through __libdwfl_report_elf) and
__libdwfl_relocate (through dwfl_module_getelf and
dwfl_module_getdwarf). Both rely on sh_addr being zero if no load
address has been set yet, so the address layout for each (SHF_ALLOC)
section is done only once.

Recent linux kernels use a linker script that does set the sh_addr
fields to (random, linker assigned) non-zero addresses. See commit
1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related
macros").

The sh_addr values seems unnecessary, but because they aren't zero
anymore our layout/relocation code doesn't know it still has to figure
out a "real" load value for these sections.

Introduce __libdwfl_reset_sh_addr which resets all sh_addr fields to
zero for SHF_ALLOC sections in ET_REL files.

We don't call __libdwfl_reset_sh_addr on aux_sym files (from
.gnu_debugdata) and when constructing an Elf from a core file. In all
other cases we know (or assume) that the Elf file is being opened
through libdw_open_elf (called indirectly through __libdw_open_elf,
__libdwfl_report_offline, dwfl_module_getelf and dwfl_module_getdwarf)

This technically changes the Elf that goes through libdwfl, but we
would already update the sh_addr fields for ET_REL Elf sections in
memory anyway to represent the load address as libdwfl would see
them. So this isn't really a change in behavior (it just might update
the sh_addr field twice).

* libdwfl/libdwflP.h (__libdwfl_reset_sh_addr): Define new
        internal function.
* libdwfl/relocate.c (__libdwfl_reset_sh_addr): New internal
        function.
* libdwfl/open.c (libdw_open_elf): Call __libdwfl_reset_sh_addr.
* libdwfl/dwfl_module_getdwarf.c (open_elf_file): Add comment.
(find_aux_sym): Likewise.
(find_dw): Likewise.
* libdwfl/dwfl_segment_report_module.c
(dwfl_segment_report_module): Likewise.
* libdwfl/dwfl_report_elf.c (__libdwfl_report_elf): Likewise.

https://sourceware.org/bugzilla/show_bug.cgi?id=33958

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 months agoPR33937: docs: catch up debuginfod-find / client docs to code
Frank Ch. Eigler [Tue, 3 Mar 2026 13:17:17 +0000 (08:17 -0500)] 
PR33937: docs: catch up debuginfod-find / client docs to code

Some options the code has supported forever were not documented in the
man pages, and the general client docs were a little too confident.

Signed-off-by: Frank Ch. Eigler <fche@elastic.org>
2 months agodwarf_tag.c: Protect cu->last_abbrev_offset with lock
Aaron Merey [Thu, 26 Feb 2026 18:41:27 +0000 (13:41 -0500)] 
dwarf_tag.c: Protect cu->last_abbrev_offset with lock

Acquire abbrev_lock before reading cu->last_abbrev_offset in dwarf_tag.

Also double check for abbrev hash table entry once lock is held to
avoid multiple threads attempting to populate the abbrev hash table.

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agoaarch64: Recognize SHT_AARCH64_ATTRIBUTES
Mark Wielaard [Tue, 24 Feb 2026 21:19:48 +0000 (22:19 +0100)] 
aarch64: Recognize SHT_AARCH64_ATTRIBUTES

Recognize SHT_AARCH64_ATTRIBUTES. This is enough to stop elflint
complaining about unknown section types. But doesn't implement parsing
the attributes.

* backends/aarch64_symbol.c (aarch64_section_type_name):
  New function.
* backends/aarch64_init.c (aarch64_init): Hook
        section_type_name.

https://sourceware.org/bugzilla/show_bug.cgi?id=33923

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agodwarf_begin_elf.c: Fix lock resource leak
Aaron Merey [Tue, 24 Feb 2026 21:08:07 +0000 (16:08 -0500)] 
dwarf_begin_elf.c: Fix lock resource leak

dwarf_begin_elf might free memory for a struct Dwarf after its rwlock and
mutex fields have been initialized without calling the corresponding
destroy functions to release the lock resources.

Fix this by moving lock inits to the end of the valid_p function, after
the struct Dwarf being intialized has passed all error checking.

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agodoc: Add gelf_xlatetof.3 and gelf_xlatetom.3
Aaron Merey [Thu, 1 Jan 2026 02:50:29 +0000 (21:50 -0500)] 
doc: Add gelf_xlatetof.3 and gelf_xlatetom.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agodoc: Add gelf_getchdr.3
Aaron Merey [Thu, 1 Jan 2026 02:50:28 +0000 (21:50 -0500)] 
doc: Add gelf_getchdr.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agodoc: Add gelf_update_phdr.3
Aaron Merey [Thu, 1 Jan 2026 02:50:27 +0000 (21:50 -0500)] 
doc: Add gelf_update_phdr.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agodoc: Add gelf_getphdr.3
Aaron Merey [Thu, 1 Jan 2026 02:50:26 +0000 (21:50 -0500)] 
doc: Add gelf_getphdr.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agodoc: Add gelf_fsize.3
Aaron Merey [Thu, 1 Jan 2026 02:50:25 +0000 (21:50 -0500)] 
doc: Add gelf_fsize.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agoreadelf: Fix NULL pointer dereference in process_symtab with -D flag
Samuel Dainard [Tue, 17 Feb 2026 22:07:06 +0000 (23:07 +0100)] 
readelf: Fix NULL pointer dereference in process_symtab with -D flag

When using eu-readelf with the -D (use_dynamic_segment) flag on malformed
ELF files, process_symtab can receive a NULL symstr_data pointer if
elf_getdata_rawchunk fails or the dynamic segment is malformed.

The function then dereferences symstr_data->d_buf without checking,
causing a segmentation fault.

Add NULL check before accessing symstr_data fields.

Fixes regression introduced in 0.194 where process_symtab was refactored
to handle dynamic segment symbol tables.

Signed-off-by: Samuel Dainard <sdainard@amazon.com>
3 months agoCONTRIBUTING: Add Policy on the Use of LLM-generated Content
Aaron Merey [Tue, 17 Feb 2026 19:47:41 +0000 (14:47 -0500)] 
CONTRIBUTING: Add Policy on the Use of LLM-generated Content

Such contributions are not being accepted at this time.  See
CONTRIBUTING for more information.

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agodebuginfod: add filename to archive_exception log
Michael Trapp [Tue, 17 Feb 2026 13:46:49 +0000 (14:46 +0100)] 
debuginfod: add filename to archive_exception log

The current archive_exception doesn't report the filename of a broken archive,
but this information is needed to identify the affected archive.

Fix this by adding a new archive_exception to get the following log message:

  libarchive error: _FILENAME_ cannot extract file: Truncated tar archive ...

Signed-off-by: Michael Trapp <michael.trapp@sap.com>
3 months agotests: Skip tests on non-ELF bitcode object files
Mark Wielaard [Tue, 10 Feb 2026 17:25:42 +0000 (18:25 +0100)] 
tests: Skip tests on non-ELF bitcode object files

clang with -flto produces object files that contain bitcode. This
breaks various (self) testcases that expect those .o files are ELF
files. eu-readelf, eu-nm, eu-elfline and eu-elfcompress won't work on
such files.

Add a helper function is_obj_bitcode in test-subr.sh that tests can
use to possibly skip a check on an .o file.

       * tests/test-subr.sh (is_obj_bitcode): New function.
       (testrun_on_self): Use is_obj_bitcode to possibly skip a file.
       (testrun_on_self_obj): Likewise.
       (testrun_on_self_compressed): Likewise.
       (testrun_on_self_quiet): Likewise.
       * tests/run-elfclassify-self.sh: Check if the object files are
       actually ELF files.
       * tests/run-nm-self.sh: Use is_obj_bitcode to possibly skip file.
       * tests/run-reverse-sections-self.sh: Likewise.
       * tests/run-strip-reloc-self.sh: Likewise.
       * tests/run-strip-strmerge.sh: Likewise.
       * tests/strip-reloc-subr.sh: Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agoreadelf: Don't warn for CUs with the same base addresses
Mark Wielaard [Tue, 10 Feb 2026 17:01:30 +0000 (18:01 +0100)] 
readelf: Don't warn for CUs with the same base addresses

It is valid for for two CUs to share the same base address attributes,
so don't warn for that (which also would sets the exit status to
non-zero).

* src/readelf.c (compare_listptr): Remove listptr_base check.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agoreadelf: Handle CUs that share an addr_base or str_offsets_base
Mark Wielaard [Thu, 5 Feb 2026 18:58:05 +0000 (19:58 +0100)] 
readelf: Handle CUs that share an addr_base or str_offsets_base

readelf assumed each .debug_addr and .debug_str_offsets was associated
with precisely one CU DIE. But CU DIEs can have the same
DW_AT_addr_base or DW_AT_str_offsets_base. Change the code to find the
first CU associated with the offset.

 * src/readelf.c (print_debug_addr_section): Skip CUs that
         have an addr_base already handled.
         (print_debug_str_offsets_section): Likewise for
         str_offsets_base.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agoelflint: Recognize .relro_padding section
Mark Wielaard [Mon, 9 Feb 2026 22:19:17 +0000 (23:19 +0100)] 
elflint: Recognize .relro_padding section

lld might generate a .relro_padding section, it should be WRITE|ALLOC
to be part of PT_GNU_TLS.

 * src/elflint.c (special_sections): Add .relro_padding.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agoelflint, readelf, support SHT_LLVM_LTO and SHT_LLVM_ADDRSIG
Mark Wielaard [Mon, 9 Feb 2026 22:18:40 +0000 (23:18 +0100)] 
elflint, readelf, support SHT_LLVM_LTO and SHT_LLVM_ADDRSIG

An SHT_LLVM_LTO section contains LLVM bitcode. An SHT_LLVM_ADDRSIG
section contains ULEB128 integers referring to the symbol table
indexes of address-significant symbols. This patch just recognizes the
SHT constants but doesn't handle the section contents.

 * libebl/eblsectiontypename.c (ebl_section_type_name):
 Recognize SHT_LLVM_ADDRSIG and SHT_LLVM_LTO.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agoelflint: Accept R_X86_64_DTPOFF64 in ET_REL files
Mark Wielaard [Mon, 9 Feb 2026 22:17:19 +0000 (23:17 +0100)] 
elflint: Accept R_X86_64_DTPOFF64 in ET_REL files

Normally R_X86_64_DTPOFF32, which takes a 32bit TLS offset, is used,
but R_X86_64_DTPOFF64, which takes a 64bit TLS offset may also be used
in ET_REL files.

 * backends/x86_64_reloc.def (DTPOFF64): Add REL.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agosrc/elfclassify.c: Fix memory leak in check_ar_members
Aaron Merey [Tue, 3 Feb 2026 21:31:00 +0000 (16:31 -0500)] 
src/elfclassify.c: Fix memory leak in check_ar_members

If current_path needs to be reallocated, full_path is assigned a newly
malloced buffer and then full_path is assigned to current_path.  This
leaks the previous value of full_path.

Free full_path before reassigning it.

Signed-off-by: Aaron Merey <amerey@redhat.com>
3 months agoconfigure: Add -Wdeprecated-non-prototype and -Wfree-labels if available
Mark Wielaard [Sat, 7 Feb 2026 17:25:09 +0000 (18:25 +0100)] 
configure: Add -Wdeprecated-non-prototype and -Wfree-labels if available

Calling a function with one or more arguments declared with an empty
parameter list is an error in C23. In C23 labels applied to
non-statements are allowed, but not in earlier standards (they are as
GNU extension in GCC). Add -Wdeprecated-non-prototype and
-Wfree-labels (available since GCC 15) to catch this.

            * configure.ac: Add HAVE_DEPRECATED_NON_PROTOTYPE_WARNING
    and HAVE_FREE_LABELS_WARNING check.
            * config/eu.am: Set FREE_LABELS_WARNING and
    FREE_LABELS_WARNING.
            (AM_CFLAGS): Add DEPRECATED_NON_PROTOTYPE_WARNING and
    FREE_LABELS_WARNING.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Reviewed-by: Sam James <sam@gentoo.org>
3 months agoconfigure: Add -Wmissing-parameter-name if available
Mark Wielaard [Sat, 7 Feb 2026 00:48:26 +0000 (01:48 +0100)] 
configure: Add -Wmissing-parameter-name if available

Before C23 omitting parameter names in function definitions isn't
supported. Add -Wmissing-parameter-name (available since GCC 15) to
catch this.

* configure.ac: Add HAVE_MISSING_PARAMETER_NAME_WARNING check.
* config/eu.am: Set MISSING_PARAMETER_NAME_WARNING based on
HAVE_MISSING_PARAMETER_NAME_WARNING.
(AM_CFLAGS): Add MISSING_PARAMETER_NAME_WARNING.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Reviewed-by: Sam James <sam@gentoo.org>
3 months agostacktrace: fix a C23-ism in sigint_handler
Mark Wielaard [Wed, 4 Feb 2026 14:09:06 +0000 (15:09 +0100)] 
stacktrace: fix a C23-ism in sigint_handler

clang 21 doesn't like ommitting a parameter name when not in C23 mode.

stacktrace.c:1138:44: error: omitting the parameter name in a function definition is a C23 extension [-Werror,-Wc23-extensions]
 1138 | static void sigint_handler (int /* signo */)
      |                                            ^
1 error generated.

* src/stacktrace.c (sigint_handler): Use attribute unused.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 months agoPR33854: fix regression in dwflst_perf_sample_getframes
Serhei Makarov [Thu, 29 Jan 2026 17:27:50 +0000 (12:27 -0500)] 
PR33854: fix regression in dwflst_perf_sample_getframes

In commit 3ce0d5ed, I missed the fact that
dwflst_perf_sample_getframes needs to handle the case of an unattached
Dwfl, when dwfl->process->ebl is not yet available to translate the
registers. Thus, it can't be a straightforward wrapper of
dwfl_sample_getframes, but should instead handle the attaching logic
identically to that function.

Also fix a leakage of sample_arg in dwflst_sample_getframes that was
happening on attach failure.

* libdwfl_stacktrace (dwflst_sample_getframes): Fix a leak of
  sample_arg on attach failure.
* libdwfl_stacktrace (dwflst_perf_sample_getframes): Implement
  attaching the Dwfl identically to dwflst_sample_getframes.
  Avoid leaking sample_arg on attach failure.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
3 months agoMake __libdwfl_debuginfod_find_* functions thread safe
Aaron Merey [Fri, 19 Dec 2025 22:39:36 +0000 (17:39 -0500)] 
Make __libdwfl_debuginfod_find_* functions thread safe

Individual debuginfod_client objects and their underlying CURLM handles
should not be used concurrently during calls to
__libdwfl_debuginfod_find_debuginfo and
__libdwfl_debuginfod_find_executable.

Add a mutex field to struct Dwfl to serialize calls to
__libdwfl_debuginfod_find_*.

Signed-off-by: Aaron Merey <amerey@redhat.com>
4 months agogelf_getmove.c: Handle ELFCLASS32 and ELFCLASS64 separately
Aaron Merey [Wed, 7 Jan 2026 23:43:49 +0000 (18:43 -0500)] 
gelf_getmove.c: Handle ELFCLASS32 and ELFCLASS64 separately

Currently gelf_getmove does not distinguish between ELFCLASS32 and
ELFCLASS64 binaries.  This is assumes that Elf32_Move and Elf64_Move
structs are the same size.

This assumption is false since the m_info and m_poffset fields have
type uint32_t for Elf32_Move but uint64_t for Elf64_Move.

Fix this by handling ELFCLASS32 and ELFCLASS64 cases separately when
copying Elfxx_Move fields to dst.

Signed-off-by: Aaron Merey <amerey@redhat.com>
4 months agoforge: Add a forgejo workflow to run various tests
Mark Wielaard [Sat, 20 Dec 2025 02:19:36 +0000 (03:19 +0100)] 
forge: Add a forgejo workflow to run various tests

This adds a check-debian.yaml file which will run various tests under
Debian and Fedora for new merge requests.

       * CONTRIBUTING: Explain how to contribute through the forge.
       * .forgejo/workflows/check-debian.yaml: New Debian based workflow.
       * .forgejo/workflows/check-fedora.yaml: New Fedora based workflow.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 months agotests: Disable valgrind for run-large-elf-file and run-compress-test
Mark Wielaard [Thu, 18 Dec 2025 15:35:06 +0000 (16:35 +0100)] 
tests: Disable valgrind for run-large-elf-file and run-compress-test

Both run-compress-test and run-large-elf-file create really big
files. Processing these under valgrind take a very long time. To
encourage more testing under valgrind memcheck or helgrind disable
valgrind for these two test so people don't have to wait 10 minutes
for make check results.

* tests/run-compress-test.sh: Unset VALGRIND_CMD.
* tests/run-large-elf-file.sh: Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 months agoreadelf: gcc_except_table: add newline in output
Martin Liška [Wed, 17 Dec 2025 14:39:05 +0000 (15:39 +0100)] 
readelf: gcc_except_table: add newline in output

Fixes:
```
 TType table: [   3] 0x23a4
 [   2] 0x23a8
 [   1] 0x23ac
```

to:
```
 TType table:
 [   3] 0x23a4
 [   2] 0x23a8
 [   1] 0x23ac
```

ChangeLog:

* src/readelf.c (print_debug_exception_table): Add newline after TType table header.

Signed-off-by: Martin Liska <martin.liska@hey.com>
5 months agolibelf: Add gelf_fsize main check
Mark Wielaard [Mon, 8 Dec 2025 10:44:45 +0000 (11:44 +0100)] 
libelf: Add gelf_fsize main check

This test itself isn't super interesting, it just checks that all
Elf_Types are handled by gelf_fsize and that the 32 vs 64 variant
sizes make sense. The interesting part is that it uses the internal
interface (__libelf_type_sizes) to do it. So you don't have to
contruct a whole Elf handle.

It mimics the support for "main checks" in libdw. It adds a way to
compile an individual source file with an optional main function that
can directly access the internal/static functions.

To add new main check tests you have to add an #ifdef MAIN_CHECK with
a main function that calls the test functions to the source file. And
add two make file rules after .SECONDEXPANSION. One starting with
<source_basename>_checks$(EXEEXT) and one starting with
nodist_<source_basename>_check_SOURCES.

* libelf/gelf_fsize.c: Add MAIN_CHECK part.
* libelf/Makefile.am: Add gelf_fsize main check rules.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 months agolibdw: Make sure to get .eh_frame_hdr with .eh_frame in getcfi_shdr
Mark Wielaard [Fri, 5 Dec 2025 15:27:04 +0000 (16:27 +0100)] 
libdw: Make sure to get .eh_frame_hdr with .eh_frame in getcfi_shdr

If we find a .eh_frame section we want to make sure to also get the
search table section .eh_frame_hdr. Otherwise lookups will be very
slow. Only create a Dwarf_CFI without a search table as a last resort.

* libdw/dwarf_getcfi_elf.c (getcfi_shdr): Keep iterating
        through the shdrs till both .eh_frame and .eh_frame_hdr are
        found. Check both aren't SHT_NOBITS.

https://sourceware.org/bugzilla/show_bug.cgi?id=33658

Suggested-by: Shimin Guo <shimin.guo@skydio.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
5 months agotests: improve reliability of run-sysroot.sh
Arnout Engelen [Fri, 5 Dec 2025 14:52:41 +0000 (15:52 +0100)] 
tests: improve reliability of run-sysroot.sh

Previously, the 'second' test would test the `RESOLVE_IN_ROOT` feature
when the current libc supports it, even when the currently running
kernel did not yet support it.

Signed-off-by: Arnout Engelen <arnout@bzzt.net>
5 months agoreadelf: improve output format for .gcc_except_table
Martin Liška [Tue, 9 Dec 2025 08:21:01 +0000 (09:21 +0100)] 
readelf: improve output format for .gcc_except_table

Before the change:
```
 Call site table: [   0] Call site start:   0x10
        Call site length:  12
        Landing pad:       0x2a
        Action:            3
 [   1] Call site start:   0x1c
        Call site length:  123
        Landing pad:       0
        Action:            0

 Action table: [   0] ar_filter:   1
        ar_disp:     0
 [   1] ar_filter:   2
        ar_disp:    -3    -> [   0]
```

After:
```
 Call site table:
 [   0] Call site start:   0x10
        Call site length:  12
        Landing pad:       0x2a
        Action:            3
 [   1] Call site start:   0x1c
        Call site length:  123
        Landing pad:       0
        Action:            0

 Action table:
 [   0] ar_filter:   1
        ar_disp:     0
 [   1] ar_filter:   2
        ar_disp:    -3    -> [   0]
```

ChangeLog:

* src/readelf.c (print_debug_exception_table): Add newlines.

Signed-off-by: Martin Liska <martin.liska@hey.com>
5 months agoPR33635: Introduce debuginfod --home-redirect and --home-html
Martin Cermak [Fri, 5 Dec 2025 13:33:57 +0000 (14:33 +0100)] 
PR33635: Introduce debuginfod --home-redirect and --home-html

NEWS: New entry
debuginfod/debuginfod.cxx: Feature implementation
doc/debuginfod.8: Doc text
tests/Makefile.am: New testcase
tests/run-debuginfod-homesite.sh: New testcase

Signed-off-by: Martin Cermak <mcermak@redhat.com>
5 months agolibdw: Translate DW_LANG_Algol68 to DW_LNAME_Algol68 with lversion 1978
Mark Wielaard [Fri, 5 Dec 2025 11:56:22 +0000 (12:56 +0100)] 
libdw: Translate DW_LANG_Algol68 to DW_LNAME_Algol68 with lversion 1978

1978 is the year of the publication of the Revised Report that defines
the revised language. And this is the version set by gcc a68. So when
we see DW_LANG_Algol68 we translate it to DW_LNAME_Algol68 with
lversion set to 1978 to match gcc a68.

* libdw/dwarf_srclang.c (srclang_to_language): Set lversion to
        1978 for DW_LANG_Algol68.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 months agolibdw: Add Erlang, Elixir and Gleam language constants
Mark Wielaard [Tue, 2 Dec 2025 14:41:23 +0000 (15:41 +0100)] 
libdw: Add Erlang, Elixir and Gleam language constants

The DWARF standard recently added language constants for Erlang,
Elixir and Gleam. https://dwarfstd.org/languages.html
https://dwarfstd.org/languages-v6.html

* libdw/dwarf.h: Add DW_LANG_Erlang, DW_LNAME_Erlang,
DW_LANG_Elixir, DW_LNAME_Elixir, DW_LANG_Gleam and
DW_LNAME_Gleam.
* libdw/dwarf_default_lower_bound.c
(dwarf_default_lower_bound): Add DW_LANG_Gleam, DW_LANG_Erlang
and DW_LANG_Elixir.
(dwarf_language_lower_bound): Add DW_LNAME_Gleam, DW_LNAME_Erlang
and DW_LNAME_Elixir.
* libdw/dwarf_srclang.c (srclang_to_language): Handle
DW_LANG_Erlang, DW_LANG_Elixir and DW_LANG_Gleam.
(language_to_srclang): Handle DW_LNAME_Erlang, DW_LNAME_Elixir
and Add DW_LNAME_Gleam.

Signed-off-by: Mark Wielaard <mark@klomp.org>
5 months agopo: Update Polish translation
Piotr Drąg [Mon, 1 Dec 2025 03:10:39 +0000 (22:10 -0500)] 
po: Update Polish translation

Signed-off-by: Aaron Merey <amerey@redhat.com>
6 months agoFix const-correctness issues
Andreas Schwab [Mon, 24 Nov 2025 12:46:16 +0000 (13:46 +0100)] 
Fix const-correctness issues

These were uncovered by the C23 const-preserving library macros.

6 months agopo: Update POTFILES.in
Piotr Drąg [Wed, 26 Nov 2025 01:10:35 +0000 (20:10 -0500)] 
po: Update POTFILES.in

Signed-off-by: Aaron Merey <amerey@redhat.com>
6 months agodoc: add man page for gelf update symbol versioning entry functions
Aaron Merey [Mon, 10 Nov 2025 04:40:04 +0000 (23:40 -0500)] 
doc: add man page for gelf update symbol versioning entry functions

Add man pages for gelf_update_versym, gelf_update_verdef,
gelf_update_verdaux, gelf_update_verneed and gelf_update_vernaux.

Signed-off-by: Aaron Merey <amerey@redhat.com>
6 months agodoc: add man pages for gelf get symbol versioning entry functions
Aaron Merey [Mon, 10 Nov 2025 04:40:03 +0000 (23:40 -0500)] 
doc: add man pages for gelf get symbol versioning entry functions

Add man pages for gelf_getversym, gelf_getverdef, gelf_getverdaux
gelf_getverneed and gelf_getvernaux.

Signed-off-by: Aaron Merey <amerey@redhat.com>