platform/upstream/elfutils.git
3 years agobackends: Remove tilegx backend.
Mark Wielaard [Sat, 17 Oct 2020 20:30:37 +0000 (22:30 +0200)]
backends: Remove tilegx backend.

Support for the Tilera TILE-Gx processor has been removed or deprecated
in gcc and binutils already. There are no users and there is no way to
test it.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibebl: Remove unused ebl_syscall_abi.
Mark Wielaard [Sat, 17 Oct 2020 19:22:22 +0000 (21:22 +0200)]
libebl: Remove unused ebl_syscall_abi.

GCC11 -Warray-parameter warned about ebl_syscall_abi being inconsistently
declared (once with a pointer to int, once with an array of 6 int elements).
Since ebl_syscall_abi isn't actually used and was only implemented for
3 backends without any tests just remove it.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agoFix bug in read_3ubyte_unaligned_inc
Tom Tromey [Fri, 23 Oct 2020 22:51:10 +0000 (16:51 -0600)]
Fix bug in read_3ubyte_unaligned_inc

The read_3ubyte_unaligned_inc macro calls read_2ubyte_unaligned, but
it should call read_3ubyte_unaligned.

Signed-off-by: Tom Tromey <tom@tromey.com>
3 years agoPR26756: add more prometheus metrics to debuginfod
Frank Ch. Eigler [Wed, 21 Oct 2020 00:24:43 +0000 (20:24 -0400)]
PR26756: add more prometheus metrics to debuginfod

Add an error_count{} family of metrics for each libc/libarchive/http
exception instance created during operation.  Add a family of fdcache*
metrics for tracking fdcache operations and status.  Test via a
injecting a permission-000 empty nothing.rpm in the testsuite.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
3 years agodebuginfod: suppress fdcache prefetching during dwz lookup
Frank Ch. Eigler [Tue, 20 Oct 2020 23:26:04 +0000 (19:26 -0400)]
debuginfod: suppress fdcache prefetching during dwz lookup

During a recent from-scratch reindexing of the rpm/deb corpus at
debuginfod.elfutils.org, we found the fdcache chewed up an abnormal
amount of $TMPDIR space.  This was due to internal .dwz lookups, which
triggered fdcache prefetching as for a webapi query, but there was not
a timely fdcache eviction pass to clean it up again.  Rather than add
that pass, it's better to suppress the prefetching completely, as an
internal .dwz search will only ever need that file, not any others
from the same archive.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
3 years agoPR25461: uninstall /etc/profile.d files for distuninstallcheck
Frank Ch. Eigler [Thu, 8 Oct 2020 15:56:15 +0000 (11:56 -0400)]
PR25461: uninstall /etc/profile.d files for distuninstallcheck

No one uses "make uninstall" except the buildbot.  Let's make it
happy too.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
3 years agoPR25461: add /etc/profile.d files for default $DEBUGINFOD_URLS
Frank Ch. Eigler [Thu, 1 Oct 2020 20:56:49 +0000 (16:56 -0400)]
PR25461: add /etc/profile.d files for default $DEBUGINFOD_URLS

To give distros a simple knob to let their userbase enjoy debuginfod
services, we add a --enable-debuginfod-urls[=URLS] to the configury.
This propagates to $DEBUGINFOD_URLS environment variable settings
in /etc/profile.d/debuginfod.{sh,csh} files.

The default is nothing.  If simply enabled, the current prototype
public server is used.  If enabled with parameters, the builder/distro
can specify a default URL search path of their own.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
3 years agodebuginfod-find.1: Fix formatting on wide consoles
Frank Ch. Eigler [Wed, 7 Oct 2020 23:03:20 +0000 (19:03 -0400)]
debuginfod-find.1: Fix formatting on wide consoles

The SYNOPSIS section looks less funny with missing
.br directives added in.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
3 years agoreadelf: Support showing view pairs in loclists as GNU extension.
Mark Wielaard [Sun, 27 Sep 2020 19:07:12 +0000 (21:07 +0200)]
readelf: Support showing view pairs in loclists as GNU extension.

View pairs are encoded in .debug_loclists as they are encoded in
.debug_locs sections by the GCC compiler. Scan for DW_AT_GNU_locviews
attributes that point to the view pairs just in front of the actual
location lists.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibdwfl: Add ZSTD support.
Mark Wielaard [Fri, 18 Sep 2020 10:49:29 +0000 (12:49 +0200)]
libdwfl: Add ZSTD support.

Newer kernels might be compressed using ZSTD add support to libdwfl open
so we can can automatically read ZSTD compressed files and kernel images.

The support is very similar to the bzip2 and lzma support, but slightly
different. With a bit more macros it could maybe have used the gzip.c
USE_INFLATE code path. But I felt that the many macros didn't really help
understand the code. So the unzip routine has a slightly different code
path for ZSTD.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agodebuginfod: store only canonicalized sref pathnames in database
Frank Ch. Eigler [Fri, 18 Sep 2020 17:03:01 +0000 (13:03 -0400)]
debuginfod: store only canonicalized sref pathnames in database

Since PR25548, we let debuginfod answer /buildid/HEX/source/PATH
queries with both canonicalized and raw PATHs.  It canonicalizes
incoming paths, but still stored the raw paths in the database too.
This near-dupe storage is not needed, since the queries would always
find the canonicalized version too, so stop doing that.  This saves
database space/time.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
3 years agodebuginfod: Fix BUILD_STATIC build.
Mark Wielaard [Tue, 8 Sep 2020 12:12:28 +0000 (14:12 +0200)]
debuginfod: Fix BUILD_STATIC build.

The BUILD_STATIC build, as used by the coverage setup, was broken for
debuginfod because the DUMMY_LIBDEBUGINFOD case was mixed up. It should
include libcurl_LIBS when NOT doing a dummy build.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agodebuginfod-find.c: Fix license block comment. File is GPLv3+ only.
Mark Wielaard [Wed, 16 Sep 2020 14:36:43 +0000 (16:36 +0200)]
debuginfod-find.c: Fix license block comment. File is GPLv3+ only.

