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

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