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

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