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