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

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