daifan [Tue, 10 Jan 2023 04:04:39 +0000 (12:04 +0800)]
debugedit: Add support for loongarch
* tools/debugedit.c (setup_relbuf): Handle EM_LOONGARCH
Mark Wielaard [Wed, 28 Dec 2022 21:23:01 +0000 (22:23 +0100)]
debugedit: Skip calling edit_dwarf2 if not rewriting and/or listing source
We skipped calling edit_dwarf2 when no base and dest dir were given and
debugedit was invoked with -i -n. But we never need to call edit_dwarf2
if we aren't rewriting paths and we don't want to list the source files.
* tools/debugedit.c (main): Adjust edit_dwarf2 call guard.
https://sourceware.org/bugzilla/show_bug.cgi?id=27639
Mark Wielaard [Wed, 20 Apr 2022 22:05:38 +0000 (00:05 +0200)]
debugedit: Use standard libelf elf_strptr
The strptr function in debugedit.c does the same thing as libelf
elf_strptr. But elf_strptr handles bounds checks and invalid section
offsets better. And elf_strptr handles compressed sections.
* tools/debugedit.c (strptr): Just call elf_strptr.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 24 Mar 2022 17:04:45 +0000 (18:04 +0100)]
debugedit: Guard against NULL names returned by by strptr
debugedit.c (edit_dwarf2): Check name is not NULL before
calling strncmp.
(main): Check name is not NULL before calling strcmp.
This is unlikely to happen, except when the ELF file is corrupt.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Allan McRae [Sun, 2 Jan 2022 05:23:34 +0000 (15:23 +1000)]
Fix -u option
The -u option was missing from optionsChars resulting in it being
unrecognised.
$ debugedit -u
debugedit: invalid option -- 'u'
Signed-off-by: Allan McRae <allan@archlinux.org>
Mark Wielaard [Thu, 18 Nov 2021 13:14:28 +0000 (14:14 +0100)]
debugedit: Handle hppa EM_PARISC and R_PARISC_DIR32
* tools/debugedit.c (setup_relbuf): Handle EM_PARISC
https://sourceware.org/bugzilla/show_bug.cgi?id=28598
Patch-provided-by: dave.anglin@bell.net
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 11 Oct 2021 11:57:15 +0000 (13:57 +0200)]
debugedit: Use original shdr sh_type to check for NOBITS
* tools/debugedit.c (handle_build_id): Check SHT_NOBITS
against dso->shdr[i].sh_type.
https://www.sourceware.org/bugzilla/show_bug.cgi?id=28408
Reported-by: Alexey Brodkin <alexey.brodkin@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 24 Sep 2021 10:16:07 +0000 (12:16 +0200)]
find-debuginfo.sh: Remove bogus shift after --dwz-single-file-mode
https://sourceware.org/bugzilla/show_bug.cgi?id=28382
Reported-by: mls@suse.de
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Fri, 30 Jul 2021 16:09:46 +0000 (18:09 +0200)]
tests: Handle zero directory entry in .debug_line DWARF5 debugedit.at
We were skipping the zero directory entry, because it was always
the same as the directory entry at position one. But that isn't
true anymore with gcc 11.2.1. There the zero dir entry is unique.
Fix the debugedit.at .debug_line testcases using DWARF5 to also
include dir entry zero.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Sergei Trofimovich [Sun, 1 Aug 2021 20:15:35 +0000 (21:15 +0100)]
use $READELF, not readelf
Allow user to specify own readelf. Use detected readelf,
not 'readelf'.
Noticed as a set of test failures on system with only
$host-prefixed tools:
debugedit/tests/testsuite.dir/at-groups/4/test-source:
line 40: readelf: command not found
* configure.ac: Add READELF user override.
* scripts/find-debuginfo.in: Use @READELF@ instead of 'readelf'.
* tests/atlocal.in: Populate READELF variable detected by configure.
* tests/debugedit.at: Use $READELF instad of 'readelf' in tests.
* Makefile.am (do_subst): Add READELF substitution.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Mark Wielaard [Mon, 26 Jul 2021 22:46:35 +0000 (00:46 +0200)]
debuginfo-find: simplify RPM env handling
As pointed out by Dmitry V. Levin the RPM env checking used redundant
trailing semicolons and wasn't somewhat verbose. Replace the three
checks with simpler for loop check over all env variables we are
expecting.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 26 Jul 2021 22:32:50 +0000 (00:32 +0200)]
find-debuginfo: Move RPM env checks after --version/help processing
Checking before breaks --version and --help handling in the script.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 26 Jul 2021 22:18:49 +0000 (00:18 +0200)]
Set version to 5.0
First release. Version set higher than any rpm release.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 26 Jul 2021 22:01:15 +0000 (00:01 +0200)]
find-debuginfo: Check RPM environment variables are there
find-debuginfo relies on a couple of RPM environment variables.
Ideally we provide command line arguments to set them. But they are
somewhat tied to how rpm sets things up. So for now just warn and
exit if they aren't set.
See also https://sourceware.org/bugzilla/show_bug.cgi?id=27637
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 5 Jul 2021 16:35:04 +0000 (18:35 +0200)]
Record and write files in read_dwarf5_line_entries.
Without giving -d /foo/build/bar debugedit wouldn't actually output
any file from the line number table for DWARF5.
* tools/debugedit.c (read_dwarf5_line_entries): Don't make
collecting_dirs and writing_files depend on dest_dir. Always
read idx for strp or line_strp on phase 0. comp_dir_len is
zero when comp_dir is NULL.
* tests/debugedit.at: Add source list mode tests for DWARF4
and DWARF5.
https://bugzilla.redhat.com/show_bug.cgi?id=
1966987
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 12 Jul 2021 20:19:02 +0000 (22:19 +0200)]
tests: Disable CFLAGS and LDFLAGS overrides
We do use the CC and LD found by configure, but explicitly keep
CFLAGS and LDFLAGS empty because the tests use specific flags.
https://sourceware.org/bugzilla/show_bug.cgi?id=27890
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 15:14:40 +0000 (17:14 +0200)]
debugedit: check write to list_file succeeds
We didn't check, or ignored, errors writing to the list_file. Always
produce an error if we cannot write to the list_file.
* debugedit.c (read_dwarf4_line): Produce error if write fails.
(read_dwarf5_line_entries): Likewise.
(edit_attributes): Likewise.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 14:48:26 +0000 (16:48 +0200)]
Resync libiberty sha1.c
This brings in the following commit:
commit
f6e9c1c9191c8b9998e03cb15de8600a2a4b9188
Author: Nick Clifton <nickc@redhat.com>
Date: Tue Mar 16 14:43:17 2021 +0000
Fix potentially undefined behaviour when computing a sha1 value.
libiberty/
* sha1.c (sha1_process_bytes): Use memmove in place of memcpy.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 14:37:13 +0000 (16:37 +0200)]
debugedit: Report errors if we cannot chmod the file.
* tools/debugedit.c (main): Check result of chmod and call error
if necessary.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 14:30:24 +0000 (16:30 +0200)]
sepdebugcrcfix: Report errors if we cannot chmod the file.
* tools/sepdebugcrcfix.c (main): Check result of chmod and call error
if necessary.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 14:12:56 +0000 (16:12 +0200)]
sepdebugcrcfix: Don't crash if .gnu_debuglink doesn't contain a file string.
If the .gnu_debuglink section didn't contain a valid file string then we would crash.
Produce an error instead.
* tools/sepdebugcrcfix.c (process): Produce an error when zerop is NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 09:58:38 +0000 (11:58 +0200)]
debugedit: Skip relocations with missing symbol/section offset.
We tried to handle relocations that didn't have a symbol associated
with any section. The would cause a message like: "Unhandled
relocation 1 in .debug_info section". Which wasn't that helpful
either. So skip relocations without an associated symbol section index
and improve the error message a little.
* debugedit.c (setup_relbuf): Continue when sym.st_shndx == 0.
Add relocation index to error message.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 1 Jul 2021 12:50:04 +0000 (14:50 +0200)]
debugedit: Handle realloc failure correctly.
Although we are already in trouble when realloc fails don't make it
worse. When realloc fails we have to free the original pointer we
wanted to extend to not cause an even bigger memory leak.
* tools/debugedit.c (read_abbrev): Free original t after realloc
fails.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 17 Jun 2021 13:14:35 +0000 (15:14 +0200)]
Set version to 0.3
Another pre-release, with find-debuginfo.sh -> find-debuginfo rename.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 19 May 2021 11:41:26 +0000 (13:41 +0200)]
find-debuginfo: Generate and install as top-level build file.
find-debuginfo relied on lib_rpm_dir to find other debugedit tools.
But the script itself was generated at configure time in a subdir.
This makes testing the (non-installed) build slightly inconvenient.
Add a automake rule to generate find-debuginfo at build time, instead
of configure time, in the top-level builddir next to the other tools.
* .gitignore: Move scripts/find-debuginfo to find-debuginfo.
* configure.ac: Explicitly check we have SED.
* Makefile.am (bin_SCRIPTS): Drop subdir scripts.
(CLEANFILES): New.
(do_subst): New.
(find-debuginfo): New generate using do_subst.
(find-debuginfo.1): Adjust location and protect against
parallel builds.
(EXTRA_DIST): Add .in suffix to scripts/find-debuginfo.
* scripts/find-debuginfo.in (lib_rpm_dir): Rename to...
(install_dir): ...this.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 19 May 2021 10:39:05 +0000 (12:39 +0200)]
tests: Remove RPM strings
The debugedit.at still contained some references to RPM even though it
doesn't depend on RPM anymore. Remove RPM from the banner and from the
DEBUGEDIT_SETUP m4 macro.
* tests/debugedit.at (AT_BANNER): Remove RPM from the name.
(RPM_DEBUGEDIT_SETUP): Rename to...
(DEBUGEDIT_SETUP): ...this.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Tue, 18 May 2021 17:03:31 +0000 (19:03 +0200)]
Rename find-debuginfo.sh to find-debuginfo
Even though it is currently a bash script we install it as a normal
program. So simply install it without the .sh suffix. To get the VERSION
right in the script make it an AC_CONFIG_FILE (from find-debuginfo.in).
This also fixes the man page name and version.
* .gitignore: Remove find-debuginfo.sh.1.
Add scripts/find-debuginfo and find-debuginfo.1
* configure.ac (AC_CONFIG_FILES): Add scripts/find-debuginfo.
* Makefile.am (bin_SCRIPTS): Rename find-debuginfo.sh to
find-debuginfo.
(dist_man_MANS): Rename find-debuginfo.sh.1 to find-debuginfo.1.
(find-debuginfo.sh.1): Rename to ...
(find-debuginfo.1): ...this and update invocation.
(EXTRA_DIST): Rename scripts/find-debuginfo.sh to
scripts/find-debuginfo.
* scripts/find-debuginfo.sh: Rename to ...
* scripts/find-debuginfo.in: ...this.
Change all find-debuginfo.sh to find-debuginfo.
Use @VERSION@ for --version.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 5 May 2021 22:06:56 +0000 (00:06 +0200)]
upload-release.sh: Use xz, not bz2 for release tar
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 5 May 2021 22:00:56 +0000 (00:00 +0200)]
Set version to 0.2 and add upload-release.sh script.
Another pre-release.
Now with the new documentation and an uploade-release.sh script.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 5 May 2021 21:33:14 +0000 (23:33 +0200)]
Makefile.am: Don't try to recursively make binaries to run help2man
We try to avoid having to run help2man unnecessary for a build from
a source distribution (which include the generated manpages). We did
this by not depending on the actual executable, but recursively calling
make to generate it when necessary. This causes trouble with parallel
makes because the two make processes don't know which objects have,
have not or are being build. Fix this by depending on the executable
but only running help2man if one of the sources has changed, not when
the executable has been regenerated.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 5 May 2021 20:00:08 +0000 (22:00 +0200)]
Makefile.am: Add scripts/find-debuginfo.sh to EXTRA_DIST
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 5 May 2021 19:22:29 +0000 (21:22 +0200)]
automake: Add std-options to check --version and --help work as intended.
Now that we rely on --version and --help to generate documentation make
sure that make distcheck checks those standard options work correctly.
Also adjust find-debuginfo.sh[.1] rules slightly to make sure they the
scripts are also checked (bin_SCRIPTS are, but dist_bin_SCRIPTS aren't).
* configure.ac (AM_INIT_AUTOMAKE): Add std-options.
* Makefile.am (dist_bin_SCRIPTS): Change into...
(bin_SCRIPTS): ... this, using top_srcdir.
(TOP_CONFIGURE_AC): New variable, with comment explaining when
.1 man pages are (re)generated.
(debugedit.1): Use TOP_CONFIGURE_AC as dependency.
(sepdebugcrcfix.1): Likewise.
(find-debuginfo.sh.1): Likewise and depend on top_srcdir script.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 29 Apr 2021 22:42:23 +0000 (00:42 +0200)]
find-debuginfo.sh: Add --help, --version and man page.
Add a --version and --help option to find-debuginfo.sh and use that to
generate a manual page.
* .gitignore: Add find-debuginfo.sh.1
* Makefile.am (dist_man_MANS): Add find-debuginfo.sh.1
(find-debuginfo.sh.1): New make rule.
* scripts/find-debuginfo.sh (help): New function.
Handle --version and --help.
https://sourceware.org/bugzilla/show_bug.cgi?id=27641
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 29 Apr 2021 20:44:41 +0000 (22:44 +0200)]
sepdebugcrcfix: Add --version, --help and man page.
Add --version and --help support to sepdebugcrcfix. Use this to generate
a manual page using help2man.
* .gitignore: Add sepdebugcrcfix.1
* Makefile.am (dist_man_MANS): Add sepdebugcrcfix.1
(sepdebugcrcfix.1): New make rule.
* tools/sepdebugcrcfix.c (version): New static functions.
(help): Likewise.
(main): Call version or help depending on argc and argv.
https://sourceware.org/bugzilla/show_bug.cgi?id=27642
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Thu, 29 Apr 2021 16:11:06 +0000 (18:11 +0200)]
debugedit: Add manual using help2man
This generates a debugedit.1 man page using help2man based on the
debugedit --help output. The generated file is included in the dist
so help2man isn't normally needed to build debugedit.
* .gitignore: Add debugedit.1
* configure.ac: Add AM_MISSING_PROG for help2man.
* Makefile.am (dist_man_MANS): Add debugedit.1
(debugedit.1): New rules.
* tools/debugedit (helpText): Add FILE argument.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Dmitry V. Levin [Mon, 26 Apr 2021 20:00:00 +0000 (20:00 +0000)]
debugedit: consistently use error() instead of fprintf(stderr)
The error() function is already used in debugedit for printing some
of diagnostic messages, extend this practice to all such messages.
The user-visible side of this change is that all diagnostic messages
are now consistently prefixed.
* tools/debugedit.c (edit_attributes, handle_build_id, main): Replace
fprintf(stderr) with error().
Dmitry V. Levin [Mon, 26 Apr 2021 20:00:00 +0000 (20:00 +0000)]
debugedit: strip extra newline characters from diagnostic messages
Since the output produced by error() is already terminated by a newline
character, no newline terminating characters are needed in diagnostic
messages printed using error().
* tools/debugedit.c (main): Remove terminating newline characters from
format strings passed to error().
Vitaly Chikunov [Wed, 14 Apr 2021 16:39:08 +0000 (19:39 +0300)]
debugedit: Fix 'Unhandled relocation 0 in .debug_info section' on e2k
Fix handling of Elbrus ELF relocatables:
/usr/lib/rpm/debugedit: ./lib/modules/5.4.58-elbrus-def-alt1/misc/xt_so.ko: Unhandled relocation 0 in .debug_info section
Reported-by: Michael Shigorin <mike@altlinux.org>
Tested-by: Andrey Savchenko <bircoph@altlinux.org>
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
Ivan A. Melnikov [Fri, 13 Nov 2020 11:51:08 +0000 (15:51 +0400)]
debugedit: add MIPS support
According to the specification[1], all MIPS .debug_* sections are
marked with ELF type SHT_MIPS_DWARF. The format of the section
data stays the same, so we have can handle e.g. .debug_info
section as we used to.
As SHT_MIPS_DWARF is from processor-specific range, we have to check
that we're actually dealing with MIPS ELF file before handling such
sections.
[1] MIPS Extensions to DWARF Version 2.0. -- Silicon Graphics
Computer Systems, rev 1.17, 29 Aug 2001
Refs: https://bugzilla.altlinux.org/39284
Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Mark Wielaard [Thu, 25 Mar 2021 23:00:42 +0000 (00:00 +0100)]
tests: Use CC, CFLAGS, LD and LDFLAGS to create testcases
Currently gcc is hardcoded in the tests. Use the configured tools to
make testing for a specfic target or alternative build tools easier.
* configure.ac: Add AC_CHECK_TOOL for LD.
* tests/atlocal.in: Set CC, CFLAGS, LD and LDFLAGS.
* tests/debugedit.at (RPM_DEBUGEDIT_SETUP): Use CC, CFLAGS, LD
and LDFLAGS.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 24 Mar 2021 23:23:43 +0000 (00:23 +0100)]
tests: Check gcc accepts -gz=none before usage
commit 4f138 "tests: fix for toolchains producing compressed debug
sections" used -gz=none unconditionally to compile the test
binaries. But not all gcc versions support -gz.
Add a configure check for -gz=none. Set GZ_NONE_FLAG in
atlocal.in. Use it instead of -gz=none in debugedit.at.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 24 Mar 2021 01:01:19 +0000 (02:01 +0100)]
tests: Check gcc accepts -gdwarf-5 otherwise skip DWARF5 tests
Add a configure check for -gdawrf-5. Set GDWARF_5_FLAG in atlocal.in
to yes or no. Use AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"]) in
debugedit.at.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Dmitry V. Levin [Mon, 22 Mar 2021 20:00:00 +0000 (20:00 +0000)]
tests: fix for toolchains producing compressed debug sections
When toolchain produces compressed debug sections by default,
quite a few debugedit tests fail because of unexpected
"debugedit: ./foo.o: DWARF version 0 unhandled" error diagnostic messages:
3: debugedit .debug_str objects DWARF4 FAILED (debugedit.at:97)
4: debugedit .debug_str/line_str objects DWARF5 FAILED (debugedit.at:129)
9: debugedit .debug_info objects FAILED (debugedit.at:291)
12: debugedit .debug_types objects FAILED (debugedit.at:370)
15: debugedit .debug_line objects DWARF4 FAILED (debugedit.at:460)
16: debugedit .debug_line objects DWARF5 FAILED (debugedit.at:484)
21: debugedit .debug_macro objects FAILED (debugedit.at:598)
Fix this by instructing gcc not to produce compressed debug sections
in object files prepared for debugedit tests.
* tests/debugedit.at: Add "-gz=none" to "gcc -g3" invocations.
Co-authored-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Martin Liška [Tue, 23 Mar 2021 14:09:03 +0000 (15:09 +0100)]
Add --dwz-single-file-mode argument for find-debuginfo.sh.
Sometime it's handy to disable multi-file mode and the patch
adds option for that: --dwz-single-file-mode.
It will be used in openSUSE for packages that use baselibs.conf
mechanism.
The patch was already approved in rpm pull request:
https://github.com/rpm-software-management/rpm/pull/1579
Signed-off-by: Martin Liska <mliska@suse.cz>
Dmitry V. Levin [Mon, 22 Mar 2021 20:00:00 +0000 (20:00 +0000)]
debugedit: fix exit status in case of wrong number of arguments
Print error diagnostics to stderr and exit with status EXIT_FAILURE
when the number of arguments is not equal to 1.
* tools/debugedit.c (usage): Add "error" argument, print usageText
to stderr and exit with status EXIT_FAILURE if error is set to true.
All callers updated.
* tests/debugedit.at: Check debugedit usage.
Fixes:
5200953d5a65 ("Initial build system. Remove rpm and popt dependencies.")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Mark Wielaard [Mon, 15 Mar 2021 09:14:49 +0000 (10:14 +0100)]
Initial build system. Remove rpm and popt dependencies.
- Add automake, autoconf and autotest files.
- Replace popt with getopt argument parsing.
- Use md5 or sha1 instead of rpmDigest algorithms for build-id updates.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Sun, 14 Mar 2021 15:56:04 +0000 (16:56 +0100)]
Add COPYING files for imported code
Code for debugedit has been imported that was derived from binutils,
libiberty and rpm some use different licenses, but all are upward
compatible with GPLv3+.
COPYING (GPLv2+) covers scripts/find-debuginfo.sh, all files under
tests, tools/hashtab.h, tools/sha1.c, tools/md5.{c,h},
tools/ansidecl.h and tools/debugedit.c.
COPYING3 (GPLv3+) covers tools/sepdebugcrcfix.c and tools/sha1.h
COPYING.LIB (LGPLv2+) covers tools/hashtab.c.
Mark Wielaard [Sun, 14 Mar 2021 15:55:09 +0000 (16:55 +0100)]
Add libiberty md5 and sha1 for 128 and 160 bit build-ids.
Mark Wielaard [Sun, 14 Mar 2021 14:41:25 +0000 (15:41 +0100)]
Sync hashtab.{c,h} with libiberty
Add ansidecl.h to use hashtab as is, but remove libiberty.h and
deprecated htab_create so we don't have to provide xmalloc and
friends.
Mark Wielaard [Mon, 15 Feb 2021 11:29:26 +0000 (12:29 +0100)]
debugedit: Add DWARF5 tests
Adjust some existing tests so they are run with an explicit -gdwarf-4
and add an -gdwarf-5 variant to make testing independent of the gcc
default DWARF version. The tests that might generate a DWARF5 line
table work for both version 4 and 5 and some also ignore stderr output
when using -p.debug_line_str because some combinations of gcc/binutils
generate DWARF5 debug info with DWARF4 debug line tables, even when
-gdwarf-5 is given.
Tested against GCC10, which defaults to DWARF4 and GCC11, which defaults
to DWARF5.
Mark Wielaard [Mon, 15 Feb 2021 11:29:25 +0000 (12:29 +0100)]
debugedit: Handle DWARF-5 debug_line and debug_line_str.
Handle the new DWARF5 .debug_line tables and the new DW_FORM_line_strp.
DWARF5 tables are handled separately from the earlier tables. They
will never change size, but they do need updates to the .debug_str
or .debug_line_str references.
Based on a patch from Jan Kratochvil <jan.kratochvil@redhat.com>
Jan Kratochvil [Mon, 15 Feb 2021 11:29:24 +0000 (12:29 +0100)]
debugedit: Implement DWARF-5 unit header and new forms parsing.
Recognize the various new DWARF5 .debug sections.
Parse and skip new DWARF5 forms in read_abbrev and skip_form.
Read DWARF5 unit headers for compile and partial units in edit_info.
This is enough to be able to process gcc -gdwarf-5 produced binaries
without the new DWARF5 .debug_line format (which isn't produced with
binutils < 2.36).
Patches slightly edited/merged by Mark Wielaard <mark@klomp.org>
Jan Kratochvil [Mon, 15 Feb 2021 11:29:23 +0000 (12:29 +0100)]
debugedit: Move code to separate functions.
New functions edit_strp, skip_form and edit_attributes_str_comp_dir
called by edit_attributes.
Split part of read_dwarf2_line into a read_dwarf4_line function.
New function edit_dwarf2_any_str called by edit_dwarf2 at the end of
phase 0 to rebuild .debug_str.
Jan Kratochvil [Mon, 15 Feb 2021 11:29:22 +0000 (12:29 +0100)]
debugedit: Protect macro arguments by parentheses
Vitaly Chikunov [Sat, 14 Nov 2020 19:32:44 +0000 (22:32 +0300)]
debugedit: Distinguish files from directories in src list file
Append '/' to directories in source file list (for `-l' option) to allow
quickly distinguish them from regular files (to avoid adding them raw
into %files section). This is needed for ALT for our debuginfo
processing to speed things up.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Vitaly Chikunov [Sat, 14 Nov 2020 15:14:28 +0000 (18:14 +0300)]
debugedit: Do not 'edit_dwarf2' when just extracting build-id
No need to call edit_dwarf2() if debugedit is invoked just to extract
build-id (with `-i -n'). Otherwise, we will get `DWARF version 0
unhandled' warning for compressed .debug files:
/usr/lib/rpm/debugedit: ./usr/lib/debug/...e.ko.debug: DWARF version 0 unhandled
Context: We have kernel modules elfcompressed in ALT.
ggardet [Fri, 9 Oct 2020 11:10:09 +0000 (13:10 +0200)]
Do not fail if there is no "$temp"/res.* file
find-debuginfo is multi-threaded and rpm runs
scripts usually with "-e" to abort on error.
If the debug-splitting tool fails, that job will abort.
But if you have X files that are problematic in the tree,
and you have X or less jobs, find-debuginfo will abort
as no single res.$number has been written.
But if you have more than X jobs, the build will succeed,
which makes the whole process random.
This commit remove this randomness.
Jan Kratochvil [Sat, 1 Aug 2020 08:45:47 +0000 (10:45 +0200)]
debugedit: Fix missing relocation of .debug_types section.
Jan Kratochvil [Sat, 1 Aug 2020 08:43:12 +0000 (10:43 +0200)]
[NFC] debugedit: Move code from edit_dwarf2() to edit_info().
Panu Matilainen [Thu, 11 Jun 2020 10:52:28 +0000 (13:52 +0300)]
Execute tests in independent testing roots to enable parallel running
Up to now we've run tests in a mish-mash of an environment where bits
and pieces of previous tests might exist, and as state has been shared
it's been impossible to execute tests in parallel.
This makes the pre-populated testing-root read-only to the owner to force
all writers to perform an extra setup call to gain a private testing
environment. Most of the users needing this already had RPMDB_INIT calls
to ensure clean rpmdb state so that's where this is hooked onto.
There's a fair bit of gymnastics with the environment to make things match
on both sides of fakechroot, some of which can hopefully go away eventually
once the dust from this settles. This is also rather heavy as it is,
on my laptop serial execution goes down from ~1m15s to ~1m45s, but then
parallel execution with -j8 is down to ~50s. There should be a number of
optimizations that can be made, such as setting up links for writable
directories instead of copying the entire testing-tree around, but leaving
that as a future exercise. This is more of an enabler than the goal state.
Note that this does *not* enable test-suite parallel running for
`make -jN check`, because `make` does not export the -j argument in
a way that we could pass to `./rpmtests` from the makefile. To enable
that, one needs to pass a suitable -jN argument through TESTSUITEFLAGS,
such as `make -j8 check TESTSUITEFLAGS="-j8"`. Or run invoke `rpmtests`
manually.
Florian Festi [Thu, 19 Dec 2019 14:40:20 +0000 (15:40 +0100)]
Rename add_percent_dir to generate_percent_dir
to reflect what the function actually does.
Denys Vlasenko [Thu, 5 Dec 2019 12:30:17 +0000 (13:30 +0100)]
find-debuginfo.sh: speed up %dir generation
For kernel build, "${LISTFILE}.dirs.sed" is debugfiles.list.dirs.sed
and it contains 1782 lines of sed script.
It is applied to two files, both are about 4450 lines long.
This is slow (~30 seconds) because of ~16 million regex matches
performed by sed.
But we don't need or want regex match here
(and it's buggy, since dots in pattern match will be treated
as "any character", which is wrong here. For example,
/usr/lib/debug/lib/modules/5@4@0-0@rc7@0@fc31@test@x86_64/vdso/
would match
/usr/lib/debug/lib/modules/5.4.0-0.rc7.0.fc31.test.x86_64/vdso/
pattern, but it should not).
This change performs matching using shell string comparison ops.
For kernel build, this change results in run time of about one second.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Michal Čihař [Sat, 11 Nov 2017 13:27:10 +0000 (14:27 +0100)]
Fix sepdebugcrcfix compilation on platforms without MAP_POPULATE
Not all architectures offer MAP_POPULATE. As MAP_POPULATE is only an
optimization to improve performance, it is safe to drop it when it is
unavailable. Originally fixed in a Debian patch.
Florian Festi [Thu, 28 Nov 2019 08:56:24 +0000 (09:56 +0100)]
find-debuginfo.sh: Dont use xargs -d for portability
Use -0 instead which is more widly available.
Related: #948
Tom de Vries [Mon, 26 Aug 2019 09:30:31 +0000 (11:30 +0200)]
Remove unused variable id in find-debuginfo.sh
There's code setting variable id in scripts/find-debuginfo.sh, but there's no
subsequent use. The only use of $id in the script is in do_file, where it is
a local variable.
The variable setting was introduced in commit
fe280a20b "Add dwz debuginfo
compression support" in combination with a subsequent make_id_link using the
variable, but the make_id_link was removed in commit
62807f0df
"Add build-id links to rpm for all ELF files".
Remove the unused variable.
Pavlina Moravcova Varekova [Fri, 9 Aug 2019 14:30:43 +0000 (16:30 +0200)]
Eliminate use of ambiguous logical operators in script conditionals
Prefer '[] && []' to '[ -a ]' and '[] || []' to '[ -o ]' in tests.
-a and -o to mean AND and OR in a [ .. ] test expression is not well
defined, and can cause incorrect results when arguments start with
dashes or contain !. Moreover binary -a and -o are inherently
ambiguous. test(1) man page recommends to use
'test EXPR1 && test EXPR2' or 'test EXPR1 || test EXPR2' instead.
It corrects warnings [SC2166] spotted by covscan.
Pavlina Moravcova Varekova [Mon, 29 Jul 2019 06:37:13 +0000 (08:37 +0200)]
Prefer '[] && []' to '[ -a ]' in test in find-debuginfo.sh (RhBug:
1720590)
Spotted by covscan:
warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. [SC2166]
Originally introduced in commit
997cc2a.
Thanks to Florian Festi for spotting this and proposing the solution.
Mark Wielaard [Mon, 17 Jun 2019 09:23:26 +0000 (11:23 +0200)]
debugedit: Make sure .debug_line old/new idx start equal.
Found by running the debugedit tests under valgrind.
If the old and new .debug_line offset isn't changed then we might
write out an uninitialized new_idx.
Mark Wielaard [Mon, 17 Jun 2019 09:23:25 +0000 (11:23 +0200)]
Handle .debug_macro in debugedit.
When compiling with -g3 gcc will generate a .debug_macro section
which has pointers to the .debug_str section. Since we might rewrite
the .debug_str section, we also need to update any .debug_macro
pointers.
Updated the debugedit.at testcase by building everything with -g
and add various checks to see the .debug_macro section looks OK
after running debugedit. Added a new rpmbuild.at testcase to check
handing of .debug_macro in the whole rpmbuild debuginfo pipeline
to double check the separate .debug file also contains the macros.
Original patch by Michael Schroeder <mls@suse.de>. Extended by
Mark Wielaard <mark@klomp.org> to deal with relocations and possible
multiple COMDAT .debug_macro sections.
Mark Wielaard [Mon, 17 Jun 2019 09:23:24 +0000 (11:23 +0200)]
debugedit: Refactor reading/writing of relocated values.
This refactors the reading and writing of relocated values into seperate
helper functions (setup_relbuf and update_rela_data). It will be easier
to reuse this code in case we want to read/write relocated values in other
sections than DEBUG_INFO. The only functional change is that we explicitly
track whether the relocation data is updated, and only explicitly update
and write out the relocation data if so. In the case there were no strp
or stmt updates, there will also not be any relocation updates, even if
there is relocation data available.
All new debugedit testcases pass before and after this refactoring.
Mark Wielaard [Mon, 17 Jun 2019 09:23:23 +0000 (11:23 +0200)]
Add some debugedit tests.
debugedit didn't have any direct tests, it was only tested indirectly
through some other debuginfo testcases. So add some testcases that
just test debugedit functionality directly.
The tests create different kinds of ELF files (object files, partially
linked files and executables) and run debugedit path replacements on
them, checking that the resulting .debug_str, .debug_info and .debug_line
sections look sane.
Testcases verified against various different gcc and binutils versions.
gcc 4.8 and gcc 6 generate slightly different .debuginfo
Also add debugedit --version. Which makes it easy to see we are
testing the correct version/install of debugedit in rpmtests.log.
Adjust autotest paths to include rpmlibexecdir, where debuginfo
is installed. Note that rpmlibexecdir != libexecdir (see rpm.am).
nickclifton [Wed, 19 Jun 2019 11:45:09 +0000 (12:45 +0100)]
Add step to find-debuginfo.sh script to compress annobin notes.
With the introduction of the annobin gcc plugin to the build process,
built binary files have become larger. Sometimes significantly so.
This is a patch that adds a new step to the post-link process performed
by rpmbuild, to run the objcopy program with the --merge-notes option
specified. This will reduce the size of the annobin notes in binary
files, thus alleviating the size growth.
Pavlina Moravcova Varekova [Wed, 5 Jun 2019 04:07:00 +0000 (06:07 +0200)]
Use [ ] in condition to avoid sub processes in find-debuginfo.sh (#735)
Introduced in commit
d0ee451, spotted by covscan.
Pavlina Moravcova Varekova [Sun, 7 Apr 2019 05:23:47 +0000 (07:23 +0200)]
Sort list of hard linked files in find-debuginfo.sh (RhBug:
1421272)
It helps to make build results reproducible. Based on Mark Wielaard's idea.
Pavlina Moravcova Varekova [Sun, 17 Mar 2019 05:47:26 +0000 (06:47 +0100)]
Add flag to use strip -g instead of full strip on DSOs (RhBug:
1663264)
The find-debuginfo.sh flag -g had exactly this meaning. But from
version rpm-4.13.0-alpha flag -g changes its behavior. It affects
both libraries and executables.
For some packages the original behavior was preferred. That is why
the new find-debuginfo.sh flag --g-libs is created.
Options -g and --g-libs are mutually exclusive.
Ernestas Kulik [Mon, 25 Feb 2019 15:34:06 +0000 (16:34 +0100)]
find-debuginfo.sh: Handle position-independent executables
Since file 5.33, PIEs are identified by a new MIME type, meaning that,
currently, for such executables, the .gnu_debugdata section is not
added, even if -m is passed.
Signed-off-by: Ernestas Kulik <ekulik@redhat.com>
Panu Matilainen [Mon, 1 Oct 2018 10:41:45 +0000 (13:41 +0300)]
Report debuginfo size in kilobytes
By standard, 'du' defaults to 512 byte units, but this differs between
implementations: GNU du defaults to 1024 unless POSIXLY_CORRECT is set
and also allows overriding via number of environment variables. It also
supports various other ways of controlling the block size, but the
only standard means to control the size is -k, and we really don't
want to break portability for the sake of FYI statistics.
Inspired by Marxim Liska's patch at in #554.
marxin [Tue, 28 Aug 2018 09:31:17 +0000 (11:31 +0200)]
Info how beneficial is dwz compression.
Example output:
...
original debug info size: 120600, size after compression: 77604
...
Panu Matilainen [Thu, 6 Sep 2018 08:39:15 +0000 (11:39 +0300)]
Revert "find-debuginfo.sh: decompress DWARF compressed ELF sections"
This is breaking suid bit handling in packaging unless an unreleased
bleeding edge version of elfutils is used. In other words it's not
an acceptable requirement and wont be for a long time. This needs
to be fixed in some other way.
This reverts commit
076c14fc57621b307f216810679d6977e3f71d26.
Pavlina Moravcova Varekova [Thu, 9 Aug 2018 06:37:16 +0000 (08:37 +0200)]
Add missing documentation for --jobs in find-debuginfo.sh
Bernhard M. Wiedemann [Mon, 30 Jul 2018 17:02:46 +0000 (19:02 +0200)]
find-debuginfo.sh: sort output of find
to make build results more reproducible
in spite of indeterministic filesystem readdir order.
For openSUSE, this helped to make squid, openssh, postfix and shadow
packages build reproducibly.
See https://reproducible-builds.org/ for why this is good.
Panu Matilainen [Wed, 1 Aug 2018 08:29:10 +0000 (11:29 +0300)]
Fix an obvious typo in dwz filename generation
This typo has always been there since the initial implementation in
Fedora-specific patches in 2012 and inherited upstream. Which suggests
something hasn't been working right all this time, or then this will
break something all of a sudden...
Mark Wielaard [Sat, 21 Jul 2018 08:13:04 +0000 (10:13 +0200)]
find-debuginfo.sh: decompress DWARF compressed ELF sections
debugedit and dwz do not support DWARF compressed ELF sections, let's
just decompress those before extracting debuginfo.
Tested-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Mark Wielaard [Tue, 22 May 2018 20:20:19 +0000 (22:20 +0200)]
find-debuginfo.sh: Handle application/x-pie-executable (file 5.33 output).
A new version of file (5.33) changed the output for PIE executables.
Which are now represented as application/x-pie-executable; charset=binary.
The following change simply recognizes that binary format as one for
which -g applies. This fixes accidental stripping of the .symtab in
glibc (which use -g to keep that symbol table).
https://bugzilla.redhat.com/show_bug.cgi?id=
1581224
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 12 Mar 2018 13:16:15 +0000 (14:16 +0100)]
debugedit: Only try to collect comp_dir in phase zero.
edit_attributes is run twice. Once for phase zero in which all strings are
collected. Then then for phase one in which the strings are rewritten. In
phase zero we also try to collect the comp_dir (either from the
DW_AT_comp_dir or the DW_AT_name of the compile unit). We were also
collecting the comp_dir is phase 1, which is unnecessary, and would not
actually work, since we would be using to old string table index for that,
which had already been rewritten.
Caught by the new string table index checks.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 7 Mar 2018 15:25:31 +0000 (16:25 +0100)]
debugedit: Check .debug_str index is valid before use.
debugedit would blindly use an .debug_str index from the .debug_info or
.debug_line sections assuming it would result in a valid string. Which
would crash and burn if the DWARF data was bogus when the string was
used. So check whenever converting an string index into a char pointer
so we can produce a more helpful error message.
https://bugzilla.redhat.com/show_bug.cgi?id=
1543912
Signed-off-by: Mark Wielaard <mark@klomp.org>
Andreas Schwab [Mon, 26 Feb 2018 09:34:26 +0000 (10:34 +0100)]
debugedit: handle RISC-V relocation
Resolves #407
Mark Wielaard [Mon, 22 Jan 2018 15:55:51 +0000 (16:55 +0100)]
Fix type mismatch calculating new line program offset in debugedit.c.
edit_dwarf2 calculates the (new) offset in the line program by
taking the difference between the old and new idx, which are of type
size_t (unsigned), plus the size_diff of the header given as ssize_t
(signed), and adding that to the current r_offset, which is an Elf64_Addr
(unsigned). On 64bit architectures, where the size of Elf64_Addr and
ssize_t are the same this isn't a problem. But on 32bit architectures,
where the size of ssize_t is smaller than Elf64_Addr the smaller signed
result gets promoted to an unsigned long first causing issues if the
size_diff was negative.
This would have been caught by gcc -Wsign-conversion
warning: conversion to ‘long unsigned int’ from ‘ssize_t’ {aka ‘long int’}
may change the sign of the result
But enabling this by default gives a lot of false positives.
Found and fixed by Richard Biener <rguenther@suse.de>.
Mark Wielaard [Fri, 8 Dec 2017 12:46:16 +0000 (14:46 +0200)]
Support --jobs as an alias to -j in find-debuginfo.sh (RhBug:
1518120)
make supports both, and as %_smp_mflags gets passed to both make and
find-debuginfo.sh now we better accept the same options for as make.
Mark Wielaard [Fri, 13 Oct 2017 21:27:32 +0000 (23:27 +0200)]
debugedit: edit_dwarf2 check lndx is in range before checking r_offset.
Panu Matilainen [Thu, 10 Aug 2017 08:17:36 +0000 (11:17 +0300)]
Revert "Warn and create empty debugsource package if there are no sources."
This reverts commit
11b9f5b312f248841ae6ebf6602496cfe2ffb5fe.
Mark Wielaard [Fri, 28 Jul 2017 13:29:52 +0000 (15:29 +0200)]
Warn and create empty debugsource package if there are no sources.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Igor Gnatenko [Fri, 28 Jul 2017 05:42:38 +0000 (07:42 +0200)]
find-debuginfo.sh: make sure that debugsourcefiles.list is generated under the builddir
The %_debugsource_template expects the debugsourcefiles.list file
to be in the (current) build dir. Make sure that is always the case
even if find-debuginfo.sh was invoked in a different (sub) directory
by prepending $BUILDDIR to the output file as written in description
"All file names in switches are relative to builddir (. if not given).".
Closes: https://github.com/rpm-software-management/rpm/issues/279
Based-on-patch-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Mark Wielaard [Wed, 19 Jul 2017 12:53:53 +0000 (14:53 +0200)]
find-debuginfo.sh: Remove non-allocated NOBITS sections from minisymtab.
In the minisymtab section (the .gnu_debugdata embedded ELF image) we
do not need unallocated sections (except for the SYMTAB and STRTAB
sections we are creating). We already remove PROGBITS and NOTES. Also
remove NOBITS sections. They should not really take up much (any) space
but they still add to the section tables. These sections might be created
with the new --keep-section support (which puts the actual section in
the main ELF binary, and a NOBITS variant in the .debug file).
Also binutils objcopy seems to sometimes add them anyway filled with
zeros instead of marking them NOBITS.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 17 Jul 2017 10:58:26 +0000 (12:58 +0200)]
find-debuginfo.sh: Add --keep-section and --remove-section for eu-strip.
Use --keep-section SECTION or --remove-section SECTION to explicitly
keep a (non-allocated) section in the main executable or explicitly
remove it into the .debug file. SECTION is an extended wildcard pattern.
Both options can be given more than once.
https://bugzilla.redhat.com/show_bug.cgi?id=
1465997
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 28 Jun 2017 12:21:32 +0000 (14:21 +0200)]
find-debuginfo.sh: Use 'return', not 'continue', to break out do_file().
commit 038bfe "Split directory traversal and debuginfo extraction"
put the core of a while loop into its own function 'do_file()'.
That means that instead of using 'continue' to break out early it now
needs to use 'return'. Otherwise the script will give errors like:
continue: only meaningful in a `for', `while', or `until' loop
https://bugzilla.redhat.com/show_bug.cgi?id=
1465170
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 28 Jun 2017 11:34:55 +0000 (13:34 +0200)]
find-debuginfo.sh: Filter out all <built-in> like fake file names.
There is no official way to mark an instruction range as being not
part of some actual source code, but as part of a compiler built-in
construct in DWARF. So different compilers have come up with fake
source file names like <built-in> or <__thread_local_inner macros>.
We already filtered out the strings "<internal>" and "<built-in>".
Just filter out all '(^|/)<[a-z _-]+>$'. They are fake files!
This is mainly to appease the rustc compiler which generates lots of
different variants to encode some instruction sequence is part of an
compiler generated macro expansion.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Wed, 28 Jun 2017 18:25:39 +0000 (20:25 +0200)]
debugedit: skip_dir_prefix should check for dir separator.
To count as a real directory prefix the string matched should either
be equal to the given prefix or start with the prefix plus '/'.
skip_dir_prefix is always used with base_dir or dest_dir which don't
end with a slash themselves.
This really only is an issue if a package would put a directory named
similar to the package source dir (which cargo on fedora does, by adding
a directory named cargo-vendor in the builddir itself).
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 26 Jun 2017 15:38:30 +0000 (17:38 +0200)]
find-debuginfo.sh: Don't create dwz multi file if there is only one .debug.
dwz -m multi only works when there are multiple .debug input files.
With just one .debug file it doesn't really make sense to extract
the shared debug info into a separate file and dwz will complain:
dwz: Too few files for multifile optimization.
So only add -m multi if there is more than one .debug file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard [Mon, 26 Jun 2017 11:35:48 +0000 (13:35 +0200)]
Update find-debuginfo.sh options and macros documentation.
This adds some missing documentation for rpm macros and find-debuginfo.sh
options that were recently added (or renamed). -j N, --build-id-seed SEED,
--unique-debug-suffix SUFFIX and --unique-debug-src-base BASE.
Signed-off-by: Mark Wielaard <mark@klomp.org>
This page took 0.090336 seconds and 5 git commands to generate.