Blame SOURCES/gdb-archer-pie-addons-keep-disabled.patch

4c2ad1
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4c2ad1
From: Fedora GDB patches <invalid@email.com>
4c2ad1
Date: Fri, 27 Oct 2017 21:07:50 +0200
4c2ad1
Subject: gdb-archer-pie-addons-keep-disabled.patch
4c2ad1
4c2ad1
;;=push+jan: Breakpoints disabling matching should not be based on address.
4c2ad1
4c2ad1
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
4c2ad1
--- a/gdb/breakpoint.c
4c2ad1
+++ b/gdb/breakpoint.c
4c2ad1
@@ -15522,6 +15522,50 @@ initialize_breakpoint_ops (void)
4c2ad1
 
4c2ad1
 static struct cmd_list_element *enablebreaklist = NULL;
4c2ad1
 
4c2ad1
+void
4c2ad1
+breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta)
4c2ad1
+{
4c2ad1
+  struct bp_location *bl, **blp_tmp;
4c2ad1
+  int changed = 0;
4c2ad1
+
4c2ad1
+  gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
4c2ad1
+
4c2ad1
+  ALL_BP_LOCATIONS (bl, blp_tmp)
4c2ad1
+    {
4c2ad1
+      struct obj_section *osect;
4c2ad1
+
4c2ad1
+      /* BL->SECTION can be correctly NULL for breakpoints with multiple
4c2ad1
+         locations expanded through symtab.  */
4c2ad1
+
4c2ad1
+      ALL_OBJFILE_OSECTIONS (objfile, osect)
4c2ad1
+	{
4c2ad1
+	  CORE_ADDR relocated_address;
4c2ad1
+	  CORE_ADDR delta_offset;
4c2ad1
+
4c2ad1
+	  delta_offset = ANOFFSET (delta, osect->the_bfd_section->index);
4c2ad1
+	  if (delta_offset == 0)
4c2ad1
+	    continue;
4c2ad1
+	  relocated_address = bl->address + delta_offset;
4c2ad1
+
4c2ad1
+	  if (obj_section_addr (osect) <= relocated_address
4c2ad1
+	      && relocated_address < obj_section_endaddr (osect))
4c2ad1
+	    {
4c2ad1
+	      if (bl->inserted)
4c2ad1
+		remove_breakpoint (bl);
4c2ad1
+
4c2ad1
+	      bl->address += delta_offset;
4c2ad1
+	      bl->requested_address += delta_offset;
4c2ad1
+
4c2ad1
+	      changed = 1;
4c2ad1
+	    }
4c2ad1
+	}
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  if (changed)
4c2ad1
+    qsort (bp_locations, bp_locations_count, sizeof (*bp_locations),
4c2ad1
+	   bp_locations_compare);
4c2ad1
+}
4c2ad1
+
4c2ad1
 void
4c2ad1
 _initialize_breakpoint (void)
4c2ad1
 {
4c2ad1
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
4c2ad1
--- a/gdb/breakpoint.h
4c2ad1
+++ b/gdb/breakpoint.h
4c2ad1
@@ -1679,6 +1679,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg);
4c2ad1
    UIOUT iff debugging multiple threads.  */
4c2ad1
 extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
4c2ad1
 
4c2ad1
+extern void breakpoints_relocate (struct objfile *objfile,
4c2ad1
+				  struct section_offsets *delta);
4c2ad1
+
4c2ad1
 /* Print the specified breakpoint.  */
4c2ad1
 extern void print_breakpoint (breakpoint *bp);
4c2ad1
 
4c2ad1
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
4c2ad1
--- a/gdb/objfiles.c
4c2ad1
+++ b/gdb/objfiles.c
4c2ad1
@@ -883,6 +883,11 @@ objfile_relocate1 (struct objfile *objfile,
4c2ad1
 				obj_section_addr (s));
4c2ad1
     }
4c2ad1
 
4c2ad1
+  /* Final call of breakpoint_re_set can keep breakpoint locations disabled if
4c2ad1
+     their addresses match.  */
4c2ad1
+  if (objfile->separate_debug_objfile_backlink == NULL)
4c2ad1
+    breakpoints_relocate (objfile, delta);
4c2ad1
+
4c2ad1
   /* Data changed.  */
4c2ad1
   return 1;
4c2ad1
 }