!42 backport patches from upstream

From: @hugel 
Reviewed-by: @shenyangyang01 
Signed-off-by: @shenyangyang01
This commit is contained in:
openeuler-ci-bot 2024-12-12 08:52:31 +00:00 committed by Gitee
commit b49248b66b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 257 additions and 3 deletions

View File

@ -0,0 +1,102 @@
From 971a74d79b48a19ff1446642f39b3c5a8a7db238 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 28 Nov 2024 17:58:54 +0100
Subject: [PATCH] find-debuginfo: Check files are writable before modifying
them
Since commit dfe1f7ff3 ("find-debuginfo.sh: Exit with real exit status
in parallel jobs") there is a check whether gdb-add-index worked
correctly and find-debuginfo would fail (even in parallel mode) if an
error occured.
This turned out to show that gdb-add-index needs write permission to
add the gdb index to the file. This is also the case for a couple of
other things, like running objcopy --merge-notes. debugedit and
add_minidebug already made sure it had write permission.
To make sure find-debuginfo doesn't (partially) fail extend the
writable check to include the gdb-add-index and objcopy --merge-notes
invocation.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
scripts/find-debuginfo.in | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index a360bf0..4e4ef5a 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -481,14 +481,29 @@ do_file()
$strict && return 2
fi
+ # debugedit makes sure to to get write permission to the file and
+ # restores original state after modifications. Other utilities
+ # might not.
+ f_writable="false"
+ if test -w "$f"; then f_writable="true"; fi
+
# Add .gdb_index if requested.
if $include_gdb_index; then
if type gdb-add-index >/dev/null 2>&1; then
+ if test "$f_writable" = "false"; then
+ chmod u+w "$f"
+ fi
gdb-add-index "$f" || {
status=$?
echo >&2 "*** ERROR:: GDB exited with exit status $status during index generation"
+ if test "$f_writable" = "false"; then
+ chmod u-w "$f"
+ fi
return 2
}
+ if test "$f_writable" = "false"; then
+ chmod u-w "$f"
+ fi
else
echo >&2 "*** ERROR: GDB index requested, but no gdb-add-index installed"
return 2
@@ -497,7 +512,13 @@ do_file()
# Compress any annobin notes in the original binary.
# Ignore any errors, since older objcopy don't support --merge-notes.
+ if test "$f_writable" = "false"; then
+ chmod u+w "$f"
+ fi
objcopy --merge-notes "$f" 2>/dev/null || true
+ if test "$f_writable" = "false"; then
+ chmod u-w "$f"
+ fi
# A binary already copied into /usr/lib/debug doesn't get stripped,
# just has its file names collected and adjusted.
@@ -507,7 +528,7 @@ do_file()
esac
mkdir -p "${debugdn}"
- if test -w "$f"; then
+ if test "$f_writable" = "true"; then
strip_to_debug "${debugfn}" "$f"
else
chmod u+w "$f"
@@ -529,7 +550,15 @@ do_file()
application/x-executable*) skip_mini=false ;;
application/x-pie-executable*) skip_mini=false ;;
esac
- $skip_mini || add_minidebug "${debugfn}" "$f"
+ if test "$skip_mini" = "true"; then
+ if test "$f_writable" = "false"; then
+ chmod u+w "$f"
+ fi
+ add_minidebug "${debugfn}" "$f"
+ if test "$f_writable" = "false"; then
+ chmod u-w "$f"
+ fi
+ fi
fi
echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
--
2.33.0

View File

@ -0,0 +1,36 @@
From 41fc1335b8b364c95a8ee2ed2956bbdfe7957853 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <dvlasenk@redhat.com>
Date: Wed, 14 Jun 2023 16:56:38 +0200
Subject: [PATCH] find-debuginfo: remove duplicate filenames when creating
debugsources.list
We remove duplicate filenames when we _process_ debugsources.list.
However, this means that momentarily we may have a very large
(in the range of *giga*bytes) debugsources.list.
This is unnecessary, we can also remove dups when we *create* it.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
---
scripts/find-debuginfo.in | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index 7dec3c3..e7ac095 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -575,7 +575,10 @@ else
exit 1
fi
done
- cat "$temp"/debugsources.* >"$SOURCEFILE"
+ # List of sources may have lots of duplicates. A kernel build was seen
+ # with this list reaching 448 megabytes in size. "sort" helps to not have
+ # _two_ sets of 448 megabytes of temp files here.
+ LC_ALL=C sort -z -u "$temp"/debugsources.* >"$SOURCEFILE"
cat "$temp"/elfbins.* >"$ELFBINSFILE"
fi
--
2.33.0

View File

