c8a4544
Index: gdb-7.2.90.20110525/gdb/dwarf2read.c
8c4c91e
===================================================================
c8a4544
--- gdb-7.2.90.20110525.orig/gdb/dwarf2read.c	2011-05-25 17:10:46.000000000 +0200
c8a4544
+++ gdb-7.2.90.20110525/gdb/dwarf2read.c	2011-05-25 17:12:35.000000000 +0200
c8a4544
@@ -7675,7 +7675,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)
c8a4544
@@ -7684,6 +7689,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
         {
c8a4544
@@ -7736,12 +7742,15 @@ read_common_block (struct die_info *die,
c8a4544
 	  if (sym != NULL
c8a4544
 	      && handle_data_member_location (child_die, cu, &offset))
c8a4544
 	    {
c8a4544
-	      SYMBOL_VALUE_ADDRESS (sym) = base + offset;
0911f37
+	      if (!base_p)
0911f37
+		dwarf2_invalid_attrib_class_complaint
0911f37
+		  ("DW_AT_data_member_location", "common block member");
c8a4544
+	      SYMBOL_VALUE_ADDRESS (sym) = base + 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);
c8a4544
@@ -7755,7 +7764,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
     }
c8a4544
Index: gdb-7.2.90.20110525/gdb/gdbtypes.h
8c4c91e
===================================================================
c8a4544
--- gdb-7.2.90.20110525.orig/gdb/gdbtypes.h	2011-05-25 17:05:21.000000000 +0200
c8a4544
+++ gdb-7.2.90.20110525/gdb/gdbtypes.h	2011-05-25 17:11:10.000000000 +0200
c8a4544
@@ -396,6 +396,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
   };
c8a4544
@@ -580,6 +581,7 @@ struct main_type
8c4c91e
 	   is the location (in the target) of the static field.
b0e03f5
 	   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
       }
c8a4544
@@ -1106,6 +1108,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,		\
c8a4544
@@ -1113,6 +1116,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))
c8a4544
@@ -1125,6 +1129,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))
c8a4544
Index: gdb-7.2.90.20110525/gdb/jv-lang.c
8c4c91e
===================================================================
c8a4544
--- gdb-7.2.90.20110525.orig/gdb/jv-lang.c	2011-03-02 01:42:53.000000000 +0100
c8a4544
+++ gdb-7.2.90.20110525/gdb/jv-lang.c	2011-05-25 17:11:10.000000000 +0200
b0e03f5
@@ -414,7 +414,8 @@ java_link_class_type (struct gdbarch *gd
0911f37
 
0911f37
   fields = NULL;
b0e03f5
   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);
b0e03f5
@@ -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 */
c8a4544
Index: gdb-7.2.90.20110525/gdb/value.c
8c4c91e
===================================================================
c8a4544
--- gdb-7.2.90.20110525.orig/gdb/value.c	2011-05-25 17:05:21.000000000 +0200
c8a4544
+++ gdb-7.2.90.20110525/gdb/value.c	2011-05-25 17:11:10.000000000 +0200
c8a4544
@@ -2492,7 +2492,8 @@ value_static_field (struct type *type, i
0911f37
     {
dd46ae6
     case FIELD_LOC_KIND_PHYSADDR:
dd46ae6
       retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
dd46ae6
-			      TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
dd46ae6
+			      TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)
dd46ae6
+			      + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
dd46ae6
       break;
dd46ae6
     case FIELD_LOC_KIND_PHYSNAME:
0911f37
     {