The license itself was correct, just the comment to get a copy of
the LGPL was wrong.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agodebuginfod-find: Support compressed (kernel) ELF images.
Mark Wielaard [Tue, 15 Sep 2020 13:43:10 +0000 (15:43 +0200)]
debuginfod-find: Support compressed (kernel) ELF images.

By using dwelf_elf_begin instead of elf_begin we automatically get
support for determining the build-id of compressed (kernel) images.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agoPrepare for 0.181 elfutils-0.181
Mark Wielaard [Tue, 8 Sep 2020 10:27:54 +0000 (12:27 +0200)]
Prepare for 0.181

Set version to 0.181.
Update NEWS and elfutils.spec.in.
Regenerate po/*.po files.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibdw,readelf: Recognize DW_CFA_AARCH64_negate_ra_state
Mark Wielaard [Thu, 3 Sep 2020 15:46:53 +0000 (17:46 +0200)]
libdw,readelf: Recognize DW_CFA_AARCH64_negate_ra_state

DW_CFA_AARCH64_negate_ra_state is used on aarch64 to indicate whether
or not the return address is mangled or not. This has the same value
as the DW_CFA_GNU_window_save. So we have to pass around the e_machine
value of the process or core we are inspecting to know which one to
use.

Note that it isn't actually implemented yet. It needs ARMv8.3 hardware.
If we don't have such hardware it is enough to simply ignore the
DW_CFA_AARCH64_negate_ra_state (and not confuse it with
DW_CFA_GNU_window_save) to get backtraces to work on aarch64.

Add a testcase for eu-readelf --debug-dump=frames to show the value
is correctly recognized. Also don't warn we cannot find any DWARF
if we are just dumping frames (those will come from .eh_frame if
there is no .debug_frame).

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibebl: Handle aarch64 bti, pac bits in gnu property note
Mark Wielaard [Thu, 3 Sep 2020 13:42:32 +0000 (09:42 -0400)]
libebl: Handle aarch64 bti, pac bits in gnu property note

When building with gcc -mbranch-protection= we might get a gnu property
note indicating BTI (Branch Target Identification) and/or PAC (Pointer
Authentication Code) is being used.

Add a small testcase to show eu-readelf -n now properly lists those
bits in the gnu property note.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agoreadelf: base address entry can be first
Mark Wielaard [Tue, 1 Sep 2020 21:32:09 +0000 (23:32 +0200)]
readelf: base address entry can be first

In both debug_ranges and debug_loc a base address entry can be the
first in the range or loc list. If so print the offset and set first
to false. Otherwise don't print the entry list offset, but do set
first to false.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agobackends: Implement aarch64_dynamic_tag_name and aarch64_dynamic_tag_check
Mark Wielaard [Fri, 28 Aug 2020 21:19:26 +0000 (23:19 +0200)]
backends: Implement aarch64_dynamic_tag_name and aarch64_dynamic_tag_check

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibelf: Sync elf.h from glibc.
Mark Wielaard [Fri, 28 Aug 2020 17:13:00 +0000 (19:13 +0200)]
libelf: Sync elf.h from glibc.

Gets us DT_AARCH64_BTI_PLT and DT_AARCH64_PAC_PLT.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agoelflint: Handle .debug_line_str as .debug_str
Mark Wielaard [Fri, 4 Sep 2020 23:17:06 +0000 (01:17 +0200)]
elflint: Handle .debug_line_str as .debug_str

The new DWARF5 .debug_line_str is identical to the .debug_str section.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibdw: Remove duplicate local wildcards from map file.
Mark Wielaard [Thu, 3 Sep 2020 12:57:07 +0000 (14:57 +0200)]
libdw: Remove duplicate local wildcards from map file.

We only need one local: * entry to capture all private local symbols.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibdwfl: do not dlopen libdebuginfod.so in --disable-libdebuginfod mode
Dmitry V. Levin [Thu, 20 Aug 2020 20:27:24 +0000 (23:27 +0300)]
libdwfl: do not dlopen libdebuginfod.so in --disable-libdebuginfod mode

debuginfod-client.c used to try to dlopen libdebuginfod.so even if
libdebuginfod was completely disabled using --disable-libdebuginfod.

Fix this by disabling build of debuginfod-client.c and disabling all
__libdwfl_debuginfod_* invocations in --disable-libdebuginfod mode.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agoreadelf: It is not an error if there are no line number statements
Mark Wielaard [Wed, 26 Aug 2020 12:27:46 +0000 (14:27 +0200)]
readelf: It is not an error if there are no line number statements

It can happen that there are no line number statements at the end of
a debug line section. So don't check that there are any more bytes
after the last file entry. And print "No line number statements."

libdw already got this corner case correct.

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibdw: Rename check_constant_offset to is_constant_offset.
Mark Wielaard [Tue, 25 Aug 2020 21:31:29 +0000 (23:31 +0200)]
libdw: Rename check_constant_offset to is_constant_offset.

The check_constant_offset code in dwarf_getlocation.c code is not very
intuitive, rename it to is_constant_offset and update the documentation.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
3 years agolibelf: Fixup SHF_COMPRESSED sh_addralign in elf_update if necessary.
Mark Wielaard [Wed, 19 Aug 2020 21:41:24 +0000 (23:41 +0200)]
libelf: Fixup SHF_COMPRESSED sh_addralign in elf_update if necessary.

In elf_getdata.c we have the following to compensate for possibly
bad sh_addralign values of compressed sections:

      /* Compressed data has a header, but then compressed data.
         Make sure to set the alignment of the header explicitly,
         don't trust the file alignment for the section, it is
         often wrong.  */
      if ((flags & SHF_COMPRESSED) != 0)
        {
          entsize = 1;
          align = __libelf_type_align (elf->class, ELF_T_CHDR);
        }

