03de720
Index: gdb-7.0.90.20100306/gdb/dwarf2read.c
8c4c91e
===================================================================
03de720
--- gdb-7.0.90.20100306.orig/gdb/dwarf2read.c	2010-03-06 23:27:30.000000000 +0100
03de720
+++ gdb-7.0.90.20100306/gdb/dwarf2read.c	2010-03-06 23:28:43.000000000 +0100
03de720
@@ -5910,7 +5910,12 @@ read_common_block (struct die_info *die,
0911f37
 {
0911f37
   struct attribute *attr;
0911f37
   struct symbol *sym;
0911f37
-  CORE_ADDR base = (CORE_ADDR) 0;
0911f37
+  struct objfile *objfile = cu->objfile;
0911f37
+  CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
0911f37
+				 SECT_OFF_TEXT (objfile));
0911f37
+  /* This is used only for DW_AT_data_member_location entries.  */
0911f37
+  CORE_ADDR base = 0;
0911f37
+  int base_p = 0;
0911f37
 
0911f37
   attr = dwarf2_attr (die, DW_AT_location, cu);
0911f37
   if (attr)
03de720
@@ -5919,6 +5924,7 @@ read_common_block (struct die_info *die,
0911f37
       if (attr_form_is_block (attr))
8c4c91e
         {
8c4c91e
           base = decode_locdesc (DW_BLOCK (attr), cu);
0911f37
+	  base_p = 1;
8c4c91e
         }
0911f37
       else if (attr_form_is_section_offset (attr))
8c4c91e
         {
03de720
@@ -5980,12 +5986,15 @@ read_common_block (struct die_info *die,
0911f37
 	      else
0911f37
 		dwarf2_complex_location_expr_complaint ();
0911f37
 
0911f37
-	      SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
0911f37
+	      if (!base_p)
0911f37
+		dwarf2_invalid_attrib_class_complaint
0911f37
+		  ("DW_AT_data_member_location", "common block member");
0911f37
+	      SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset + baseaddr;
0911f37
 	      add_symbol_to_list (sym, &global_symbols);
0911f37
 	    }
0911f37
 
0911f37
 	  if (SYMBOL_CLASS (sym) == LOC_STATIC)
0911f37
-	    SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym));
0911f37
+	    SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym) - baseaddr);
0911f37
 	  else
0911f37
 	    SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
0911f37
 	  FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
03de720
@@ -5999,7 +6008,7 @@ read_common_block (struct die_info *die,
0911f37
 
0911f37
       sym = new_symbol (die, type, cu);
0911f37
       /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static.  */
0911f37
-      SYMBOL_VALUE_ADDRESS (sym) = base;
0911f37
+      SYMBOL_VALUE_ADDRESS (sym) = base + baseaddr;
0911f37
 
0911f37
       set_die_type (die, type, cu);
0911f37
     }
03de720
Index: gdb-7.0.90.20100306/gdb/gdbtypes.h
8c4c91e
===================================================================
03de720
--- gdb-7.0.90.20100306.orig/gdb/gdbtypes.h	2010-03-06 23:26:34.000000000 +0100
03de720
+++ gdb-7.0.90.20100306/gdb/gdbtypes.h	2010-03-06 23:28:43.000000000 +0100
03de720
@@ -412,6 +412,7 @@ enum type_instance_flag_value
8c4c91e
 enum field_loc_kind
8c4c91e
   {
8c4c91e
     FIELD_LOC_KIND_BITPOS,	/* bitpos */
8c4c91e
+    /* This address is unrelocated by the objfile's ANOFFSET.  */
8c4c91e
     FIELD_LOC_KIND_PHYSADDR,	/* physaddr */
8c4c91e
     FIELD_LOC_KIND_PHYSNAME	/* physname */
8c4c91e
   };
03de720
@@ -591,6 +592,7 @@ struct main_type
8c4c91e
 	   is the location (in the target) of the static field.
8c4c91e
 	   Otherwise, physname is the mangled label of the static field. */
8c4c91e
 
