Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
d23740fbaf
!58 [sync] PR-55: find-debuginfo: Fix skip_mini (".gnu_debugdata") handling
From: @openeuler-sync-bot 
Reviewed-by: @xujing99 
Signed-off-by: @xujing99
2025-04-21 07:27:38 +00:00
hugel
9d7a84c0c7 find-debuginfo: Fix skip_mini (".gnu_debugdata") handling
(cherry picked from commit 6aa93d74c485e5f76ffffd5525aa8eab93b40562)
2025-04-21 14:18:18 +08:00
openeuler-ci-bot
fda9005a0e
!51 [sync] PR-49: add sw_64 support
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2025-02-28 07:57:18 +00:00
liweigang
14be23854c add sw_64 support
Signed-off-by: liweigang <liweiganga@uniontech.com>
(cherry picked from commit d0db9f95eb1b6575046ffd618901299a8af1fe97)
2025-02-28 14:25:41 +08:00
openeuler-ci-bot
b49248b66b
!42 backport patches from upstream
From: @hugel 
Reviewed-by: @shenyangyang01 
Signed-off-by: @shenyangyang01
2024-12-12 08:52:31 +00:00
hugel
a4aa189fbc backport patches from upstream 2024-12-12 16:17:49 +08:00
openeuler-ci-bot
afca1b217f
!36 [sync] PR-33: 回合上游补丁修复可能的测试失败
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-11-28 06:46:57 +00:00
laokz
67772e585f backport upstream to avoid tests failure
readelf might produce some warning messages that don't matter for the
specific tests in debugedit.at. So ignore stderr output and just check
stdout output is as expected.

The issue reported by riscv64 building.

(cherry picked from commit 99ecf4c529ba89a6cebffa2ee8f7ac5db63358ec)
2024-11-28 14:21:09 +08:00
openeuler-ci-bot
d0a1545d8a
!28 修复loongarch64平台的patch在x86_64或其他平台编译出来的源码包中丢失的问题
From: @nebd 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-06-07 06:35:24 +00:00
孤独的大河马在躺平
4e87d80348
Fix lack of loongarch64 patch files in src.rpm package which is build from any platform.
Signed-off-by: 孤独的大河马在躺平 <shaojiansong@kylinos.cn>
2024-05-28 09:33:56 +00:00
7 changed files with 497 additions and 4 deletions

24
add-sw_64-support.patch Normal file
View File

@ -0,0 +1,24 @@
From 5d5b6fae22f4bc7627009ea171534c115b5f5677 Mon Sep 17 00:00:00 2001
From: mahailiang <mahailiang@uniontech.com>
Date: Wed, 30 Oct 2024 21:33:17 +0800
Subject: [PATCH] add sw_64 support
---
tools/debugedit.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 216e2fa..0067238 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -598,6 +598,10 @@ setup_relbuf (DSO *dso, debug_section *sec, int *reltype)
if (rtype != R_X86_64_32)
goto fail;
break;
+ case EM_SW_64:
+ if (rtype != R_SW_64_REFLONG)
+ goto fail;
+ break;
case EM_ALPHA:
if (rtype != R_ALPHA_REFLONG)
goto fail;
--
2.20.1

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,33 @@
From 64d61a5f7d0ed685880f5c4f4b91f967445ba3a9 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 16 Jan 2025 12:02:11 +0100
Subject: [PATCH] find-debuginfo: Fix skip_mini (".gnu_debugdata") handling
The conditional that tests $skip_mini for true/false was inadvertently
flipped, causing the add_minidebug() function to no longer run for the
otherwise eligible binary files.
Fixes: 971a74d79b48 ("find-debuginfo: Check files are writable before modifying them")
Reported-by: Michal Domonkos <mdomonko@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
scripts/find-debuginfo.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index 4e4ef5a..f889e6d 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -550,7 +550,7 @@ do_file()
application/x-executable*) skip_mini=false ;;
application/x-pie-executable*) skip_mini=false ;;
esac
- if test "$skip_mini" = "true"; then
+ if test "$skip_mini" = "false"; then
if test "$f_writable" = "false"; then
chmod u+w "$f"
fi
--
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