Which makes sure the d_data alignment is correct for the Chdr struct
at the start of the compressed section.

But this means that if a user just reads such a compressed section
without changing it, and then tries to write it out again using
elf_update they get an error message about d_align and sh_addralign
being out of sync.

We already correct obviously incorrect sh_entsize fields.
Do the same for the sh_addralign field of a SHF_COMPRESSED section.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoOnly typedef Ebl once.
Mark Wielaard [Sun, 19 Jul 2020 19:51:16 +0000 (21:51 +0200)]
Only typedef Ebl once.

Since commit 287a18452 libasm.h defines an opague Ebl handle.
This is fine, except for (internal) code that also includes libebl.h.
Since C11 having multiple typedefs for the same thing is fine, but we
do build using GNU/C99. This also allows multiple same typedefs, except
for (very) old GCCs.

This only affects internal code, since libebl.h isn't a public header.

For internal code, only add the typedef in libebl.h when libasm.h
hasn't been included. Make sure all code that includes both headers
includes libasm.h first.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoelfclassify: Handle fwrite to stdout failing.
Mark Wielaard [Sun, 19 Jul 2020 17:36:38 +0000 (19:36 +0200)]
elfclassify: Handle fwrite to stdout failing.

In theory an fwrite can fail, if so, signal it by calling issue ().

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoconfigure.ac: Set -DBAD_FTS=1 also for CXXFLAGS.
Mark Wielaard [Fri, 17 Jul 2020 23:53:29 +0000 (01:53 +0200)]
configure.ac: Set -DBAD_FTS=1 also for CXXFLAGS.

debuginfod.cxx checks whether or not BAD_FTS is defined.
This only matters on old 32bit arches.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl, src: Replace some asserts with proper check or error messages.
Mark Wielaard [Sat, 4 Jul 2020 22:33:38 +0000 (00:33 +0200)]
libdwfl, src: Replace some asserts with proper check or error messages.

library code really shouldn't assert and for utilities a proper
error message is better than crashing with an assert.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibasm: Make libasm.h include work without relying on any other include.
Mark Wielaard [Sat, 4 Jul 2020 22:13:35 +0000 (00:13 +0200)]
libasm: Make libasm.h include work without relying on any other include.

The public headers should be usable when includes as is.
libasm.h wasn't because it was using gelf.h data structures without
include gelf.h. Include it now in libasm.h.

Add a new testcase run-test-includes.sh to test all public headers
can be included "standalone".

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod: DEBUGINFOD_URLS should accept scheme-free urls
Alice Zhang [Fri, 3 Jul 2020 17:37:34 +0000 (13:37 -0400)]
debuginfod: DEBUGINFOD_URLS should accept scheme-free urls

Check scheme instead of effective url so that user may abbreviate
DEBUGINFOD_URL. Add one test for scheme free http url.

Notice that libcurl does not provide an almighty scheme free url
support, /path/to/something without FILE:// can not be recognized
in most circumstances, therefore for the neatness of our code
structure, DEBUGINFOD_ URL of scheme "FILE" must be input as URI.

Signed-off-by: Alice Zhang <alizhang@redhat.com>
4 years agodebuginfod: Add --disable-libdebuginfod and --enable-libdebuginfod=dummy.
Mark Wielaard [Fri, 19 Jun 2020 17:41:08 +0000 (19:41 +0200)]
debuginfod: Add --disable-libdebuginfod and --enable-libdebuginfod=dummy.

Make it possible to build just the debuginfod client or to create a
dummy libdebuginfod that doesn't link against libcurl. The dummy library
can be used for bootstrapping. For testing purposes you can also build
debuginfod against the dummy libdebuginfod but then the debuginfod
server will not be able to do delegation.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoPR26195: adapt debuginfod to API change in libmicrohttpd-0.9.71
Frank Ch. Eigler [Thu, 2 Jul 2020 14:52:48 +0000 (14:52 +0000)]
PR26195: adapt debuginfod to API change in libmicrohttpd-0.9.71

To make our code build with -Werror as well as against older libmicrohttpd,
we must conditionalize the data type (int vs. enum) returned by callbacks
and some mhd functions.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agolibdwfl: read_address should use increasing address in intuit_kernel_bounds
Mark Wielaard [Sun, 28 Jun 2020 13:27:25 +0000 (15:27 +0200)]
libdwfl: read_address should use increasing address in intuit_kernel_bounds

In kernels from 4.14 up to 4.19 in /proc/kallsyms there are special
__entry_SYSCALL_64_trampoline symbols. The problem is that they come
after the last kernel address, but before the module addresses.
And they are (much) smaller than the start address we found. This
confuses intuit_kernel_bounds and makes it fail.

Make sure to check read_address returns an increasing address when
searching for the end.

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

Reported-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod: Make sure handle_data can be allocated and is always freed.
Mark Wielaard [Tue, 16 Jun 2020 22:08:23 +0000 (00:08 +0200)]
debuginfod: Make sure handle_data can be allocated and is always freed.

When allocating handle_data we should check for out of memory failures.
Also when the allocation has succeeded make sure we always clean up by
going to out1 on any future errors. So move the curl_multi_init call
earlier, because that goes to out0 on failure.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod: Fix build_id hexadecimal length check.
Mark Wielaard [Tue, 16 Jun 2020 22:03:37 +0000 (00:03 +0200)]
debuginfod: Fix build_id hexadecimal length check.

When is debuginfod_query_server is given an hexadecimal string as
build-id build_id_len will be zero. We were checking the size of
the build_id_bytes destination string instead of the string length
of build_id input string. Make sure the input string is not too
big or strcpy might overwrite then end of the build_id_bytes array.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod: Make sure suffix can place zero terminator when copying filename
Mark Wielaard [Tue, 16 Jun 2020 21:56:45 +0000 (23:56 +0200)]
debuginfod: Make sure suffix can place zero terminator when copying filename

