From ba75ec63f8bc3e68be8a5d84b39e2e241e091238 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Tue, 13 Jun 2023 07:34:45 -0700 Subject: [PATCH] Import rawhide gdb-add-index.patch This patch permits users to override what version of gdb to use when invoking gdb-add-index.sh. Resolves: rhbz#2213228 --- _gdb.spec.Patch.include | 13 +++++-- _patch_order | 2 +- gdb-add-index.patch | 77 +++++++++++++++++++++++++++++++++++++ gdb-libexec-add-index.patch | 37 ------------------ gdb.spec | 6 ++- 5 files changed, 92 insertions(+), 43 deletions(-) create mode 100644 gdb-add-index.patch delete mode 100644 gdb-libexec-add-index.patch diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include index 1647254..3c93a0a 100644 --- a/_gdb.spec.Patch.include +++ b/_gdb.spec.Patch.include @@ -241,14 +241,19 @@ Patch057: gdb-container-rh-pkg.patch #=fedora Patch058: gdb-linux_perf-bundle.patch -# Fix gdb-headless /usr/bin/ executables (BZ 1390251). +# Update gdb-add-index.sh such that, when the GDB environment +# variable is not set, the script is smarter than just looking for +# 'gdb' in the $PATH. # -# Also, make /usr/bin/gdb.minimal be the default GDB used, if it's -# present. For rationale, see: +# The actual search order is now: /usr/bin/gdb.minimal, gdb (in the +# $PATH), then /usr/libexec/gdb. +# +# For the rationale of looking for gdb.minimal see: # # https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot +# #=fedora -Patch059: gdb-libexec-add-index.patch +Patch059: gdb-add-index.patch # [s390x] Backport arch12 instructions decoding (RH BZ 1553104). # =fedoratest diff --git a/_patch_order b/_patch_order index 9258332..0a0491b 100644 --- a/_patch_order +++ b/_patch_order @@ -56,7 +56,7 @@ gdb-opcodes-clflushopt-test.patch gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch gdb-container-rh-pkg.patch gdb-linux_perf-bundle.patch -gdb-libexec-add-index.patch +gdb-add-index.patch gdb-rhbz1553104-s390x-arch12-test.patch gdb-backport-readline_support.patch gdb-backport-fix-break-main-file-remove-fail.patch diff --git a/gdb-add-index.patch b/gdb-add-index.patch new file mode 100644 index 0000000..b95e06f --- /dev/null +++ b/gdb-add-index.patch @@ -0,0 +1,77 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-add-index.patch + +;; Update gdb-add-index.sh such that, when the GDB environment +;; variable is not set, the script is smarter than just looking for +;; 'gdb' in the $PATH. +;; +;; The actual search order is now: /usr/bin/gdb.minimal, gdb (in the +;; $PATH), then /usr/libexec/gdb. +;; +;; For the rationale of looking for gdb.minimal see: +;; +;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot +;; +;;=fedora + +diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh +--- a/gdb/contrib/gdb-add-index.sh ++++ b/gdb/contrib/gdb-add-index.sh +@@ -16,14 +16,52 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-# This program assumes gdb and objcopy are in $PATH. +-# If not, or you want others, pass the following in the environment +-GDB=${GDB:=gdb} ++# This program assumes objcopy and readelf are in $PATH. If not, or ++# you want others, pass the following in the environment + OBJCOPY=${OBJCOPY:=objcopy} + READELF=${READELF:=readelf} + + myname="${0##*/}" + ++# For GDB itself we need to be a little smarter. If GDB is set in the ++# environment then we will use that. But if GDB is not set in the ++# environment then we have a couple of options that we need to check ++# through. ++# ++# Our default choice is for /usr/bin/gdb.minimal. For an explanation ++# of why this is chosen, check out: ++# https://bugzilla.redhat.com/show_bug.cgi?id=1695015 ++# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot ++# ++# If gdb.minimal is not found then we look for a 'gdb' executable on ++# the path. ++# ++# And finally, we check for /usr/libexec/gdb. ++# ++# If none of those result in a useable GDB then we give an error and ++# exit. ++if test -z "$GDB"; then ++ for possible_gdb in /usr/bin/gdb.minimal gdb /usr/libexec/gdb; do ++ if ! which "$possible_gdb" 2>/dev/null; then ++ continue ++ fi ++ ++ possible_gdb=$(which "$possible_gdb") ++ ++ if ! test -x "$possible_gdb"; then ++ continue ++ fi ++ ++ GDB="$possible_gdb" ++ break ++ done ++ ++ if test -z "$GDB"; then ++ echo "$myname: Failed to find a useable GDB binary" 1>&2 ++ exit 1 ++ fi ++fi ++ + dwarf5="" + if [ "$1" = "-dwarf-5" ]; then + dwarf5="$1" diff --git a/gdb-libexec-add-index.patch b/gdb-libexec-add-index.patch deleted file mode 100644 index 19f6b54..0000000 --- a/gdb-libexec-add-index.patch +++ /dev/null @@ -1,37 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Fedora GDB patches -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-libexec-add-index.patch - -;; Fix gdb-headless /usr/bin/ executables (BZ 1390251). -;; -;; Also, make /usr/bin/gdb.minimal be the default GDB used, if it's -;; present. For rationale, see: -;; -;; https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot -;;=fedora - -diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh ---- a/gdb/contrib/gdb-add-index.sh -+++ b/gdb/contrib/gdb-add-index.sh -@@ -22,6 +22,20 @@ GDB=${GDB:=gdb} - OBJCOPY=${OBJCOPY:=objcopy} - READELF=${READELF:=readelf} - -+GDB2=/usr/libexec/gdb -+if test -x $GDB2 && ! which $GDB &>/dev/null; then -+ GDB=$GDB2 -+fi -+ -+# We default to using /usr/bin/gdb.minimal if it's present. See -+# https://bugzilla.redhat.com/show_bug.cgi?id=1695015 and -+# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot for -+# explanations. -+GDB3=/usr/bin/gdb.minimal -+if test -x $GDB3; then -+ GDB=$GDB3 -+fi -+ - myname="${0##*/}" - - dwarf5="" diff --git a/gdb.spec b/gdb.spec index 2b0cde4..b309fff 100644 --- a/gdb.spec +++ b/gdb.spec @@ -69,7 +69,7 @@ Version: 12.1 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL # Do not provide URL for snapshots as the file lasts there only for 2 days. @@ -1201,6 +1201,10 @@ fi %endif %changelog +* Tue Jun 13 2023 Keith Seitz - 12.1-3.el9 +- Backport "Update gdb-add-index.sh ..." + (Andrew Burgess, RHBZ 2213228) + * Thu Apr 27 2023 Keith Seitz - 12.1-2.el9 - Backport binutls/29699 "Fix an illegal memory access when parsing..." (Nick Clifton, RHBZ 2153228)