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.patch
4c2ad1
4c2ad1
;;=push+jan: May get obsoleted by Tom's unrelocated objfiles patch.
4c2ad1
4c2ad1
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
4c2ad1
--- a/gdb/gdbtypes.h
4c2ad1
+++ b/gdb/gdbtypes.h
4c2ad1
@@ -505,6 +505,7 @@ enum field_loc_kind
4c2ad1
   {
4c2ad1
     FIELD_LOC_KIND_BITPOS,	/**< bitpos */
4c2ad1
     FIELD_LOC_KIND_ENUMVAL,	/**< enumval */
4c2ad1
+    /* This address is unrelocated by the objfile's ANOFFSET.  */
4c2ad1
     FIELD_LOC_KIND_PHYSADDR,	/**< physaddr */
4c2ad1
     FIELD_LOC_KIND_PHYSNAME,	/**< physname */
4c2ad1
     FIELD_LOC_KIND_DWARF_BLOCK	/**< dwarf_block */
4c2ad1
@@ -556,6 +557,7 @@ union field_location
4c2ad1
      field.  Otherwise, physname is the mangled label of the
4c2ad1
      static field.  */
4c2ad1
 
4c2ad1
+  /* This address is unrelocated by the objfile's ANOFFSET.  */
4c2ad1
   CORE_ADDR physaddr;
4c2ad1
   const char *physname;
4c2ad1
 
4c2ad1
@@ -1438,6 +1440,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
4c2ad1
 #define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval)
4c2ad1
 #define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0)
4c2ad1
 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
4c2ad1
+/* This address is unrelocated by the objfile's ANOFFSET.  */
4c2ad1
 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
4c2ad1
 #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
4c2ad1
 #define SET_FIELD_BITPOS(thisfld, bitpos)			\
4c2ad1
@@ -1449,6 +1452,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
4c2ad1
 #define SET_FIELD_PHYSNAME(thisfld, name)			\
4c2ad1
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME,		\
4c2ad1
    FIELD_STATIC_PHYSNAME (thisfld) = (name))
4c2ad1
+/* This address is unrelocated by the objfile's ANOFFSET.  */
4c2ad1
 #define SET_FIELD_PHYSADDR(thisfld, addr)			\
4c2ad1
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR,		\
4c2ad1
    FIELD_STATIC_PHYSADDR (thisfld) = (addr))
4c2ad1
@@ -1465,6 +1469,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
4c2ad1
 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
4c2ad1
 #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n))
4c2ad1
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
4c2ad1
+/* This address is unrelocated by the objfile's ANOFFSET.  */
4c2ad1
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
4c2ad1
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
4c2ad1
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
4c2ad1
diff --git a/gdb/value.c b/gdb/value.c
4c2ad1
--- a/gdb/value.c
4c2ad1
+++ b/gdb/value.c
4c2ad1
@@ -2829,7 +2829,8 @@ value_static_field (struct type *type, int fieldno)
4c2ad1
     {
4c2ad1
     case FIELD_LOC_KIND_PHYSADDR:
4c2ad1
       retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
4c2ad1
-			      TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
4c2ad1
+			      TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)
4c2ad1
+			      + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
4c2ad1
       break;
4c2ad1
     case FIELD_LOC_KIND_PHYSNAME:
4c2ad1
     {