Slava Barinov [Mon, 6 Mar 2023 10:55:36 +0000 (13:55 +0300)]
Update to 0.189
Change-Id: I3ddaf2d3c995d49efda2e7de0b3f7f1c6d08b616
Dongkyun Son [Fri, 24 Feb 2023 11:20:27 +0000 (20:20 +0900)]
add packaging
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
Mark Wielaard [Fri, 3 Mar 2023 15:13:52 +0000 (16:13 +0100)]
Prepare for 0.189
Set version to 0.189
Update NEWS and elfutils.spec.in
Set copyright year in configure.ac and printversion.
Regenerate po/*.po files.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 3 Mar 2023 14:37:18 +0000 (15:37 +0100)]
libelf: Document and make ELFCOMPRESS_ZSTD usable with old system elf.h
Make sure that even if the system elf.h doesn't have ELF_COMPRESS_ZSTD
defined it can still be used as constant. Also update libelf.h
documentation and add new feature to NEWS.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 3 Mar 2023 13:13:49 +0000 (14:13 +0100)]
readelf: Fix use-after-free ebl pointer issue
With -flto gcc 13 sees that we use the ebl pointer after closing and
freeing it.
In function ‘process_elf_file’,
inlined from ‘process_dwflmod’ at readelf.c:818:3:
readelf.c:1070:6: error: pointer ‘ebl_18’ used after ‘free’ [-Werror=use-after-free]
1070 | if (pure_ebl != ebl)
| ^
In function ‘ebl_closebackend’,
inlined from ‘process_elf_file’ at readelf.c:1068:3,
inlined from ‘process_dwflmod’ at readelf.c:818:3:
../libebl/eblclosebackend.c:47:7: note: call to ‘free’ here
47 | free (ebl);
| ^
Fix by only calling ebl_closebackend after using it in the comparison.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 22 Feb 2023 22:34:00 +0000 (23:34 +0100)]
libdw: Fix dwarf_getscopes memory leak on error
When there is an error in dwarf_getscopes after the initial scopes
have been allocated, e.g. when looking for the inlined scopes, then
the scopes would leak. Fix this by explicitly free the scopes on error.
https://sourceware.org/bugzilla/show_bug.cgi?id=29434
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonggang Luo [Sat, 17 Dec 2022 16:52:02 +0000 (00:52 +0800)]
libcpu: Remove the need of NMNES by using enum
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 20 Feb 2023 15:42:56 +0000 (16:42 +0100)]
libdw: Use elf_rawdata when checking .debug section
.debug sections are raw bytes and don't need conversion even when host
and file have different endian order.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 20 Feb 2023 15:32:57 +0000 (16:32 +0100)]
libelf: memmove any extra bytes left by elf_cvt_gnuhash conversion
Otherwise some undefined bytes might be left in the buffer. Now they
might still be not useful, but at least they are as defined in the
file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 23 Feb 2023 09:42:15 +0000 (10:42 +0100)]
NEWS: Add old version code names
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 21 Feb 2023 21:27:59 +0000 (22:27 +0100)]
Update m4 files from autoconf-archive
Update m4/ax_check_compile_flag.m4 and m4/ax_cxx_compile_stdcxx.m4
to autoconf-archive-2023.02.20.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 21 Feb 2023 12:12:38 +0000 (13:12 +0100)]
configure: Check for and -Wuse-after-free=3 when available
gcc already includes -Wuse-after-free=2 in -Wall. -Wuse-after-free=3
also warns for indeterminate pointers in equality expressions.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 17 Feb 2023 13:52:04 +0000 (14:52 +0100)]
libasm: Fix use-after-free issue with circular single linked list cleanup
Pointed out by gcc 12 with -Wuse-after-free=3
In function ‘free_section’
asm_end.c:552:17: error: pointer ‘data’ used after ‘free’ [-Werror=use-after-free]
552 | while (oldp != scnp->content);
| ~~~~~^~~~~~~~~~~~~~~~
asm_end.c:550:9: note: call to ‘free’ here
550 | free (oldp);
| ^~~~~~~~~~~
Fix by freeing scnp->content last.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 17 Feb 2023 20:17:10 +0000 (21:17 +0100)]
NEWS: Mention linking with libstdc++ or using --disable-demangler
Signed-off-by: Mark Wielaard <mark@klomp.org>
Aleksei Vetrov [Tue, 14 Feb 2023 20:30:02 +0000 (20:30 +0000)]
libdw: check that DWARF strings are null-terminated
It is expected from libdw to return strings that are null-terminated to
avoid overflowing ELF data.
* Add calculation of a safe prefix inside string sections, where any
string will be null-terminated.
* Check if offset overflows the safe prefix in dwarf_formstring.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
Mark Wielaard [Wed, 15 Feb 2023 16:00:30 +0000 (17:00 +0100)]
configure: Error when demangler is enabled, but libstdc++ support isn't
There have been a couple of cases where demangler support has been
accidentially been disabled because libstdc++ wasn't there/installed
during build. Make it an error if --disable-demangler isn't explicitly
given.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 14 Feb 2023 20:03:38 +0000 (21:03 +0100)]
doc: Add .TP before -g in debuginfod.8
Fixes indentation of -g option.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 14 Feb 2023 19:24:30 +0000 (20:24 +0100)]
libdw: Correct data end checkfor deref_type operand in dwarf_getlocation
In __libdw_intern_expression we checked for one byte too many.
We only need one byte for the size and (at least one) for the uleb128
DIE reference.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 10 Feb 2023 12:56:58 +0000 (13:56 +0100)]
libdw: Handle DW_OP_GNU_uninit in dwarf_getlocation
dwarf_getlocation would return an error when it saw a
DW_OP_GNU_uninit. Handle it by simply recognizing as a no argument
operation.
DW_OP_GNU_uninit is emitted by GCC as a marker to flag the location
expression as referring to an uninitialized value.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 8 Feb 2023 15:53:24 +0000 (16:53 +0100)]
libdw, readelf, elflint: Add get_(u|s)leb128 guards
Add sanity check making sure an leb128 isn't being read beyond the
end of the current data segment. Most code already had these guards,
but some were missing. This makes sure an appropriate error is
generated instead.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Aleksei Vetrov [Mon, 13 Feb 2023 20:10:05 +0000 (20:10 +0000)]
libdw: check memory access in get_(u|s)leb128
__libdw_get_uleb128 and __libdw_get_sleb128 should check if addrp has
already reached the end before unrolling the first step. It is done by
moving __libdw_max_len to the beginning of the function, which can
notice, that addrp is beyond the end. Then we just check the result of
this function.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
Mark Wielaard [Thu, 26 Jan 2023 17:19:15 +0000 (18:19 +0100)]
backends: Handle DW_TAG_unspecified_type in dwarf_peeled_die_type
binutils 2.40 introduces DW_TAG_unspecified_type for assembly
functions with an unknown return type. This breaks the
run-funcretval.sh testcase because dwfl_module_return_value_location
returns an error for such functions because it cannot determine the
return value location. Fix that by treating DW_TAG_unspecified_type
as if the DIE doesn't have a DW_AT_type.
Also update the testcase to explicitly checking for
DW_TAG_unspecified_type and printing "returns unspecified type".
https://sourceware.org/bugzilla/show_bug.cgi?id=30047
Signed-off-by: Mark Wielaard <mark@klomp.org>
Ilya Leoshkevich [Mon, 13 Feb 2023 16:45:51 +0000 (17:45 +0100)]
configure: Add --enable-sanitize-memory
Add support for clang Memory Sanitizer [1], which detects the usage of
uninitialized values. While elfutils itself is already checked with
valgrind, checking code that depends on elfutils requires elfutils to
be built with MSan.
MSan is not linked into shared libraries, and is linked into
executables statically. Therefore, unlike the other sanitizers, MSan
needs to be configured fairly early, since we need to drop
-D_FORTIFY_SOURCE [2], -Wl,-z,defs and --no-undefined.
Disable a few tests that run for more than 5 minutes due to test files
being statically linked with MSan.
[1] https://clang.llvm.org/docs/MemorySanitizer.html
[2] https://github.com/google/sanitizers/issues/247
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Mon, 13 Feb 2023 16:45:50 +0000 (17:45 +0100)]
backends: Support returning lvalue and rvalue references
On the low level, they are the same as pointers. The change needs to be
done for all backends, so define a function and a macro to avoid
repetition. Also add a native test, which has to be implemented in C++.
Add the configure check for it.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Mon, 13 Feb 2023 16:45:49 +0000 (17:45 +0100)]
printversion: Fix unused variable
clang complains:
debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable]
ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
^
../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF'
const char *const apba__ __asm ("argp_program_bug_address")
^
The default linkage for consts in C++ is internal, so declare them
extern. While at it, remove the debuginfod workaround for
argp_program_version_hook.
Co-developed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Mon, 13 Feb 2023 16:45:48 +0000 (17:45 +0100)]
tests: Ignore dwfl-report-offline-memory
It's showing up in git status when configuring in the source directory.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Wed, 8 Feb 2023 19:52:25 +0000 (20:52 +0100)]
configure: Add --disable-demangler
__cxa_demangle is normally implemented in the C++ runtime library,
instrumenting which for MSan is a hassle. Add a knob for disbling it.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Wed, 8 Feb 2023 19:52:24 +0000 (20:52 +0100)]
configure: Use -fno-addrsig if possible
By default, clang produces .llvm_addrsig sections [1]. The GNU
toolchain does not know how to handle them yet [2], so just ask clang
not to generate them for the time being.
[1] https://llvm.org/docs/Extensions.html#sht-llvm-addrsig-section-address-significance-table
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105625
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Wed, 8 Feb 2023 19:52:22 +0000 (20:52 +0100)]
readelf: Fix set but not used parameter
clang complains:
readelf.c:12205:72: error: parameter 'desc' set but not used [-Werror,-Wunused-but-set-parameter]
handle_bit_registers (const Ebl_Register_Location *regloc, const void *desc,
^
Mark Wielaard says:
It is never really used since as far as I can see we don't have any
backend with a core register sets where a register doesn't have a
number of bits which isn't a multiple of 8 (only ia64 has some 1
bit registers, but those don't seem part of the core register set).
If we do accidentally try to handle such a register having an abort
is also not very nice. Lets just warn and return/continue.
https://sourceware.org/bugzilla/show_bug.cgi?id=30084
Co-developed-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Wed, 8 Feb 2023 19:52:20 +0000 (20:52 +0100)]
libasm: Fix xdefault_pattern initialization
clang complains:
asm_newscn.c:48:22: error: field 'pattern' with variable sized type 'struct FillPattern' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
struct FillPattern pattern;
^
Fix by using a union instead. Define the second union member to be a
char array 1 byte larger than struct FillPattern. This should be legal
according to 6.7.9:
If an object that has static or thread storage duration is not
initialized explicitly, then ... if it is a union, the first named
member is initialized (recursively) according to these rules, and
any padding is initialized to zero bits.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Mon, 6 Feb 2023 22:25:09 +0000 (23:25 +0100)]
addr2line: Do not test demangling in run-addr2line-i-test.sh
There is run-addr2line-i-demangle-test.sh for that.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Mon, 6 Feb 2023 22:25:08 +0000 (23:25 +0100)]
Initialize reglocs for VMCOREINFO
MSan complains:
Uninitialized value was created by an allocation of 'reglocs' in the stack frame
#0 0x562d35c686f0 in handle_core_note elfutils/src/readelf.c:12674:3
#const Ebl_Register_Location *reglocs;
==1006199==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x562d35c68a2a in handle_core_note elfutils/src/readelf.c:12692:11
#colno = handle_core_registers (ebl, ebl->elf, desc + regs_offset,
# reglocs, nregloc);
Strictly speaking, this is not a problem, because nregloc == 0, but for
other note types we initialize it anyway, so do it here as well.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ilya Leoshkevich [Mon, 6 Feb 2023 22:25:07 +0000 (23:25 +0100)]
readelf: Fix set but not used variable
clang complains:
readelf.c:10250:10: error: variable 'nculist' set but not used [-Werror,-Wunused-but-set-variable]
size_t nculist = 0;
^
Fix by deleting it.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Aaron Merey [Wed, 8 Feb 2023 02:15:33 +0000 (21:15 -0500)]
debuginfod-client.c: Download section even if cached executable didn't contain it.
Before attempting to download a section, cache_find_section tries to
extract the section from existing files in the cache. If it's determined
that the section must not exist, cache_find_section returns -ENOENT to
indicate that the download should be skipped.
This patch fixes a bug where cache_find_section returns -ENOENT even
though the section exists. If the cache contains the executable but
not the debuginfo with the given build-id and the section only exists
in the debuginfo (such as any of the .debug_* sections), then
debuginfod_find_section returns -ENOENT even if the section could be
downloaded.
Fix this by having cache_find_section not return -ENOENT unless cached
debuginfo was able to be read.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Mark Wielaard [Mon, 6 Feb 2023 09:21:58 +0000 (10:21 +0100)]
debuginfod: Make sure there is only one typedef for debuginfod_client
Both debuginfod.h and libdwfl.h have a simple typedef for struct
debuginfod_client. Some compilers pedantically warn when including
both headers that such typedefs are only officially supported in
C11. So guard them with _ELFUTILS_DEBUGINFOD_CLIENT_TYPEDEF to
make them happy.
https://sourceware.org/bugzilla/show_bug.cgi?id=30077
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 3 Feb 2023 12:44:17 +0000 (13:44 +0100)]
tests: Check ELFUTILS_DISABLE_DEMANGLE in run-addr2line-C-test.sh
https://sourceware.org/bugzilla/show_bug.cgi?id=30072
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sat, 21 Jan 2023 23:31:57 +0000 (00:31 +0100)]
libdw: Search for abstract origin in the correct CU
With gcc -flto the abstract origin of an inlined subroutine
could be in a different CU. dwarf_getscopes might return an
empty scope if it cannot find the abstract origin scope. So
make sure to search in the
We also tried to add the origin match in pc_record directly
in the current inlined scope. This always failed, causing
to do a needless traversal, followed by the full CU scan in
dwarf_getscopes. Just always stop the pc_record search and
then do the CU origin_match in dwarf_getscopes.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 22 Jan 2023 19:50:53 +0000 (20:50 +0100)]
addr2line: -C should not try to handle optional (ignored) argument
The --demangle option takes an option (ignored) argument. Since -C
is the short option of --demangle it also takes that optional
argument. But that means that something like -Cfi is like -C got
fi as argument, while the user expects -Cfi to be like -C -f -i.
Separate the --demangle and -C options. --demangle still takes
an optional (ignored) argument, but -C doesn't take any arguments
so -Cfi acts the same as -fiC.
Also fix --target, -b, so that it is properly ignored (and not
accidentially enables demangling).
Signed-off-by: Mark Wielaard <mark@klomp.org>
Aleksei Vetrov [Wed, 25 Jan 2023 14:16:57 +0000 (14:16 +0000)]
libdwfl: add check for elf_memory return value
elf_memory call in __libdw_open_elf_memory can return NULL. It was not
checked and led to the null pointer dereference.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
Mark Wielaard [Thu, 19 Jan 2023 22:53:33 +0000 (23:53 +0100)]
tests: run-debuginfod-query-retry.sh /bin/sh might not have a build-id
If /bin/sh wasn't build with build-id the test fails because
debuginfod-find will not be able to even try to fetch something.
Use libdebuginfod.so.1 instead as test file because we just
build that and configure makes sure we always produce a build-id.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 19 Jan 2023 22:04:04 +0000 (23:04 +0100)]
backends: sparc uses NONE relocation type in ET_EXEC and ET_DYN files
Using the NONE relocation doesn't do anything, but is harmless.
This fixes several (self) tests on sparc that use elflint to
check files are valid ELF.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 10 Jan 2023 17:18:05 +0000 (18:18 +0100)]
readelf: Check compression status of .debug section data
The various print_debug_*_section functions didn't get the section
data in the same way. Add a new get_debug_elf_data function that
gets the (possibly relocated) section data and that checks (and
warns) if the data might still be compressed in a way that we
cannot decompress.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Sam James [Fri, 13 Jan 2023 22:16:07 +0000 (22:16 +0000)]
Fix typos from codespell
debuginfod/ChangeLog:
* debuginfod-client.c: Typo simultaniously.
doc/ChangeLog:
* debuginfod.8: Typo succesfully.
lib/ChangeLog:
* dynamicsizehash_concurrent.c: Typo modul.
* system.h: Typo dependend.
libdwfl/ChangeLog:
* open.c: Typo non-existant.
src/ChangeLog:
* nm.c: Typo Covert.
* strings.c: Likewise.
tests/ChangeLog:
* elfstrmerge.c: Typo outselves.
* run-debuginfod-extraction.sh: Typo accidentially.
* run-debuginfod-fd-prefetch-caches.sh: Likewise.
Signed-off-by: Sam James <sam@gentoo.org>
Serhei Makarov [Tue, 10 Jan 2023 16:20:13 +0000 (11:20 -0500)]
debuginfod-find.1: note on how to find a comp_dir
doc/ChangeLog:
* debuginfod-find.1: add a note to DESCRIPTION section for the 'source'
subcommand, clarifying where to find the CU compilation-directory.
I'm looking at how to improve and document the workflow for using
debuginfod-find to study the behaviour of packaged software on a system, e.g.
in conjunction with a tracing tool like SystemTap. You can read the exact
compiled source code with debuginfod-find source and use that to figure out
which source code locations are interesting to trace. But that process has
several non-obvious or inconvenient steps.
This patch is a clarification to the debuginfod-find source man page pointing
out the eu-readelf command that can show the comp_dir in downloaded debuginfo.
Since debuginfod-find source could be picked up and used by a developer
unfamiliar with DWARF terminology, I think such a clarification saves time
for newbies figuring out what a CU compilation-directory is.
Signed-off-by: Serhei Makarov <serhei@serhei.io>
Frank Ch. Eigler [Tue, 10 Jan 2023 22:59:35 +0000 (17:59 -0500)]
debuginfod PR29975 & PR29976: decrease default concurrency
... based on rlimit (rlimig -n NUM)
... based on cpu-affinity (taskset -c A,B,C,D ...)
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Mark Wielaard [Tue, 10 Jan 2023 22:20:41 +0000 (23:20 +0100)]
debuginfod-client: Use CURLOPT_PROTOCOLS_STR for libcurl >= 7.85.0
https://sourceware.org/bugzilla/show_bug.cgi?id=29926
Signed-off-by: Mark Wielaard <mark@klomp.org>
Martin Liska [Tue, 29 Nov 2022 09:59:30 +0000 (10:59 +0100)]
support ZSTD compression algorithm
config/ChangeLog:
* libelf.pc.in: Add LIBLZSTD to Requires.private.
ChangeLog:
* configure.ac: Detect ZSTD streaming API.
libelf/ChangeLog:
* Makefile.am: Use zstd_LIBS.
* elf_compress.c:
(__libelf_compress): Split into ...
(__libelf_compress_zlib): ... this.
(do_zstd_cleanup): New.
(zstd_cleanup): New.
(__libelf_compress_zstd): New.
(__libelf_decompress): Switch in between zlib and zstd.
(__libelf_decompress_zlib): Renamed from __libelf_decompress.
(__libelf_decompress_zstd): New.
(__libelf_decompress_elf): Dispatch in between compression
algorithms.
(elf_compress): Likewise.
* elf_compress_gnu.c (elf_compress_gnu): Call with
ELFCOMPRESS_ZLIB.
* libelfP.h (__libelf_compress): Add new argument.
(__libelf_decompress): Add chtype argument.
src/ChangeLog:
* elfcompress.c (enum ch_type): Add ZSTD.
(parse_opt): Parse "zstd".
(get_section_chtype): New.
(process_file): Support zstd compression.
(main): Add zstd to help.
* readelf.c (elf_ch_type_name): Rewrite with switch.
tests/ChangeLog:
* Makefile.am: Add ELFUTILS_ZSTD if zstd is enabled.
* run-compress-test.sh: Test zstd compression algorithm
for debug sections.
Mark Wielaard [Wed, 21 Dec 2022 15:40:29 +0000 (16:40 +0100)]
libdwfl: Don't undef _
A couple of files undefined _, which is defined in lib/eu-config.h as
gettext helper macro. This seems unnecessary and arbitrary.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Shahab Vahedi [Wed, 21 Dec 2022 11:27:05 +0000 (12:27 +0100)]
Add support for Synopsys ARCv2 processors
There is no regression in tests for an x86_64 build, while the new
hello_arc_hs4.ko is added as well. This is the only meaningful
test that I could add at the moment, given the features supported
by this port.
$ cat tests/test-suite.log
==========================================
elfutils 0.188: tests/test-suite.log
==========================================
# TOTAL: 236
# PASS: 235
# SKIP: 1
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
.. contents:: :depth: 2
SKIP: run-lfs-symbols.sh
========================
LFS testing is irrelevant on this system
SKIP run-lfs-symbols.sh (exit status: 77)
$ cat tests/run-strip-reloc.sh.log
runtest hello_i386.ko
runtest hello_x86_64.ko
runtest hello_ppc64.ko
runtest hello_s390.ko
runtest hello_aarch64.ko
runtest hello_m68k.ko
runtest hello_riscv64.ko
runtest hello_csky.ko
runtest hello_arc_hs4.ko <-- [ new ARC HS4 test ]
runtest /home/shahab/pahole_pkg/elfutils-git/bld_arc/src/strip
runtest /home/shahab/pahole_pkg/elfutils-git/bld_arc/src/strip.o
runtest strip-uncompressed.o
runtest strip-compressed.o
runtest testfile-debug-rel-ppc64.o
runtest testfile-debug-rel-ppc64-z.o
runtest testfile-debug-rel-ppc64-g.o
PASS run-strip-reloc.sh (exit status: 0)
Signed-off-by: Shahab Vahedi <shahab@synopsys.email>
Mark Wielaard [Tue, 20 Dec 2022 22:20:52 +0000 (23:20 +0100)]
lib: Remove -ffunction-sections for xmalloc
The build used -ffunction-sections just for one file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonggang Luo [Sat, 17 Dec 2022 16:52:03 +0000 (00:52 +0800)]
libcpu: Use __asm instead of asm to mark variables as used
This block of code can not be removed. As it's contains a goto label
enomem that been used elsewhere.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Mark Wielaard [Wed, 21 Dec 2022 17:21:08 +0000 (18:21 +0100)]
debuginfod: Define CURL_AT_LEAST_VERSION if necessary
Older curl.h don't define CURL_AT_LEAST_VERSION, so define it
ourselves because it is nicer than doing hex encoded version
comparisons.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Andrew Paprocki [Wed, 21 Dec 2022 16:15:00 +0000 (11:15 -0500)]
PR29926: debuginfod: Fix usage of deprecated CURLINFO_*
The `CURLINFO_SIZE_DOWNLOAD_T` and `CURLINFO_CONTENT_LENGTH_DOWNLOAD_T`
identifiers are `enum`s, not pre-processor definitions, so the current
`#ifdef` logic is not selecting the newer API. This results in the
older identifiers being used and they now generate errors when compiled
against Curl 7.87, which has silently deprecated them, causing GCC to
emit `-Werror=deprecated-declarations`.
Instead, the newer identifiers were added in Curl 7.55, so explicitly
check for `CURL_AT_LEAST_VERSION(7, 55, 0)` instead of the current
logic. This eliminates the error when compiling against Curl 7.87.
Ref: https://github.com/curl/curl/pull/1511
Signed-off-by: Andrew Paprocki <andrew@ishiboo.com>
Mark Wielaard [Tue, 20 Dec 2022 13:53:43 +0000 (14:53 +0100)]
Do not use relative include paths in library files.
Rely on include dirs being set up correctly. Setup libdw AM_CPPFLAGS
to include libebl directory. In libdwfl note that debuginfod.h is a
generated file in the builddir. Only include it in the one file
debuginfod-client.c that really needs it.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Hengqi Chen [Sat, 3 Dec 2022 13:47:07 +0000 (21:47 +0800)]
Add support for LoongArch
This implements initial support for the LoongArch architecture.
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Gavin Li [Wed, 30 Nov 2022 17:26:19 +0000 (18:26 +0100)]
libdwfl: Read no more than required in dwfl_segment_report_module
Since read_portion and the standard dwfl_elf_phdr_memory_callback
functions make sure to read at least minread bytes there is no need
for dwfl_segment_report_module to check and adjust the data to the
actual buffer size read. Reading beyond the end of the expected data
size (if the buffer read is much larger) actually causes issues when
passing the data to elfXX_xlatetom() because it is possible that
src->d_size is not a multiple of recsize (for ELF_T_DYN, recsize is 16
while the minimum required alignment is 8), causing elfXX_xlatetom()
to return ELF_E_INVALID_DATA.
Signed-off-by: Gavin Li <gavin@matician.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonggang Luo [Thu, 20 Oct 2022 18:25:52 +0000 (02:25 +0800)]
libdw: Change typeof -> __typeof in memory-access.h
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Yonggang Luo [Thu, 20 Oct 2022 18:25:51 +0000 (02:25 +0800)]
libcpu: Use "#define FCT_mod$64r_m FCT_mod$r_m" in i386_data.h
This is enough and can be recognized by clang-cl on windows
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Mark Wielaard [Wed, 30 Nov 2022 23:25:01 +0000 (00:25 +0100)]
libelf: Sync elf.h from glibc
Adds various new ARC related declarations.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Martin Liska [Mon, 28 Nov 2022 13:10:36 +0000 (14:10 +0100)]
Refactor elf_compare
src/ChangeLog:
* elfcompress.c (T_UNSET): Remove and use ch_type.
(T_DECOMPRESS): Likewise.
(T_COMPRESS_ZLIB): Likewise.
(T_COMPRESS_GNU): Likewise.
(enum ch_type): New.
(parse_opt): Parse to new ch_type.
(compress_section): Change gnu and compress arguments
to schtype (source compression) and dchtype (destination
compression).
(process_file): Use new enum type and adjusted compress_section.
Martin Liska [Mon, 28 Nov 2022 13:01:29 +0000 (14:01 +0100)]
Missing newline for: elfcompress -t zlib-gnu a.out -force
Fixes:
./src/elfcompress -t zlib-gnu a.out -force
[28] .zdebug_aranges unchanged, already GNU compressed[29] .zdebug_info unchanged, already GNU compressed[30] .zdebug_abbrev unchanged, already GNU compressed[31] .zdebug_line unchanged, already GNU compressed[32] .zdebug_str unchanged, already GNU compressed[33] .zdebug_line_str unchanged, already GNU compressed[34] .zdebug_rnglists unchanged, already GNU compressed
to:
./src/elfcompress -t zlib-gnu a.out -force
[28] .zdebug_aranges unchanged, already GNU compressed
[29] .zdebug_info unchanged, already GNU compressed
[30] .zdebug_abbrev unchanged, already GNU compressed
[31] .zdebug_line unchanged, already GNU compressed
[32] .zdebug_str unchanged, already GNU compressed
[33] .zdebug_line_str unchanged, already GNU compressed
[34] .zdebug_rnglists unchanged, already GNU compressed
src/ChangeLog:
* elfcompress.c (process_file): Add missing newline.
Martin Liska [Fri, 25 Nov 2022 13:27:19 +0000 (14:27 +0100)]
readelf: print warning for -sW
The option -s accepts in elfutils (compared to binutils) a positional
argument that is name of a symbol table section which should be printed.
Thus, print a reasonable warning if -sW is used:
./src/readelf -sW a.out
WARNING: cannot find section: 'W'
PR29719
src/ChangeLog:
* readelf.c (print_symtab): Change signature and return true if
something is printed.
(process_elf_file): Use it and print warning.
tests/ChangeLog:
* run-readelf-s.sh: Test -sW.
Mark Wielaard [Tue, 15 Nov 2022 16:50:01 +0000 (17:50 +0100)]
debuginfod: Initialize response_data early in debuginfod-client query
On error going to out2, the response_data is freed. So initialize the
response_data to NULL immediately after allocation or when going back
to query_in_parallel.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Aaron Merey [Mon, 7 Nov 2022 16:26:32 +0000 (11:26 -0500)]
debuginfod-client.c: Don't treat 0 as an error code.
Replace 'fd > 0' with 'fd >= 0' to avoid treating a possible file
descriptor as an error code.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Aaron Merey [Fri, 4 Nov 2022 21:22:40 +0000 (17:22 -0400)]
debuginfod_find_section: Always update rc with most recent error code
debuginfod_find_section may attempt to download both the debuginfo
and executable matching the given build-id. If neither of these
files can be found, update rc to ensure that we always return an
accurate error code in this case.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Frank Ch. Eigler [Thu, 3 Nov 2022 14:07:31 +0000 (10:07 -0400)]
debuginfod.cxx: fix coverity-found use-after-release error
The debuginfod_client object lifetime needs more careful handling,
made easier with the defer_dtor<> gadget.
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Mark Wielaard [Thu, 3 Nov 2022 12:52:32 +0000 (13:52 +0100)]
readelf: Check gelf_getdyn doesn't return NULL
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 3 Nov 2022 12:44:35 +0000 (13:44 +0100)]
libdw: Don't dereference and assign values we are skipping
We don't use the FDE address encoding byte, so no reason
to read and store it. Just skip past it.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 3 Nov 2022 12:38:45 +0000 (13:38 +0100)]
readelf: Check phdr != NULL or shdr != NULL in handle_dynamic.
The compiler doesn't know that when use_dynamic_segment is true,
then phdr should/will be non-NULL and otherwise shdr is non-NULL.
Add explicit checks to help the compiler out and in case an error
is made calling the handle_dynamic function.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 2 Nov 2022 16:54:11 +0000 (17:54 +0100)]
debuginfod: Mark extract_section function static
The extract_section function in debuginfod-client.c is an internal
function and should not be exported. Mark it as static.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 2 Nov 2022 12:47:08 +0000 (13:47 +0100)]
Prepare for 0.188
Set version to 0.188
Update elfutils.spec.in
Regenerate po/*.po files
Signed-off-by: Mark Wielaard <mark@klomp.org>
Aaron Merey [Wed, 2 Nov 2022 00:09:36 +0000 (20:09 -0400)]
Changelog: Update entries from previous commits.
Update Changelogs with details from commits
04b1a3aa and
054b3bde9.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Aaron Merey [Tue, 1 Nov 2022 23:07:44 +0000 (19:07 -0400)]
run-debuginfod-section.sh: Avoid zstd-compressed rpms
Only test using rpms without zstd compression. Older versions of
libarchive may fail to handle these.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Aaron Merey [Tue, 1 Nov 2022 21:51:00 +0000 (17:51 -0400)]
debuginfod-client: Fix out-of-bounds write
Return early from path_escape when '\0' is seen in order to prevent
an out-of-bounds write to the dest buffer.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Aaron Merey [Tue, 1 Nov 2022 03:44:23 +0000 (23:44 -0400)]
debuginfod: Support queries for ELF/DWARF sections
Add new function debuginfod_find_section which queries debuginfod
servers for the raw binary contents of the specified ELF/DWARF section
in a file matching the given build-id.
Extend the server webapi to support section queries. Section query
URLS have the following format: /buildid/BUILDID/section/SECTION
The server will attempt to extract the section from a debuginfo file
matching the given build-id. If the debuginfo file cannot be found
or the section has type SHT_NOBITS, the server will attempt to extract
the section from the executable file matching the build-id.
If the server is built without section query support, the client will
attempt to download the debuginfo matching the build-id and extract the
section. If the debuginfo file cannot be found or the section has type
SHT_NOBITS, the server will attempt to download the executable file
matching the build-id and extract the section.
Signed-off-by: Aaron Merey <amerey@redhat.com>
Yonggang Luo [Tue, 20 Sep 2022 08:43:01 +0000 (16:43 +0800)]
Rename 'hello{2,3}.spec.' -> 'hello{2,3}.specfile'
These filenames are invalid on win32.
We don't want to include multiple .spec files for make rpm.
rpmbuild --sign is not supported anymore.
Also include hello3.specfile in EXTRA_DIST.
Escape some macros in the elfutils.spec.in file comments.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Arsen Arsenović [Fri, 28 Oct 2022 20:44:47 +0000 (22:44 +0200)]
readelf: add binutils-style --syms option
This helps people with a lot of built up muscle memory :)
Signed-off-by: Arsen Arsenović <arsen@aarsen.me>
Mark Wielaard [Fri, 28 Oct 2022 21:52:29 +0000 (23:52 +0200)]
libelf: Sync elf.h from glibc
Adds ELFCOMPRESS_ZSTD, NT_S390_PV_CPU_DATA and NT_LOONGARCH_*.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonggang Luo [Thu, 20 Oct 2022 18:25:46 +0000 (02:25 +0800)]
lib{asm,cpu,dw,dwfl,dwelf}: Move platform depended include into system.h
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Daniel Thornburgh [Tue, 18 Oct 2022 21:21:32 +0000 (14:21 -0700)]
debuginfod-client: Add DEBUGINFOD_HEADERS_FILE.
This DEBUGINFOD_HEADERS_FILE environment variable names a file to supply
HTTP headers to outgoing requests. Notably, this allows for
Authorization headers to be added from a file under OS access control.
Signed-off-by: Daniel Thornburgh <dthorn@google.com>
Mark Wielaard [Sat, 22 Oct 2022 19:58:19 +0000 (21:58 +0200)]
configure.ac: Update AC_PROG_CC and AC_PROG_LEX for autoconf 2.70
With autoconf 2.70 we must use AC_PROG_CC (which will check for c11
and c99), for earlier versions we'll use AC_PROG_CC_C99. Also use
AC_PROG_LEX([noyywrap]), the extra argument is ignored with earlier
versions, but required for 2.70.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 27 Oct 2022 16:34:54 +0000 (18:34 +0200)]
Use grep -E instead of egrep, use grep -F instead of fgrep.
GNU grep 3.8 gives a deprecation warning when using egrep or fgrep.
Just use grep -E and grep -F.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 27 Oct 2022 16:30:37 +0000 (18:30 +0200)]
config: Add BuildRequires socat for run-debuginfod-response-headers.sh
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 19 Oct 2022 22:02:39 +0000 (00:02 +0200)]
readelf: Handle DW_LLE_GNU_view_pair
DW_LLE_GNU_view_pair is used by gcc -gvariable-location-views=incompat5.
As described in http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt
and proposed for DWARF6 https://dwarfstd.org/ShowIssue.php?issue=170427.1
Signed-off-by: Mark Wielaard <mark@klomp.org>
Yonggang Luo [Thu, 20 Oct 2022 18:25:44 +0000 (02:25 +0800)]
libdw: Use #include <system.h> instead of <endian.h> in memory-access.h
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Yonggang Luo [Thu, 20 Oct 2022 18:25:43 +0000 (02:25 +0800)]
libelf/libdwfl: Remove LIB_SYSTEM_H define in lib{elf,dwfl}_crc32.c
rationale: https://sourceware.org/bugzilla/show_bug.cgi?id=21001
If we don't remove this macro, when try #include <system.h> in
libdw/memory-access.h wont' take effect because
"#define LIB_SYSTEM_H 1"
The compile error:
./../libdw/memory-access.h:390:12: error: implicit declaration of
function ‘bswap_32’ [-Werror=implicit-function-declaration]
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Yonggang Luo [Thu, 20 Oct 2022 18:25:42 +0000 (02:25 +0800)]
libebl: Don't #include <dlfcn.h> in eblclosebackend.c and eblopenbackend.c
It's not accessed symbols in dlfcn.h in eblclosebackend.c and
eblopenbackend.c
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Frank Ch. Eigler [Mon, 17 Oct 2022 14:07:39 +0000 (10:07 -0400)]
debuginfod: report libmicrohttpd version on startup
To assist troubleshooting with intermittent bugs.
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Yonggang Luo [Tue, 20 Sep 2022 08:43:05 +0000 (16:43 +0800)]
Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
__BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined by the
gcc/clang preprocessor. BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN are
defined in <endian.h>.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Yonggang Luo [Sat, 15 Oct 2022 16:36:21 +0000 (00:36 +0800)]
Move the #include <libintl.h> into eu-config.h
So we do not need include in each file.
And indeed the macro
#define _(Str) dgettext ("elfutils", Str)
access libintl function dgettext, so it's make more sense
#include <libintl.h> in file eu-config.h
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Yonggang Luo [Sat, 15 Oct 2022 16:36:20 +0000 (00:36 +0800)]
move platform depended include into system.h of libelf
All of these files either #include <system.h> directly or #include "libelfP.h"
And now "libelfP.h also #include <system.h>, so the platform depended include
can be moved to system.h safely
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Mark Wielaard [Sun, 16 Oct 2022 16:23:06 +0000 (18:23 +0200)]
tests: include config.h first.
Otherwise some symbols (lseek, open) might not get the 64bit offset
variants because they don't pick up _FILE_OFFSET_BITS.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 16 Oct 2022 16:02:46 +0000 (18:02 +0200)]
tests: Check lseek, read and malloc results with correct types in test.
When compiling dwfl-report-offline-memory.c on some systems (latest
gcc/glibc and --enable-sanitize-undefined) we might get:
In file included from /usr/include/features.h:490,
from /usr/include/assert.h:35,
from dwfl-report-offline-memory.c:18:
In function ‘read’,
inlined from ‘main’ at dwfl-report-offline-memory.c:68:23:
/usr/include/bits/unistd.h:38:10: error: ‘__read_alias’ specified size
18446744073709551615
exceeds maximum object size
9223372036854775807 [-Werror=stringop-overflow=]
38 | return __glibc_fortify (read, __nbytes, sizeof (char),
| ^~~~~~~~~~~~~~~
/usr/include/bits/unistd.h: In function ‘main’:
/usr/include/bits/unistd.h:26:16: note: in a call to function ‘__read_alias’ declared with
attribute ‘access (write_only, 2, 3)’
26 | extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
| ^~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:2461: dwfl-report-offline-memory.o] Error 1
Fix by using the correct types and checking all return values.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Aleksei Vetrov [Tue, 20 Sep 2022 13:36:37 +0000 (13:36 +0000)]
libdwfl: add dwfl_report_offline_memory
This method allows to read and report ELF from memory instead of opening
a file. That way arbitrary memory can be worked with, e.g. when coming
from a stream without the need to persist.
Another useful application is for fuzzing, because fuzzers might be able
to track accesses to the memory and change the fuzzer input to cover
more edge cases through more targeted input. Hence, add a new function
along with a test case.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
Khem Raj [Tue, 13 Sep 2022 16:40:06 +0000 (09:40 -0700)]
tests: Add libeu to tests needing error() API
A local error() implementation is used when libc does not provide it,
therefore link in libeu.a which contains this function in tests needing
error() API
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Aaron Merey [Wed, 28 Sep 2022 14:04:23 +0000 (10:04 -0400)]
debuginfod-client: Ensure only negative error codes returned.
Switch a couple error codes from positive to negative so they aren't
interpreted as file descriptors by the caller.
河辺 岳人 [Tue, 27 Sep 2022 12:10:39 +0000 (21:10 +0900)]
Retrive 64bit timestamp from curl_easy_getinfo on _TIME_BITS=64 environment
On 32bit system compiled with -D_TIME_BITS=64, following tests failed:
FAIL: run-debuginfod-archive-test.sh
FAIL: run-debuginfod-archive-groom.sh
FAIL: run-debuginfod-archive-rename.sh
FAIL: run-debuginfod-federation-sqlite.sh
FAIL: run-debuginfod-federation-metrics.sh
FAIL: run-debuginfod-federation-link.sh
due to tests/debuginfod-subr.sh:archive_test failing on
"test $fileame -ot `pwd`", with LHS file having a bogus timestamp.
LHS is generated by debuginfo-find as a cache file.
I'm not sure the fix is the correct way, but
since -D_TIME_BITS=64 mandates -D_FILE_OFFSET_BITS=64 in glibc,
this does work on glibc environment.
Signed-off-by: Taketo Kabe <kabe@sra-tohoku.co.jp>
Mark Wielaard [Sun, 28 Aug 2022 15:46:08 +0000 (17:46 +0200)]
ar: Correct -N COUNT off-by-one
When using instance [COUNT], the instance check is wrong.
instance-- == 0 should be --instance == 0.
Add a testcase run-ar-N.sh that uses -N COUNT with extract and delete
operations checking the right instance was extracted and deleted.
https://sourceware.org/bugzilla/show_bug.cgi?id=28725
Reported-by: panxiaohe <panxh_ran@163.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 28 Aug 2022 17:51:13 +0000 (19:51 +0200)]
libelf: Correctly decode ar_mode as octal string
ar_mode is encoded as an octal ascii string, not decimal. Add a new
OCT_FIELD macro to decode it.
https://sourceware.org/bugzilla/show_bug.cgi?id=28729
Signed-off-by: Mark Wielaard <mark@klomp.org>
Frank Ch. Eigler [Thu, 8 Sep 2022 13:47:45 +0000 (09:47 -0400)]
PR28284 cont'd, ->winning_headers reset at start of new query
Mark noted we need to ditch the last client ->winning_headers along
with the last ->url.
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>