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

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