To better support cross-compilation Gentoo provides a way
to configure system without 'gcc' binary and only provide
tool-prefixed tools, like 'x86_64-pc-linux-gnu-gcc'.
The packages are built as ./configure --host=x86_64-pc-linux-gnu.
In https://bugs.gentoo.org/718872 Agostino Sarubbo found
a few test failures that use hardcoded 'gcc' instead of
expected ${CC}. The change propagates detected ${CC} at
configure time to test scripts.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Timm Bäder [Fri, 8 Jan 2021 08:04:49 +0000 (09:04 +0100)]
strip: Remove no_symtab_updates() function
The no_symtab_updates() function was being called at the beginning of
all case labels in this switch, so we can just call it once before the
switch. Then it only has one call-site, so inline this short function
there.
Timm Bäder [Fri, 8 Jan 2021 08:04:47 +0000 (09:04 +0100)]
strip: Pull relocate() info file scope
Pull relocate() info file scope and get rid of a nested function this
way. Refactor remove_debug_relocations() to minimize the parameters we
need to pass to relocate().
Mark Wielaard [Tue, 12 Jan 2021 10:35:10 +0000 (11:35 +0100)]
elflint: Recognize SHF_GNU_RETAIN as extra section flag.
SHF_GNU_RETAIN is like SHF_LINK_ORDER it can appear on any section
and should be ignored by elflint. Add all such flags to a new
EXTRA_SHFLAGS and use it consistently in check_sections.
before the change section_flags_string() ignored unknown section
flags: snprintf() did write numeric value into buffer, but
"*cp = '\0'" negated the effect.
The change advances the 'cp' pointer'.
While at it add a '|' separator between known and unknown flags.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Érico Rolim [Wed, 16 Dec 2020 22:30:12 +0000 (19:30 -0300)]
src/readelf: use qsort instead of qsort_r.
This program is single threaded, so using qsort with a global variable
isn't a danger. The interface for qsort_r isn't standardized (and
diverges between glibc and FreeBSD, for example), which makes usage of
qsort, where possible, preferrable.
Dmitry V. Levin [Sun, 20 Dec 2020 08:00:00 +0000 (08:00 +0000)]
Split the top level .gitignore file
Move subdirectory parts of the top level .gitignore into appropriate
subdirectories. This would be consistent with ChangeLog files,
currently one has to update the top level ChangeLog file when
the top level .gitignore file is changed in a way that affects
a specific subdirectory only.
Dmitry V. Levin [Tue, 15 Dec 2020 08:00:00 +0000 (08:00 +0000)]
Modernize gettext infrastructure
Switch to use AM_GNU_GETTEXT, AM_GNU_GETTEXT_VERSION, and
AM_GNU_GETTEXT_REQUIRE_VERSION, this allows to stop bundling gettext
infrastructure files and let autoreconf invoke autopoint which will set
the gettext infrastructure up.
Use this opportunity to create separate .gitignore files for m4/ and po/
directories.
Tested with
autoreconf -if && ./configure --enable-maintainer-mode && make && make distcheck
Dmitry V. Levin [Wed, 16 Dec 2020 08:00:00 +0000 (08:00 +0000)]
libcpu: consistently use _(Str) instead of gettext(Str)
eu-config.h defines _(Str) to dgettext ("elfutils", Str) instead of
a simple gettext (Str) for a reason: the library might be indirectly
used by clients that called bindtextdomain with a domain different
from "elfutils".
The change was made automatically using the following command:
$ git grep -l '\<gettext *(' libcpu |xargs sed -i 's/\<gettext *(/_(/g'
Dmitry V. Levin [Wed, 16 Dec 2020 08:00:00 +0000 (08:00 +0000)]
lib: consistently use _(Str) instead of gettext(Str)
eu-config.h defines _(Str) to dgettext ("elfutils", Str) instead of
a simple gettext (Str) for a reason: the library might be indirectly
used by clients that called bindtextdomain with a domain different
from "elfutils".
The change was made automatically using the following command:
$ git grep -l '\<gettext *(' lib |xargs sed -i 's/\<gettext *(/_(/g'
Dmitry V. Levin [Wed, 16 Dec 2020 08:00:00 +0000 (08:00 +0000)]
Consistently define _(Str) using dgettext ("elfutils", Str)
Move the definition of _(Str) macro to lib/eu-config.h which already
provides a definition of N_(Str) macro. Since lib/eu-config.h is
appended to config.h, it is included into every compilation unit
and therefore both macros are now universally available.
Remove all other definitions of N_(Str) and _(Str) macros from other files
to avoid conflicts and redundancies.
The next step is to replace all uses of gettext(Str) with _(Str).
Dmitry V. Levin [Tue, 15 Dec 2020 08:00:00 +0000 (08:00 +0000)]
libebl: consistently use _(Str) instead of gettext(Str)
libeblP.h defines _(Str) to dgettext ("elfutils", Str) instead of
a simple gettext (Str) for a reason: the library might be indirectly
used by clients that called bindtextdomain with a domain different
from "elfutils".
The change was made automatically using the following command:
$ git grep -l '\<gettext *(' libebl |xargs sed -i 's/\<gettext *(/_(/g'
Mark Wielaard [Wed, 16 Dec 2020 09:57:22 +0000 (10:57 +0100)]
libelf: Make sure we have at least a full ELF header available.
When elf_memory is called we could get a slightly too small image
that doesn't contain a full ELF header (but does contain at least
the e_ident values). Require the full header before even validating
the rest of the ELF header fields.
Dmitry V. Levin [Tue, 15 Dec 2020 20:56:37 +0000 (23:56 +0300)]
po: remove empty translation files
Remove translation files that do not contain any translation strings,
not even a single fuzzy one. These files are also unused because they
are not listed in the LINGUAS file.
Dmitry V. Levin [Tue, 15 Dec 2020 14:40:38 +0000 (17:40 +0300)]
m4: remove unneeded Makefile.am
m4 files do not have to listed in EXTRA_DIST, in fact,
biarch.m4 has not been listed since its very beginning in 2013,
and nobody seems to have noticed so far.
Tested with
autoreconf -if && ./configure --enable-maintainer-mode && make && make distcheck
Dmitry V. Levin [Sat, 12 Dec 2020 01:27:37 +0000 (04:27 +0300)]
src: fix spelling typos in argp help text and error diagnostics
Since all these help text strings are marked for translation, apply the fixes
to translation strings as well, this helps to avoid translations becoming fuzzy.
An attempt to run autoreconf in tests would currently fail
with the following automake error:
automake: error: cannot open < config/eu.am: No such file or directory
Apparently, nobody builds tests as a separate project for more than 10
years, so cleanup the remains of that unused and broken code.
Dmitry V. Levin [Wed, 9 Dec 2020 23:34:55 +0000 (02:34 +0300)]
Fix automake warnings
Apparently, commit 2f02e81510946a4c8e9157ad0b72d92894b9acd7 that removed
$(EXEEXT) suffix from shared libraries was incomplete: it missed the
fact that some libraries were included into noinst_PROGRAMS, resulting
to the following automake warnings:
Fix this by renaming noinst_PROGRAMS to noinst_DATA and removing no
longer needed lib{asm,dw,elf}_so_SOURCES variables and add lib{asm,dw,elf).so
to CLEANFILES.
Fixes: 2f02e8151094 ("Drop $(EXEEXT) suffix from shared libraries") Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Mark Wielaard <mark@klomp.org>
Dmitry V. Levin [Wed, 9 Dec 2020 00:13:12 +0000 (03:13 +0300)]
debuginfod: create libdebuginfod.so.1 before libdebuginfod.so
This would allow to switch from "libdebuginfod-" VERSION ".so"
to DEBUGINFOD_SONAME in __libdwfl_debuginfod_init, and to remove the
fall back to dlopen of "libdebuginfod.so" which would no longer be needed.
Dmitry V. Levin [Wed, 9 Dec 2020 00:12:53 +0000 (03:12 +0300)]
debuginfod: export DEBUGINFOD_SONAME macro in debuginfod.h
Add DEBUGINFOD_SONAME macro to API for use by those of libdebuginfod
clients that would like to dlopen the library in the same way as
__libdwfl_debuginfod_init does.
Frank Ch. Eigler [Thu, 26 Nov 2020 00:41:03 +0000 (19:41 -0500)]
debuginfod: use clock_gettime(CLOCK_MONOTONIC) for intervals
On Mark's request, use a monotonic clock for metrics/reports related
to time interval measurement. gettimeofday can jump a bit, which
could distort metrics. Tests unaffected.
Frank Ch. Eigler [Tue, 24 Nov 2020 00:58:10 +0000 (19:58 -0500)]
debuginfod: sqlite3 metrics
Add metrics for tracking sqlite3 error counts and query performance.
The former looks like a new sibling of the "error_count" family, and
is tested by dd-corrupting a live database file then triggering some
debuginfod activity.
error_count{sqlite3="file is not a database"} 1
The latter looks like _count/_sum pairs for each type of sqlite
prepared-statement used in the code, and is grep smoke-tested. They
should assist a sysadmin in tuning db storage. This example shows a
6.4 ms/operation cost:
Mark Wielaard [Tue, 10 Nov 2020 23:23:08 +0000 (00:23 +0100)]
debuginfod-client: Add debuginfod_set_verbose_fd and DEBUGINFOD_VERBOSE
Introduce a new function debuginfod_set_verbose_fd which will produce
verbose output on a given file descriptor (STDERR_FILENO if the
environment variable DEBUGINFOD_VERBOSE is set) showing how the search
for a particular client query is going.
Example output:
debuginfod_find_debuginfo 1234567890
server urls "https://debuginfod.elfutils.org/ http://dbgd.usersys.com:3632/"
checking build-id
checking cache dir /home/mark/.cache/debuginfod_client
using timeout 90
init server 0 https://debuginfod.elfutils.org/
url 0 https://debuginfod.elfutils.org/buildid/1234567890/debuginfo
init server 1 http://dbgd.usersys.com:3632/
url 1 http://dbgd.usersys.com:3632/buildid/1234567890/debuginfo
query 2 urls in parallel
server response HTTP response code said error
url 0 The requested URL returned error: 404 Not Found
server response HTTP response code said error
url 1 The requested URL returned error: 404 Not Found
not found No such file or directory (err=-2)
Frank Ch. Eigler [Thu, 19 Nov 2020 18:16:10 +0000 (13:16 -0500)]
debuginfod: add thread-busy metrics to webapi service
Improve monitoring of debuginfod instances by tracking thread_busy
status for the threads responding to http requests. While these are
usually short-lived, longer archive-uncompress operations can take
long enough time to show up on top/uptime. This should also assist
noticing abusive clients and guide scaling of the service.
Mark Wielaard [Wed, 11 Nov 2020 20:28:07 +0000 (21:28 +0100)]
debuginfod-find: Be a bit less verbose with -v
debuginfod-find -v enables a progressfn that prints the Progress every
time the callback is called. For slow transfers or big downloads this
can be really verbose (hundreds a times a second). Slow it down a bit,
so it only prints the progress at most 5 times a second.
Mark Wielaard [Fri, 6 Nov 2020 17:16:24 +0000 (18:16 +0100)]
libelf: Update SH_ENTSIZE_HASH comment.
The elf-knowledge.h contains various macros to deal with specific ELF
knowledge needed to interpret some ELF constructs that can be ambigious
depending on architecture ABI. Update the comment of SH_ENTSIZE_HASH
to add a more technical description of why it is needed.
Dmitry V. Levin [Wed, 4 Nov 2020 08:00:00 +0000 (08:00 +0000)]
config: do not define DEBUGINFOD_URLS environment variable unnecessarily
Before this change, when elfutils was configured without
--enable-debuginfod-urls, the installed profile.d/debuginfod.sh and
profile.d/debuginfod.csh scripts used to define the DEBUGINFOD_URLS
environment variable as an non-empty string containing spaces, making
all libdebuginfod users do extra work.
Change these scripts to avoid defining the DEBUGINFOD_URLS environment
variable unless configured using --enable-debuginfod-urls.
Dmitry V. Levin [Mon, 2 Nov 2020 08:00:00 +0000 (08:00 +0000)]
config: Conditionalize on LIBDEBUGINFOD instead of DEBUGINFOD
When elfutils is configured using --enable-libdebuginfod
--disable-debuginfod, that is, when the library is built and installed
but the server is not, it makes sense to install libdebuginfod.pc
because the latter complements the library rather than the server.
Likewise, it makes sense to install profile.d/debuginfod.*sh files
along with libdebuginfod because the library can use DEBUGINFOD_URLS
environment variable as well as the server.
This change does not affect --enable-debuginfod mode as the latter
requires --enable-libdebuginfod.
Fixes: fed3c3ceeaa6 ("Do not install libdebuginfod.pc unless debuginfod is enabled") Fixes: b503c358dde8 ("Do not install profile.d/debuginfod.*sh files unless debuginfod is enabled") Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Mark Wielaard [Sun, 1 Nov 2020 17:52:15 +0000 (18:52 +0100)]
libelf: Check header exists in elf_strptr
We already checked the header actually existed for ELFCLASS64 but not
for the ELFCLASS32 case. It is very unlikely it is at this point in the
code, but theoretically it could happen.
Mark Wielaard [Sun, 1 Nov 2020 17:51:02 +0000 (18:51 +0100)]
libelf: Set dst to zero on failure in __elf_getphdrnum_rdlock
GCC with -flto finds some (very) unlikely error paths. It flags callers
of __elf_getphdrnum_chk_rdlock with *dst not yet set because an internal
call to __elf_getphdrnum_rdlock might not initialize *dst either in one
particular failure path. The sanity check that __elf_getphdrnum_chk_rdlock
then performs might happen against uninitialized data. So just set *dst
to zero on failure in __elf_getphdrnum_rdlock so any caller can simply
check either the result/error code or whether *dst is zero or not.
Mark Wielaard [Sun, 1 Nov 2020 17:50:04 +0000 (18:50 +0100)]
libelf: Use GElf_Ehdr instead of Elf handle in __libelf_data_type
GCC with -flto detects some (very) unlikely issues in error paths.
In theory getting the Ehdr from an Elf handle might fail. But in
most cases where __libelf_data_type is used, we already have the
Ehdr anyway. So simply pass that to __libelf_data_type. In the one
place where we don't have it yet, get it and check for failure
before calling __libelf_data_type.
Mark Wielaard [Mon, 2 Nov 2020 14:20:54 +0000 (15:20 +0100)]
tests: Create bogus R/nothing.rpm with cyclic symlink.
We used to try to trigger an error during debuginfod scanning using
a chmod 000 file. But this doesn't always result in an error. Create
a cyclic symlink instead, which always results in a failure to open/read.
Érico Rolim [Mon, 2 Nov 2020 01:49:46 +0000 (22:49 -0300)]
Switch from numerical to defined constants for permissions.
Use defined constants for permission values. Also add fallback
definitions for them in system.h, to allow for compatibility with
systems that don't provide these macros.
Include system.h in all tests/ files that required it.
Signed-off-by: Érico Rolim <erico.erc@gmail.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
Érico Rolim [Mon, 2 Nov 2020 00:48:50 +0000 (21:48 -0300)]
Support building when fts and obstack aren't part of libc.
- Make configure.ac test for fts and obstack availability;
- Add fts and obstack ldflags to all files that need them;
- Add missing argp ldflags to programs in debuginfod/.
Added new metrics for scanning that allow estimation of its reading
bandwidth. Accelerated responsivity to SIGINT shutdown during
archive-scanning phase, which previously insisted on completely
processing the current archive. Noted in systemd service file that in
the worst case, it might still take a long time. Accelerated
traversals by moving regex -I/-X handling to apply to file names only
(as always documented), so directory traversal metrics are accurate
regardless of their name.