We need to make sure that we can always place a zero terminator at
the end of suffix when we are copying the filename. So add one more
char to the suffix array. And make sure that we can always add an
extra escape character when we need to escape the current character.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod: Handle not being able to fopen interval_path.
Mark Wielaard [Tue, 16 Jun 2020 21:53:03 +0000 (23:53 +0200)]
debuginfod: Handle not being able to fopen interval_path.

Although we check for and/or create the interval_path right before,
there is still a possibility that the fopen call fails. Handle that
as if the file is unreadable.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoar, ranlib: Call fchown before fchmod, explicitly check and ignore errors.
Mark Wielaard [Tue, 16 Jun 2020 21:22:56 +0000 (23:22 +0200)]
ar, ranlib: Call fchown before fchmod, explicitly check and ignore errors.

In ar and ranlib we don't mind if the fchown call fails (it normally
would, then the file simply gets own by the current user). We used to
call fchown before fchmod, but that might ignore (or reset) some mode
flags, so call fchown first, then try fchmod (like we already do in
elfcompress). Also explicitly test and then ignore any errors for
chown. We used to do some asm trick, but that confuses some static
analyzers (and it is somewhat unreadable). Also split out the giant
if statements to make them a little bit more understandable.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: Flag an error if CIE return_address_register is invalid.
Mark Wielaard [Tue, 16 Jun 2020 16:24:43 +0000 (18:24 +0200)]
libdwfl: Flag an error if CIE return_address_register is invalid.

If the CIE return address register is invalid (unknown) for the
architecture immediately flag an error and return.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: When we find a compressed image, use that, don't search for others
Mark Wielaard [Tue, 16 Jun 2020 16:19:45 +0000 (18:19 +0200)]
libdwfl: When we find a compressed image, use that, don't search for others

We try to find a compressed vmlinux image ending with either .gz, bz2 or
xz. Stop searching if we find one. Otherwise we will leak a file descriptor
for an earlier one we opened.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoelflint: Explicitly check and ignore elf_compress error.
Mark Wielaard [Tue, 16 Jun 2020 16:14:37 +0000 (18:14 +0200)]
elflint: Explicitly check and ignore elf_compress error.

We just want to make sure that any section data is decompressed before
use, if the section was already decompressed that is fine, so just ignore
any errors. The make this more clear, explicitly check for errors, then
don't do anything. This is better than silently ignoring since everywhere
else in the code we do explicitly check for errors.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdw: Add missing FALLTHROUGH in execute_cfi.
Mark Wielaard [Tue, 16 Jun 2020 16:05:59 +0000 (18:05 +0200)]
libdw: Add missing FALLTHROUGH in execute_cfi.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agobackends: Make the reloc_nametable zero element an one char array.
Mark Wielaard [Tue, 16 Jun 2020 15:53:08 +0000 (17:53 +0200)]
backends: Make the reloc_nametable zero element an one char array.

We are using the reloc_nametable zero element as an char array.
So make that element an actual array (we are actually after one
of the next string arrays in the table).

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agotests: Use #/usr/bin/env bash in scripts that use bash
Mark Wielaard [Mon, 15 Jun 2020 22:25:47 +0000 (00:25 +0200)]
tests: Use #/usr/bin/env bash in scripts that use bash

Some systems don't have bash in /bin.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoelfutils/configure.ac: use $READELF, not readelf
Sergei Trofimovich [Sun, 14 Jun 2020 19:28:07 +0000 (20:28 +0100)]
elfutils/configure.ac: use $READELF, not readelf

Allow user to specify own readelf. Use detected readelf,
not 'readelf'.

Noticed when was building elfutils on tuple-prefixed toolchain:

```
checking whether the compiler generates build-ids...
  ./configure: line 5197: readelf: command not found
no
```

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agotests: Add GCOV flags when necessary.
Mark Wielaard [Thu, 11 Jun 2020 17:07:28 +0000 (19:07 +0200)]
tests: Add GCOV flags when necessary.

The nlist-test has a special compile rule, make sure it gets the
GCOV flags when configuring with --enable-gcov.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoPrepare for 0.180 elfutils-0.180
Mark Wielaard [Thu, 11 Jun 2020 14:09:03 +0000 (16:09 +0200)]
Prepare for 0.180

