Blame SOURCES/gdb-rhbz2086761-unknown-cfa-rule.patch

e22c64
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
e22c64
From: Keith Seitz <keiths@redhat.com>
e22c64
Date: Tue, 24 May 2022 07:39:17 -0700
e22c64
Subject: gdb-rhbz2086761-unknown-cfa-rule.patch
e22c64
e22c64
;; Backport "fix logic of find_comp_unit and set_comp_unit"
e22c64
;; (Simon Marchi, RHBZ 2086761)
e22c64
e22c64
The logic in find_comp_unit and set_comp_unit is reversed.  When the BFD
e22c64
requires relocation, we want to put the comp_unit structure in the
e22c64
map where the comp_unit objects are not shared, that is the one indexed
e22c64
by objfile.  If the BFD does not require relocation, then, we can share
e22c64
a single comp_unit structure for all users of that BFD, so we want to
e22c64
put it in the BFD-indexed map.  The comments on top of
e22c64
dwarf2_frame_bfd_data and dwarf2_frame_objfile_data make that clear.
e22c64
e22c64
Fix it by swapping the two in find_comp_unit and set_comp_unit.
e22c64
e22c64
I don't have a test for this, because I don't see how to write one in a
e22c64
reasonable amount of time.
e22c64
e22c64
gdb/ChangeLog:
e22c64
e22c64
        PR gdb/26876
e22c64
        * dwarf2/frame.c (find_comp_unit, set_comp_unit): Reverse use of
e22c64
        dwarf2_frame_bfd_data and dwarf2_frame_objfile_data.
e22c64
e22c64
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
e22c64
--- a/gdb/dwarf2/frame.c
e22c64
+++ b/gdb/dwarf2/frame.c
e22c64
@@ -1640,8 +1640,9 @@ find_comp_unit (struct objfile *objfile)
e22c64
 {
e22c64
   bfd *abfd = objfile->obfd;
e22c64
   if (gdb_bfd_requires_relocations (abfd))
e22c64
-    return dwarf2_frame_bfd_data.get (abfd);
e22c64
-  return dwarf2_frame_objfile_data.get (objfile);
e22c64
+    return dwarf2_frame_objfile_data.get (objfile);
e22c64
+
e22c64
+  return dwarf2_frame_bfd_data.get (abfd);
e22c64
 }
e22c64
 
e22c64
 /* Store the comp_unit on OBJFILE, or the corresponding BFD, as
e22c64
@@ -1652,8 +1653,9 @@ set_comp_unit (struct objfile *objfile, struct comp_unit *unit)
e22c64
 {
e22c64
   bfd *abfd = objfile->obfd;
e22c64
   if (gdb_bfd_requires_relocations (abfd))
e22c64
-    return dwarf2_frame_bfd_data.set (abfd, unit);
e22c64
-  return dwarf2_frame_objfile_data.set (objfile, unit);
e22c64
+    return dwarf2_frame_objfile_data.set (objfile, unit);
e22c64
+
e22c64
+  return dwarf2_frame_bfd_data.set (abfd, unit);
e22c64
 }
e22c64
 
e22c64
 /* Find the FDE for *PC.  Return a pointer to the FDE, and store the