@ -0,0 +1,107 @@
From dfe1f7ff30f4e0be538835fca1e6348723ea7aa7 Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Fri, 16 Aug 2024 11:54:20 -0700
Subject: [PATCH] find-debuginfo.sh: Exit with real exit status in parallel
jobs
Currently, when the script is executed in parallel (-jN), the
resulting exit status will always be 0.
The script execs an appropriate number of clones of itself, calling
run_job to run the actual workload. This then calls do_file(), saving
the exit status into "res.$jobid".
In do_file(), though, if an error occurs, exit is called. This causes
the entire exec'd shell to exit with status 0 (since there are almost
always echo calls as the last executed statement). The real exit
status is therefor never written to the "res.$jobid" files by run_job().
The simple solution is to use 'return' instead of 'exit'. A number
of minor adjustments are also made to propagate this properly so that
it is reported as the correct exit status.
While at it, I've incorporated a patch for find-debuginfo/30505.
Using this patch and another patch to the RPM package (submitted as
github issue #3215), failures of gdb-add-index.sh will now properly fail
the build instead of being swallowed. It should be much easier for
developers to figure out why their builds have failed should gdb crash.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30505
Signed-off-by: Keith Seitz <keiths@redhat.com>
---
scripts/find-debuginfo.in | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index ae0818f..5998b9d 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -477,16 +477,20 @@ do_file()
-l "$SOURCEFILE" "$f") || exit
if [ -z "$id" ]; then
echo >&2 "*** ${strict_error}: No build ID note found in $f"
- $strict && exit 2
+ $strict && return 2
fi
# Add .gdb_index if requested.
if $include_gdb_index; then
if type gdb-add-index >/dev/null 2>&1; then
- gdb-add-index "$f"
+ gdb-add-index "$f" || {
+ status=$?
+ echo >&2 "*** ERROR:: GDB exited with exit status $status during index generation"
+ return 2
+ }
else
echo >&2 "*** ERROR: GDB index requested, but no gdb-add-index installed"
- exit 2
+ return 2
fi
fi
@@ -547,6 +551,7 @@ run_job()
{
local jobid=$1 filenum
local SOURCEFILE=$temp/debugsources.$jobid ELFBINSFILE=$temp/elfbins.$jobid
+ local res=0
>"$SOURCEFILE"
>"$ELFBINSFILE"
@@ -558,8 +563,12 @@ run_job()
break
fi
do_file $(sed -n "$(( 0x$filenum )) p" "$temp/primary")
+ res=$?
+ if [ $res != 0 ]; then
+ break
+ fi
done
- echo 0 >"$temp/res.$jobid"
+ echo $res >"$temp/res.$jobid"
}
n_files=$(wc -l <"$temp/primary")
@@ -570,6 +579,10 @@ fi
if [ $n_jobs -le 1 ]; then
while read nlinks inum f; do
do_file "$nlinks" "$inum" "$f"
+ res=$?
+ if [ "$res" != "0" ]; then
+ exit $res
+ fi
done <"$temp/primary"
else
for ((i = 1; i <= n_files; i++)); do
@@ -587,7 +600,7 @@ else
test -f "$f" || continue
res=$(< "$f")
if [ "$res" != "0" ]; then
- exit 1
+ exit $res
fi
done
# List of sources may have lots of duplicates. A kernel build was seen
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: debugedit
Version: 5.0
Release: 8
Release: 9
Summary: Tools for debuginfo creation
License: GPL-2.0-or-later and LGPL-2.1-only and GPL-3.0-only
Group: Applications
@ -19,9 +19,12 @@ Requires: sed dwz grep
Patch0: tests-Handle-zero-directory-entry-in-.debug_line-DWA.patch
Patch1: find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
Patch2: tests-Ignore-stderr-output-of-readelf-in-debugedit.a.patch
Patch6000: backport-Fix-u-option.patch
Patch6001: backport-tests-Ignore-stderr-output-of-readelf-in-debugedit.a.patch
Patch6002: backport-find-debuginfo-remove-duplicate-filenames-when-creat.patch
Patch6003: backport-find-debuginfo.sh-Exit-with-real-exit-status-in-para.patch
Patch6004: backport-find-debuginfo-Check-files-are-writable-before-modif.patch
Patch9000: add-loongarch-support-for-debugedit.patch
%description
@ -33,8 +36,11 @@ paths in DWARF data for debugging, tracing and profiling.
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch6000 -p1
%patch6001 -p1
%patch6002 -p1
%patch6003 -p1
%patch6004 -p1
%ifarch loongarch64
%patch9000 -p1
%endif
@ -73,6 +79,9 @@ make check %{?_smp_mflags}
%{_rpmconfigdir}/debugedit
%changelog
* Thu Dec 12 2024 hugel <gengqihu2@h-partners.com> - 5.0-9
- backport patches from upstream
* Wed Nov 6 2024 laokz <zhangkai@iscas.ac.cn> - 5.0-8
- backport upstream patch to avoid tests failure