Set version to 0.180.
Update NEWS and elfutils.spec.in.
Set copyright year in printversion.
Regenerate po/*.po files.
Update .gitignore.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibebl: Remove Ebl struct size check and MODVERSION string.
Mark Wielaard [Wed, 10 Jun 2020 18:55:58 +0000 (20:55 +0200)]
libebl: Remove Ebl struct size check and MODVERSION string.

We used to do several sanity checks when the ebl backend libraries
were loaded to make sure there was no version mismatch. When initializing
the backend we passed the current Ebl struct size so the library could
check it supported the given Ebl struct and we checked that the init
method returned the correct build time module version string. Neither
are necessary now that the backends are builtin.

Remove both the struct size check and the MODVERSION string (which
wasn't actually checked anymore). Make the init function return the
given Ebl handle or NULL on error (no init function currently indicates
any error).

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agonm: Handle corrupt symbol name table.
Mark Wielaard [Sun, 7 Jun 2020 14:13:13 +0000 (16:13 +0200)]
nm: Handle corrupt symbol name table.

We try to sort symbol by name (when neither -n nor -p are given).
This could crash if the symbol name table was corrupt. Use elf_strptr
to get the symbol name and use the empty string in case a name couldn't
be found.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agonm: Explicitly print weak 'V' or 'T' and common 'C' symbols.
Mark Wielaard [Sat, 6 Jun 2020 23:02:52 +0000 (01:02 +0200)]
nm: Explicitly print weak 'V' or 'T' and common 'C' symbols.

Mimic binutils nm for bsd and posix formats which uses 'V' for weak
symbols, 'C' for common symbols and 'T' for weak functions. Also fix
some formatting issues. Don't print undefined addresses as zeros, but
make sure there is enough padding instead. Just print UNIQUE for
GNU_UNIQUE to make it fit 6 chars, like other binding names in sysv
format.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibelf: Sync elf.h from glibc.
Mark Wielaard [Thu, 4 Jun 2020 14:38:22 +0000 (16:38 +0200)]
libelf: Sync elf.h from glibc.

There is now finally a PT_GNU_PROPERTY define.
Also EM_ARC_COMPACT2 got renamed to EM_ARCV2.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agosize: Also obey radix printing for bsd format.
Mark Wielaard [Thu, 14 May 2020 21:52:54 +0000 (23:52 +0200)]
size: Also obey radix printing for bsd format.

eu-size already prints according to the given radix for sysv format,
but not for the bsd format. Fix that.

Reported-by: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibcpu: Free unused new bitfield on error in i386_parse.y new_bitfield.
Mark Wielaard [Sat, 9 May 2020 21:31:05 +0000 (23:31 +0200)]
libcpu: Free unused new bitfield on error in i386_parse.y new_bitfield.

GCC10 -fanalyzer detected we didn't free the newly created bitfield
on error. Make sure to free it before returning.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: Return failure from dwfl_standard_find_debuginfo for NULL module.
Mark Wielaard [Sat, 9 May 2020 20:09:40 +0000 (22:09 +0200)]
libdwfl: Return failure from dwfl_standard_find_debuginfo for NULL module.

GCC10 -fanalyzer plus -flto notices that some functions called by
dwfl_standard_find_debuginfo check that the given module isn't NULL,
but others expect it to be non-NULL. Just return a failure immediately
when a NULL mod is passed to dwfl_standard_find_debuginfo.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agosrc: Check ebl_openbackend result before using ebl handle.
Mark Wielaard [Sat, 9 May 2020 19:05:31 +0000 (21:05 +0200)]
src: Check ebl_openbackend result before using ebl handle.

GCC10 -fanalyzer plus -flto sees that ebl_openbackend can fail and
return NULL. Most of the time we will get a dummy ebl, but in case
of out of memory or corrupt ELF header it might return NULL. Make
sure that we report a (fatal) error in that case in all tools.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibelf: Check for NULL shdr in elf_strptr.
Mark Wielaard [Sat, 9 May 2020 03:02:25 +0000 (05:02 +0200)]
libelf: Check for NULL shdr in elf_strptr.

GCC10 -fanalyzer with -flto notices __elf64_getshdr_rdlock can fail
and because the result isn't checked in elf_strptr it can cause a
dereference of NULL.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibelf: Check __gelf_getehdr_rdlock call doesn't fail in elf_getdata.
Mark Wielaard [Sat, 9 May 2020 01:41:56 +0000 (03:41 +0200)]
libelf: Check __gelf_getehdr_rdlock call doesn't fail in elf_getdata.

GCC10 -fanalyzer with -flto notices __gelf_getehdr_rdlock can fail
and that the result of the call in __libelf_set_rawdata_wrlock isn't
checked, which can cause a dereference of NULL.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agotests: Make sure to not call memcmp with NULL arguments.
Mark Wielaard [Fri, 8 May 2020 22:18:20 +0000 (00:18 +0200)]
tests: Make sure to not call memcmp with NULL arguments.

GCC10 -fanalyzer thinks we are too clever:

elfputzdata.c: In function ‘main’:
elfputzdata.c:178:8: warning: use of possibly-NULL ‘orig_buf’ where
                     non-null expected [CWE-690]
                     [-Wanalyzer-possible-null-argument]
  178 |     && memcmp (orig_buf, d->d_buf, orig_size) == 0)

orig_buf can only be NULL when orig_size is zero, but it might still
be undefined behaviour. So don't try to be too smart and just check
whether we actually have an buffer.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: Cleanup user_core resources on failure in dwfl_core_file_report.
Mark Wielaard [Fri, 8 May 2020 21:35:12 +0000 (23:35 +0200)]
libdwfl: Cleanup user_core resources on failure in dwfl_core_file_report.

GCC10 -fanalyzer noticed that we allocate, but don't always cleanup the
dwfl->user_core if it wasn't set yet on error. In theory dwfl_module_end
should take care of it, but it is cleaner and less confusing to just do
it here.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdw: Skip imported compiler_units in libdw_visit_scopes walking DIE tree
Mark Wielaard [Fri, 8 May 2020 10:18:41 +0000 (12:18 +0200)]
libdw: Skip imported compiler_units in libdw_visit_scopes walking DIE tree

Some gcc -flto versions imported other top-level compile units,
skip those. Otherwise we'll visit various DIE trees multiple times.

Note in the testcase that with newer GCC versions function foo is
fully inlined and does appear only once (as declared, but not as
separate subprogram).

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdw: Use correct CU to resolve file names in dwarf_decl_file.
Mark Wielaard [Fri, 8 May 2020 10:33:11 +0000 (12:33 +0200)]
libdw: Use correct CU to resolve file names in dwarf_decl_file.

dwarf_decl_file uses dwarf_attr_integrate to get the DW_AT_decl_file
attribute. This means the attribute might come from a different DIE
in a different CU. If so, we need to use the CU associated with the
attribute, not the original DIE, to resolve the file name.

Also add a bit more documentation to dwarf_attr_integrate explaining
that the attribute returned might come from a different CU (and even
different Dwarf).

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: Handle debugaltlink in dwfl_standard_find_debuginfo.
Mark Wielaard [Thu, 30 Apr 2020 21:57:26 +0000 (23:57 +0200)]
libdwfl: Handle debugaltlink in dwfl_standard_find_debuginfo.

When we fall back to the debuginfod client then we need to do the
same trick we do for local lookups in dwfl_build_id_find_debuginfo.
If the debug file (dw) is already set, then we must be looking for
the altfile. But we cannot use the actual file/path name given as
hint. We'll have to lookup the alt file "build-id". Because the
debuginfod client only handles build-ids.

Previously we would use the build-id of the main file which meant
the debuginfod client would give us another copy of the debug file,
which would then be set as its own altfile. This caused lots of
confusion...

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: Fix double free on failure path in gzip.c.
Mark Wielaard [Sun, 26 Apr 2020 00:10:41 +0000 (02:10 +0200)]
libdwfl: Fix double free on failure path in gzip.c.

GCC10 -fanalyzer found a double free when openstream failed. When
openstream fails __libdw_gunzip will call fail, which frees the
state->buffer. But openstream can call zlib_fail, which will also
call fail. Instead of calling zlib_fail, just return the error
that zlib_fail would have returned.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdw: Call Dwarf oom_handler() when malloc fails in __libdw_alloc_tail.
Mark Wielaard [Sat, 25 Apr 2020 23:41:27 +0000 (01:41 +0200)]
libdw: Call Dwarf oom_handler() when malloc fails in __libdw_alloc_tail.

GCC10 -fanalyzer found a possibly-NULL dereference after a failed
malloc in __libdw_alloc_tail. In this case we should call the Dwarf
oom_handler as is done in other places where an essential malloc
call fails. The oom_handler cannot return and will likely just abort.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibasm: Fix double fclose in asm_end.
Mark Wielaard [Sat, 25 Apr 2020 23:20:57 +0000 (01:20 +0200)]
libasm: Fix double fclose in asm_end.

GCC10 -fanalyzer found a double fclose in asm_end. asm_end can call
text_end, which calls fclose and checks for errors, then asm_end
calls __libasm_finictx which can call fclose again (but doesn't
check for errors). Call fflush in text_end instead. fflush will
generate the same error fclose would if something went wrong writing
out the file.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibelf: Fix double free in __libelf_compress on error path.
Mark Wielaard [Fri, 24 Apr 2020 23:21:12 +0000 (01:21 +0200)]
libelf: Fix double free in __libelf_compress on error path.

In commit 2092865a7e589ff805caa47e69ac9630f34d4f2a
"libelf: {de,}compress: ensure zlib resource cleanup" we added a
call to deflate_cleanup to make sure all resources were freed.
As GCC10 -fanalyzer points out that could cause a double free
of out_buf. Fix by removing the free (out_buf) in __libelf_compress.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agotests: Run run-varlocs-self.sh for object files with --exprlocs.
Mark Wielaard [Fri, 17 Apr 2020 10:31:15 +0000 (12:31 +0200)]
tests: Run run-varlocs-self.sh for object files with --exprlocs.

The varlocs test relies on finding addresses for the CUs, even in
object files. This might not be true (for example when building with
gcc -flto, which only emits partial, type only, debuginfo). Split
running the self tests in running on executables and shared libraries
as normal, but run object files with --exprlocs to test that output
too (and not require addresses).

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agotests: Build test-nlist with minimal CFLAGS to guarantee symbol order.
Mark Wielaard [Fri, 17 Apr 2020 10:21:46 +0000 (12:21 +0200)]
tests: Build test-nlist with minimal CFLAGS to guarantee symbol order.

test_nlist checks its own symbol table, and expects various symbols
to be in the order as specified in the source file. Explicitly set
minimal CFLAGS.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod sysconfig: add /var/lib/pulp as default search path
Frank Ch. Eigler [Tue, 21 Apr 2020 21:11:18 +0000 (17:11 -0400)]
debuginfod sysconfig: add /var/lib/pulp as default search path

Red Hat Satellite 6 (pulp era) stores RPMs under this hierarchy, so if
a user is fortunate enough to have debuginfod on such a machine, we
might as well index that.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agolibdw, readelf: Handle GCC LTO .gnu.debuglto_ prefix.
Mark Wielaard [Fri, 17 Apr 2020 09:31:40 +0000 (11:31 +0200)]
libdw, readelf: Handle GCC LTO .gnu.debuglto_ prefix.

GCC puts (partial) DWARF debuginfo into sections prefixed with
.gnu.debuglto_. Handle those sections as if they are normal .debug
sections (which they are). This allows showing the DWARF that gcc
puts into ET_REL files compiled with -flto.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoelflint: Allow SHF_EXCLUDE as generic section flag when --gnu is given.
Mark Wielaard [Thu, 16 Apr 2020 16:48:58 +0000 (18:48 +0200)]
elflint: Allow SHF_EXCLUDE as generic section flag when --gnu is given.

Strictly speaking SHF_EXCLUDE is a processor specific section flag,
but it is used generically in the GNU toolchain. For example when
adding .gnu.lto_ sections.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibcpu: Replace assert with goto invalid_op for bad prefix.
Mark Wielaard [Thu, 16 Apr 2020 13:41:57 +0000 (15:41 +0200)]
libcpu: Replace assert with goto invalid_op for bad prefix.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agolibdwfl: Initialize bits to NULL in dwfl_standard_find_debuginfo for LTO.
Mark Wielaard [Thu, 16 Apr 2020 15:45:31 +0000 (17:45 +0200)]
libdwfl: Initialize bits to NULL in dwfl_standard_find_debuginfo for LTO.

GCC10 LTO is too smart (and somewhat cryptic):

    find-debuginfo.c: In function ‘dwfl_standard_find_debuginfo’:
    debuginfod-client.c:85:8: error: ‘bits’ may be used uninitialized
    in this function [-Werror=maybe-uninitialized]
    find-debuginfo.c:360:24: note: ‘bits’ was declared here
    lto1: all warnings being treated as errors

So it inlines __libdwfl_debuginfod_find_debuginfo into
dwfl_standard_find_debuginfo and since it cannot see into the
function pointer (*fp_debuginfod_find_debuginfo), it assumes that
build_id_bit (== bits in dwfl_standard_find_debuginfo) will be used
by the called function and it might not be initialized.
But if you read the code the there is a check for build_id_len > 0
to see whether bits is or isn't initialized before using bits.
But gcc isn't smart enough to figure that out.

Maybe that actually should be an heuristic gcc lto should use.
If the callchain I am inlining is so deep that I cannot figure out
maybe-uninitialized variables anymore I should stop inlining.

For now just help GCC out and initialize bits to NULL.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoconfig: chmod uploaded dir and files to make them readable.
Mark Wielaard [Mon, 30 Mar 2020 12:39:43 +0000 (14:39 +0200)]
config: chmod uploaded dir and files to make them readable.

Default file permissions on sourceware have changed. Make sure that
the upload-release.sh script sets the permissions right.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoPrepare for 0.179 elfutils-0.179
Mark Wielaard [Mon, 30 Mar 2020 11:04:00 +0000 (13:04 +0200)]
Prepare for 0.179

Set version to 0.179.
Update NEWS and elfutils.spec.in.
Regenerate po/*.po files.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoUpdate Ukrainian translation
Yuri Chornoivan [Sat, 28 Mar 2020 13:03:22 +0000 (15:03 +0200)]
Update Ukrainian translation

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
4 years agodebuginfod: Document and sanity check debuginfod_add_http_header format.
Mark Wielaard [Sun, 29 Mar 2020 22:57:30 +0000 (00:57 +0200)]
debuginfod: Document and sanity check debuginfod_add_http_header format.

Document and sanity check the format of the header string form that can
be passed to debuginfod_add_http_header. It should contain precisely
one colon, which cannot be the first or last character. And the function
should only be used to add optional headers, not replace any existing
standard ones. Anything else isn't supported.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod-client default_progressfn: formatting fix
Frank Ch. Eigler [Sun, 29 Mar 2020 19:10:37 +0000 (15:10 -0400)]
debuginfod-client default_progressfn: formatting fix

The saga of clean $DEBUGINFOD_PROGRESS=1 output continues.  Previous
code would sometimes insert a \n (a blank line) into the output
stream, even if the target file was found in a cache and thus the
progressfn was never called.  New code sets a client flag to track
this case more precisely.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25728: disable debuginfod --port=0
Mark Wielaard [Sat, 28 Mar 2020 20:42:04 +0000 (16:42 -0400)]
PR25728: disable debuginfod --port=0

When starting debuginfod with --port=0 it would start using a random port
(possibly different for ipv4 and ipv6). This seems to be an accidental
and not very useful functionality. Just produce an error when started
with --port=0.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25739: debuginfod correct mtime for fdcache'd files
Frank Ch. Eigler [Sat, 28 Mar 2020 19:57:09 +0000 (15:57 -0400)]
PR25739: debuginfod correct mtime for fdcache'd files

Files extracted from archives then left in the fdcache need to get get
their mtime set consistently, so that a subsequent cache-hit fetch can
relay the correct mtime to clients.

Reported-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25722: debuginfod-find: accept /path/names in place of buildid hex
Frank Ch. Eigler [Sat, 28 Mar 2020 00:47:45 +0000 (20:47 -0400)]
PR25722: debuginfod-find: accept /path/names in place of buildid hex

Extend the debuginfod-find command line interface to permit
/file/names instead of only buildid hexadecimal strings.

v2: move code into debuginfod-find; client API remains buildid only.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agodebuginfod: User-Agent and X-Forwarded-For header relay
Frank Ch. Eigler [Wed, 25 Mar 2020 03:46:30 +0000 (23:46 -0400)]
debuginfod: User-Agent and X-Forwarded-For header relay

Extend the debuginfod client API with a function to stuff outgoing
headers into libcurl http transfers.  Use this from debuginfod so
federated trees of debuginfod/httpd can trace back to to the
originating client for administrative purposes.  Docs & test included.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25448: debuginfod: add transfer performance metrics
Frank Ch. Eigler [Thu, 26 Mar 2020 20:44:20 +0000 (16:44 -0400)]
PR25448: debuginfod: add transfer performance metrics

We now export metrics related to the time taken and data sent,
from which prometheus type tools can compute nice time series
with averages.

http_responses_duration_milliseconds_count{code="200"} 63
http_responses_duration_milliseconds_count{code="404"} 2
http_responses_duration_milliseconds_count{code="503"} 1
http_responses_duration_milliseconds_sum{code="200"} 66
http_responses_duration_milliseconds_sum{code="404"} 2
http_responses_duration_milliseconds_sum{code="503"} 0
http_responses_transfer_bytes_count{code="200"} 63
http_responses_transfer_bytes_count{code="404"} 2
http_responses_transfer_bytes_count{code="503"} 1
http_responses_transfer_bytes_sum{code="200"} 425177
http_responses_transfer_bytes_sum{code="404"} 18
http_responses_transfer_bytes_sum{code="503"} 37

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25583: debuginfod: conditionally prefer bsdtar to dpkg for .deb handling
Frank Ch. Eigler [Fri, 27 Mar 2020 01:32:40 +0000 (21:32 -0400)]
PR25583: debuginfod: conditionally prefer bsdtar to dpkg for .deb handling

Prefer /usr/bin/dpkg-deb if installed, as normal on a debian system.

Suggested-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25583: debuginfod: prefer bsdtar to dpkg for .deb handling
Frank Ch. Eigler [Wed, 25 Mar 2020 14:55:53 +0000 (10:55 -0400)]
PR25583: debuginfod: prefer bsdtar to dpkg for .deb handling

It turns out a bsdtar subshell can do the job of dpkg-deb.
bsdtar comes from/with libarchive so it should be available
everywhere.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agodebuginfod: document and workaround fedora31 zstd compression
Frank Ch. Eigler [Thu, 26 Mar 2020 17:48:20 +0000 (13:48 -0400)]
debuginfod: document and workaround fedora31 zstd compression

Old enough (even RHEL8 era) rpm/libarchive tools cannot grok fedora31
zstd-compressed rpms.  Disable those tests if necessary.  Document -Z
based workaround for these debuginfod users.

https://fedoraproject.org/wiki/Changes/Switch_RPMs_to_zstd_compression

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agotests: Add missing debuginfod-rpms/fedora31/hello3-*.rpm to EXTRA_DIST.
Mark Wielaard [Thu, 26 Mar 2020 17:01:29 +0000 (18:01 +0100)]
tests: Add missing debuginfod-rpms/fedora31/hello3-*.rpm to EXTRA_DIST.

The new rpms were used in the new test. Make sure they are in the dist
tar ball.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agoPR25548: CURLOPT_PATH_AS_IS backward compatibility
Frank Ch. Eigler [Thu, 26 Mar 2020 15:12:49 +0000 (11:12 -0400)]
PR25548: CURLOPT_PATH_AS_IS backward compatibility

old libcurl lacks the CURL_AT_LEAST_VERSION macro, so use
LIBCURL_VERSION_NUM testing instead.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoPR25548: CURLOPT_PATH_AS_IS backward compatibility
Frank Ch. Eigler [Thu, 26 Mar 2020 15:12:49 +0000 (11:12 -0400)]
PR25548: CURLOPT_PATH_AS_IS backward compatibility

libcurl < 7.42 lacks the CURLOPT_PATH_AS_IS flag, but extraneous
client-side canonicalization is mostly harmless.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Reported-by: Mark Wielaard <mark@klomp.org>
4 years agoPR25548: support canonicalized source-path names in debuginfod webapi
Frank Ch. Eigler [Mon, 23 Mar 2020 19:33:56 +0000 (15:33 -0400)]
PR25548: support canonicalized source-path names in debuginfod webapi

Programs are sometimes compiled with source path names containing
noise like /./ or // or /foo/../, and these survive into DWARF.  This
code allows either raw or canonicalized pathnames in the webapi, by
letting the client pass things verbatim, and letting the server
store/accept both raw and canonicalized path names for source files.
Tests included & docs updated.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Reported-by: Eli Schwartz <eschwartz@archlinux.org>
Tested-by: Eli Schwartz <eschwartz@archlinux.org>
4 years agoPR25367: improve debuginfod webapi logging
Frank Ch. Eigler [Wed, 25 Mar 2020 01:57:59 +0000 (21:57 -0400)]
PR25367: improve debuginfod webapi logging

Improve debuginfod logging to show webapi query results including
http status, sizes, and processing times.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agoUpdate mailinglist subscription info.
Mark Wielaard [Wed, 25 Mar 2020 22:22:55 +0000 (23:22 +0100)]
Update mailinglist subscription info.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agodebuginfod-client thinko: non-default progressfn extra output
Frank Ch. Eigler [Wed, 25 Mar 2020 01:30:02 +0000 (21:30 -0400)]
debuginfod-client thinko: non-default progressfn extra output

A previous commit changed the default_progressfn output format
to \rFOOBAR, to be terminated by an \n when the download finished.
The \n terminator was conditional on the wrong thing (env var
setting, rather than actual progressfn setting), so the \n could
be printed even if an app overrode the default.

4 years agodebuginfod-find: Correct error check for -v source combo
Frank Ch. Eigler [Tue, 24 Mar 2020 19:01:58 +0000 (15:01 -0400)]
debuginfod-find: Correct error check for -v source combo

Hardcoding argv[2] is wrong in presence of -v option.  Code
immediately following did the correct argv[] indexing already.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
4 years agotests: Fix getphdrnum and run-lfs-symbols.sh testcase.
Mark Wielaard [Mon, 23 Mar 2020 22:57:51 +0000 (23:57 +0100)]
tests: Fix getphdrnum and run-lfs-symbols.sh testcase.

getphdrnum.c didn't include config.h which is why run-lfs-symbols.sh
flagged it for containing bad (non-lfs) symbols.

run-lfs-symbols.sh was still checking the libebl modules, which we
don't create anymore. But it didn't fail the test for non-existing
tests. Add some extra logging and explicitly check files exist.

Signed-off-by: Mark Wielaard <mark@klomp.org>
4 years agotests: Add testcase for elf_getphdrnum with more than 65535 entries.
Mark Wielaard [Sun, 22 Mar 2020 22:14:24 +0000 (23:14 +0100)]
tests: Add testcase for elf_getphdrnum with more than 65535 entries.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Omar Sandoval <osandov@fb.com>
4 years agolibelf: handle PN_XNUM in elf_getphdrnum before shdr 0 is cached
Omar Sandoval [Wed, 18 Mar 2020 20:18:51 +0000 (13:18 -0700)]
libelf: handle PN_XNUM in elf_getphdrnum before shdr 0 is cached

__elf_getphdrnum_rdlock() handles PN_XNUM by getting sh_info from
elf->state.elf{32,64}.scns.data[0].shdr.e{32,64}. However, that is only
a cache that may or may not have been populated by elf_begin() or
elf{32,64}_getshdr(); if it hasn't been cached yet, elf_getphdrnum()
returns 65535 (the value of PN_XNUM) instead. We should explicitly get
the shdr if it isn't cached.

Signed-off-by: Omar Sandoval <osandov@fb.com>
4 years agodebuginfod client API: add get_url function
Frank Ch. Eigler [Sat, 21 Mar 2020 01:33:52 +0000 (21:33 -0400)]
debuginfod client API: add get_url function

This function lets a client know, during or after a progressfn
callback, what the url of the winning outgoing download is/was.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>