@ -0,0 +1,158 @@
From 785f451a1b05f89c3b24eb5550f35488b80152b7 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 6 Nov 2024 00:28:40 +0100
Subject: [PATCH] tests: Ignore stderr output of readelf in debugedit.at
readelf might produce some warning messages that don't matter for the
specific tests in debugedit.at. So ignore stderr output and just check
stdout output is as expected.
https://sourceware.org/bugzilla/show_bug.cgi?id=31653
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tests/debugedit.at | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 1c59e86..fa38416 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -308,7 +308,7 @@ AT_CHECK([[
readelf --debug-dump=info foo.o subdir_bar/bar.o baz.o \
| grep -E 'DW_AT_(name|comp_dir)' \
| rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -331,7 +331,7 @@ AT_CHECK([[
readelf --debug-dump=info ./foobarbaz.part.o \
| grep -E 'DW_AT_(name|comp_dir)' \
| rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -353,7 +353,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
AT_CHECK([[
readelf --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
| rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -390,7 +390,7 @@ for i in ./foo.o ./subdir_bar/bar.o ./baz.o;do \
| sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
| sort;
done
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -419,7 +419,7 @@ readelf --debug-dump=info ./foobarbaz.part.o \
| awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
| sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
| sort
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -448,7 +448,7 @@ readelf --debug-dump=info ./foobarbaz.exe \
| awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
| sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
| sort
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -477,7 +477,7 @@ AT_CHECK([[
readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
| grep -A3 "The Directory Table" | grep "^ [123]" \
| grep /foo/ | cut -c5- | sort
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -504,7 +504,7 @@ AT_CHECK([[
readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
| grep -A5 "The Directory Table" | grep "^ [0123]" \
| cut -f2- -d/ | grep ^foo/ | sort -u
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -526,7 +526,7 @@ AT_CHECK([[
readelf --debug-dump=line ./foobarbaz.part.o \
| grep -A3 "The Directory Table" | grep "^ [123]" \
| grep /foo/ | cut -c5- | sort
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -551,7 +551,7 @@ AT_CHECK([[
readelf --debug-dump=line ./foobarbaz.part.o \
| grep -A5 "The Directory Table" | grep "^ [0123]" \
| cut -f2- -d/ | grep ^foo/ | sort -u
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -573,7 +573,7 @@ AT_CHECK([[
readelf --debug-dump=line ./foobarbaz.exe \
| grep -A3 "The Directory Table" | grep "^ [123]" \
| grep /foo/ | cut -c5- | sort
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -598,7 +598,7 @@ AT_CHECK([[
readelf --debug-dump=line ./foobarbaz.exe \
| grep -A5 "The Directory Table" | grep "^ [0123]" \
| cut -f2- -d/ | grep ^foo/ | sort -u
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -623,7 +623,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
AT_CHECK([[
readelf --debug-dump=macro foo.o subdir_bar/bar.o baz.o \
| grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -646,7 +646,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
AT_CHECK([[
readelf --debug-dump=macro ./foobarbaz.part.o \
| grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
@@ -669,7 +669,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
AT_CHECK([[
readelf --debug-dump=macro ./foobarbaz.exe \
| grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
-]],[0],[expout])
+]],[0],[expout],[ignore])
AT_CLEANUP
--
2.39.5

View File

@ -1,6 +1,6 @@
Name: debugedit
Version: 5.0
Release: 6
Release: 11
Summary: Tools for debuginfo creation
License: GPL-2.0-or-later and LGPL-2.1-only and GPL-3.0-only
Group: Applications
@ -21,9 +21,13 @@ Patch0: tests-Handle-zero-directory-entry-in-.debug_line-DWA.patch
Patch1: find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
Patch6000: backport-Fix-u-option.patch
%ifarch loongarch64
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
Patch6005: backport-find-debuginfo-Fix-skip_mini-.gnu_debugdata-handling.patch
Patch9000: add-loongarch-support-for-debugedit.patch
%endif
Patch9001: add-sw_64-support.patch
%description
Debugedit provides programs and scripts for creating debuginfo and
@ -31,7 +35,21 @@ source file distributions, collect build-ids and rewrite source
paths in DWARF data for debugging, tracing and profiling.
%prep
%autosetup -p1
%setup -q
%patch0 -p1
%patch1 -p1
%patch6000 -p1
%patch6001 -p1
%patch6002 -p1
%patch6003 -p1
%patch6004 -p1
%patch6005 -p1
%ifarch loongarch64
%patch9000 -p1
%endif
%ifarch sw_64
%patch9001 -p1
%endif
%build
autoreconf -f -v -i
@ -67,6 +85,21 @@ make check %{?_smp_mflags}
%{_rpmconfigdir}/debugedit
%changelog
* Mon Apr 21 2025 hugel <gengqihu2@h-partners.com> - 5.0-11
- find-debuginfo: Fix skip_mini (".gnu_debugdata") handling
* Thu Feb 27 2025 liweigang <liweiganga@uniontech.com> - 5.0-10
- add sw_64 support
* 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
* Tue May 28 2024 shaojiansong <shaojiansong@kylinos.cn> - 5.0-7
- Fix lack of loongarch64 patch files in src.rpm package which is build from any platform.
* Fri Jan 6 2023 Wenlong Zhang<zhangwenlong@loongson.cn> - 5.0-6
- add loongarch64 support for debugedit