8c4c91e
+	/* This address is unrelocated by the objfile's ANOFFSET.  */
8c4c91e
 	CORE_ADDR physaddr;
8c4c91e
 	char *physname;
8c4c91e
       }
03de720
@@ -1091,6 +1093,7 @@ extern void allocate_gnat_aux_type (stru
0911f37
 #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
0911f37
 #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
0911f37
 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
0911f37
+/* This address is unrelocated by the objfile's ANOFFSET.  */
0911f37
 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
0911f37
 #define SET_FIELD_BITPOS(thisfld, bitpos)			\
8c4c91e
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS,		\
03de720
@@ -1098,6 +1101,7 @@ extern void allocate_gnat_aux_type (stru
0911f37
 #define SET_FIELD_PHYSNAME(thisfld, name)			\
0911f37
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME,		\
0911f37
    FIELD_STATIC_PHYSNAME (thisfld) = (name))
0911f37
+/* This address is unrelocated by the objfile's ANOFFSET.  */
0911f37
 #define SET_FIELD_PHYSADDR(thisfld, addr)			\
0911f37
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR,		\
0911f37
    FIELD_STATIC_PHYSADDR (thisfld) = (addr))
03de720
@@ -1110,6 +1114,7 @@ extern void allocate_gnat_aux_type (stru
0911f37
 #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
0911f37
 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
0911f37
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
0911f37
+/* This address is unrelocated by the objfile's ANOFFSET.  */
0911f37
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
0911f37
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
8c4c91e
 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
03de720
Index: gdb-7.0.90.20100306/gdb/jv-lang.c
8c4c91e
===================================================================
03de720
--- gdb-7.0.90.20100306.orig/gdb/jv-lang.c	2010-03-06 23:19:13.000000000 +0100
03de720
+++ gdb-7.0.90.20100306/gdb/jv-lang.c	2010-03-06 23:28:43.000000000 +0100
8c4c91e
@@ -416,7 +416,8 @@ java_link_class_type (struct gdbarch *gd
0911f37
 
0911f37
   fields = NULL;
0911f37
   nfields--;			/* First set up dummy "class" field. */
0911f37
-  SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas));
0911f37
+  SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas)
0911f37
+    - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
0911f37
   TYPE_FIELD_NAME (type, nfields) = "class";
0911f37
   TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
0911f37
   SET_TYPE_FIELD_PRIVATE (type, nfields);
8c4c91e
@@ -462,7 +463,8 @@ java_link_class_type (struct gdbarch *gd
0911f37
 	  SET_TYPE_FIELD_PROTECTED (type, i);
0911f37
 	}
0911f37
       if (accflags & 0x0008)	/* ACC_STATIC */
0911f37
-	SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset);
0911f37
+	SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset
0911f37
+	  - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
0911f37
       else
0911f37
 	TYPE_FIELD_BITPOS (type, i) = 8 * boffset;
0911f37
       if (accflags & 0x8000)	/* FIELD_UNRESOLVED_FLAG */
03de720
Index: gdb-7.0.90.20100306/gdb/value.c
8c4c91e
===================================================================
03de720
--- gdb-7.0.90.20100306.orig/gdb/value.c	2010-03-06 23:19:13.000000000 +0100
03de720
+++ gdb-7.0.90.20100306/gdb/value.c	2010-03-06 23:28:43.000000000 +0100
8c4c91e
@@ -1897,7 +1897,8 @@ value_static_field (struct type *type, i
0911f37
   if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
0911f37
     {
0911f37
       retval = value_at (TYPE_FIELD_TYPE (type, fieldno),
0911f37
-			 TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
0911f37
+			 TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)
0911f37
+			   + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
0911f37
     }
0911f37
   else
0911f37
     {
8c4c91e
@@ -1927,7 +1928,8 @@ value_static_field (struct type *type, i
0911f37
  	}
0911f37
       if (retval && VALUE_LVAL (retval) == lval_memory)
0911f37
 	SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
0911f37
-			    value_address (retval));
0911f37
+			    value_address (retval)
0911f37
+			      - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
0911f37
     }
0911f37
   return retval;
0911f37
 }