public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC 0/7] make psymbols independent of progspace
@ 2014-02-20 21:32 Tom Tromey
  2014-02-20 21:32 ` [RFC 5/7] introduce accessors for psymtab high and low fields Tom Tromey
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches

This patch series changes partial symbols to be independent of the
program space.

This is done following the same general approach as was taken for
minimal symbols and for SystemTap probes.  It is based on top of the
minimal symbol series.

One thing to note is that this series does not actually move partial
symbols or partial symbol tables to the per-BFD object.  This is
harder than it may seem.

One problem is that psymtabs have a back-link to the symtab.  This
could be broken in various ways, for example moving the mapping to a
hash table on the objfile.  (Temporarily, since once symtabs are moved
to the per-BFD, we could revert to the current scheme.)

However, there are other lurking issues.  E.g., in the DWARF reader
there are further back-links in the .gdb_index code.  And, I think
some fields of the dwarf2_per_objfile object are initialized during
psymtab reading.


One idea for the next step of improvements here would be to move the
psymbol bcache to the per-BFD object.  This would allow sharing the
psymbols at least, if not the psymtabs.  This is not extremely hard,
except:

* Some code paths in dwarf2read.c allocate psymbol names on the
  objfile_obstack; and as this code is shared with the full symbol
  reader it isn't trivial to move this.  Specifically,
  read_partial_die calls dwarf2_canonicalize_name.  This could be
  solved either by noting the fact in the partial DIE and then later
  copying the name; or by introducing a new bcache to hold canonical
  names.

* add_psymbol_to_list checks to see whether the psymbol was added to
  the cache.  This would have to change to a post-pass to remove
  duplicates.

I think a more likely route forward instead is to convert symbols,
symbol tables, types, and whatever issues there are in dwarf2read; and
then move all these data structures to the per-BFD object at one time.

Built and regtested on x86-64 Fedora 18, both in the default mode and
with -gstabs+; and on AIX (gcc111).

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 5/7] introduce accessors for psymtab high and low fields
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
@ 2014-02-20 21:32 ` Tom Tromey
  2014-02-20 21:32 ` [RFC 4/7] make PSYMBOL_VALUE_ADDRESS take objfile argument Tom Tromey
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces accessors for the partial symbol table textlow and
texthigh fields.  This lets us later arrange to relocate these values
at their point of use.

I did this conversion by renaming the fields.  I didn't rename the
fields back afterward, thinking that on the off chance that someone
has a patch touching this area, then a merge would helpfully break
their compile.  However, I can rename back if anybody cares.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (read_dbx_symtab, end_psymtab, read_ofile_symtab):
	Update.
	* dwarf2read.c (dwarf2_create_include_psymtab): Don't initialize
	textlow and texthigh fields.
	(process_psymtab_comp_unit_reader): Update.
	* mdebugread.c (parse_lines, parse_partial_symbols)
	(psymtab_to_symtab_1): Update.
	* psympriv.h (struct partial_symtab) <textlow_, texthigh_>: Rename
	fields.  Update comment.
	(PSYMTAB_TEXTLOW, PSYMTAB_TEXTHIGH, SET_PSYMTAB_TEXTLOW)
	(SET_PSYMTAB_TEXTHIGH): New macros.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_sect_psymbol, relocate_psymtabs, dump_psymtab)
	(start_psymtab_common, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Update.
	* xcoffread.c (xcoff_end_psymtab): Don't initialize textlow and
	texthigh fields.
	(scan_xcoff_symtab): Update.
---
 gdb/ChangeLog    | 21 +++++++++++++++++++++
 gdb/dbxread.c    | 51 ++++++++++++++++++++++++++-------------------------
 gdb/dwarf2read.c | 10 ++++------
 gdb/mdebugread.c | 42 ++++++++++++++++++++++--------------------
 gdb/psympriv.h   | 13 ++++++++++---
 gdb/psymtab.c    | 48 ++++++++++++++++++++++++++----------------------
 gdb/xcoffread.c  | 11 +++++------
 7 files changed, 114 insertions(+), 82 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 216c86c..66c4071 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1363,12 +1363,12 @@ read_dbx_symtab (struct objfile *objfile)
 	      if (past_first_source_file && pst
 		  /* The gould NP1 uses low values for .o and -l symbols
 		     which are not the address.  */
-		  && nlist.n_value >= pst->textlow)
+		  && nlist.n_value >= PSYMTAB_TEXTLOW (pst))
 		{
 		  end_psymtab (objfile, pst, psymtab_include_list,
 			       includes_used, symnum * symbol_size,
-			       nlist.n_value > pst->texthigh
-			       ? nlist.n_value : pst->texthigh,
+			       nlist.n_value > PSYMTAB_TEXTHIGH (pst)
+			       ? nlist.n_value : PSYMTAB_TEXTHIGH (pst),
 			       dependency_list, dependencies_used,
 			       textlow_not_set);
 		  pst = (struct partial_symtab *) 0;
@@ -1484,7 +1484,8 @@ read_dbx_symtab (struct objfile *objfile)
 		  {
 		    end_psymtab (objfile, pst, psymtab_include_list,
 				 includes_used, symnum * symbol_size,
-				 valu > pst->texthigh ? valu : pst->texthigh,
+				 (valu > PSYMTAB_TEXTHIGH (pst)
+				  ? valu : PSYMTAB_TEXTHIGH (pst)),
 				 dependency_list, dependencies_used,
 				 prev_textlow_not_set);
 		    pst = (struct partial_symtab *) 0;
@@ -1659,8 +1660,8 @@ read_dbx_symtab (struct objfile *objfile)
 		 function relative stabs, or the address of the function's
 		 end for old style stabs.  */
 	      valu = nlist.n_value + last_function_start;
-	      if (pst->texthigh == 0 || valu > pst->texthigh)
-		pst->texthigh = valu;
+	      if (PSYMTAB_TEXTHIGH (pst) == 0 || valu > PSYMTAB_TEXTHIGH (pst))
+		SET_PSYMTAB_TEXTHIGH (pst, valu);
 	      break;
 	    }
 
@@ -1883,7 +1884,7 @@ read_dbx_symtab (struct objfile *objfile)
 	      if (pst && textlow_not_set
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
-		  pst->textlow = nlist.n_value;
+		  SET_PSYMTAB_TEXTLOW (pst, nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      /* End kludge.  */
@@ -1898,12 +1899,12 @@ read_dbx_symtab (struct objfile *objfile)
 		 the partial symbol table.  */
 	      if (pst
 		  && (textlow_not_set
-		      || (nlist.n_value < pst->textlow
+		      || (nlist.n_value < PSYMTAB_TEXTLOW (pst)
 			  && (nlist.n_value
 			      != ANOFFSET (objfile->section_offsets,
 					   SECT_OFF_TEXT (objfile))))))
 		{
-		  pst->textlow = nlist.n_value;
+		  SET_PSYMTAB_TEXTLOW (pst, nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      add_psymbol_to_list (sym_name, sym_len, 1,
@@ -1953,7 +1954,7 @@ read_dbx_symtab (struct objfile *objfile)
 	      if (pst && textlow_not_set
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
-		  pst->textlow = nlist.n_value;
+		  SET_PSYMTAB_TEXTLOW (pst, nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      /* End kludge.  */
@@ -1968,12 +1969,12 @@ read_dbx_symtab (struct objfile *objfile)
 		 the partial symbol table.  */
 	      if (pst
 		  && (textlow_not_set
-		      || (nlist.n_value < pst->textlow
+		      || (nlist.n_value < PSYMTAB_TEXTLOW (pst)
 			  && (nlist.n_value
 			      != ANOFFSET (objfile->section_offsets,
 					   SECT_OFF_TEXT (objfile))))))
 		{
-		  pst->textlow = nlist.n_value;
+		  SET_PSYMTAB_TEXTLOW (pst, nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      add_psymbol_to_list (sym_name, sym_len, 1,
@@ -2158,7 +2159,8 @@ read_dbx_symtab (struct objfile *objfile)
 
       end_psymtab (objfile, pst, psymtab_include_list, includes_used,
 		   symnum * symbol_size,
-		   text_end > pst->texthigh ? text_end : pst->texthigh,
+		   (text_end > PSYMTAB_TEXTHIGH (pst)
+		    ? text_end : PSYMTAB_TEXTHIGH (pst)),
 		   dependency_list, dependencies_used, textlow_not_set);
     }
 
@@ -2220,7 +2222,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 
   if (capping_symbol_offset != -1)
     LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
-  pst->texthigh = capping_text;
+  SET_PSYMTAB_TEXTHIGH (pst, capping_text);
 
   /* Under Solaris, the N_SO symbols always have a value of 0,
      instead of the usual address of the .o file.  Therefore,
@@ -2237,7 +2239,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
      a reliable texthigh by taking the address plus size of the
      last function in the file.  */
 
-  if (pst->texthigh == 0 && last_function_name
+  if (PSYMTAB_TEXTHIGH (pst) == 0 && last_function_name
       && gdbarch_sofun_address_maybe_missing (gdbarch))
     {
       char *p;
@@ -2264,8 +2266,8 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 	}
 
       if (minsym.minsym)
-	pst->texthigh = (BMSYMBOL_VALUE_ADDRESS (minsym)
-			 + MSYMBOL_SIZE (minsym.minsym));
+	SET_PSYMTAB_TEXTHIGH (pst, (BMSYMBOL_VALUE_ADDRESS (minsym)
+				    + MSYMBOL_SIZE (minsym.minsym)));
 
       last_function_name = NULL;
     }
@@ -2274,7 +2276,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
     ;
   /* This test will be true if the last .o file is only data.  */
   else if (textlow_not_set)
-    pst->textlow = pst->texthigh;
+    SET_PSYMTAB_TEXTLOW (pst, PSYMTAB_TEXTHIGH (pst));
   else
     {
       struct partial_symtab *p1;
@@ -2287,8 +2289,9 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 
       ALL_OBJFILE_PSYMTABS (objfile, p1)
       {
-	if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst)
-	  p1->texthigh = pst->textlow;
+	if (PSYMTAB_TEXTHIGH (p1) == 0 && PSYMTAB_TEXTLOW (p1) != 0
+	    && p1 != pst)
+	  SET_PSYMTAB_TEXTHIGH (p1, PSYMTAB_TEXTLOW (pst));
       }
     }
 
@@ -2323,9 +2326,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->read_symtab_private =
 	obstack_alloc (&objfile->objfile_obstack, sizeof (struct symloc));
       LDSYMOFF (subpst) =
-	LDSYMLEN (subpst) =
-	subpst->textlow =
-	subpst->texthigh = 0;
+	LDSYMLEN (subpst) = 0;
 
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
@@ -2498,8 +2499,8 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
 
   sym_offset = LDSYMOFF (pst);
   sym_size = LDSYMLEN (pst);
-  text_offset = pst->textlow;
-  text_size = pst->texthigh - pst->textlow;
+  text_offset = PSYMTAB_TEXTLOW (pst);
+  text_size = PSYMTAB_TEXTHIGH (pst) - PSYMTAB_TEXTLOW (pst);
   section_offsets = pst->section_offsets;
 
   dbxread_objfile = objfile;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 019f17b..df95d04 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4397,8 +4397,6 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
     }
 
   subpst->section_offsets = pst->section_offsets;
-  subpst->textlow = 0;
-  subpst->texthigh = 0;
 
   subpst->dependencies = (struct partial_symtab **)
     obstack_alloc (&objfile->objfile_obstack,
@@ -6041,8 +6039,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 	  best_highpc = highpc;
 	}
     }
-  pst->textlow = best_lowpc + baseaddr;
-  pst->texthigh = best_highpc + baseaddr;
+  SET_PSYMTAB_TEXTLOW (pst, best_lowpc + baseaddr);
+  SET_PSYMTAB_TEXTHIGH (pst, best_highpc + baseaddr);
 
   pst->n_global_syms = objfile->global_psymbols.next -
     (objfile->global_psymbols.list + pst->globals_offset);
@@ -6083,8 +6081,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 			  ", %d global, %d static syms\n",
 			  per_cu->is_debug_types ? "type" : "comp",
 			  per_cu->offset.sect_off,
-			  paddress (gdbarch, pst->textlow),
-			  paddress (gdbarch, pst->texthigh),
+			  paddress (gdbarch, PSYMTAB_TEXTLOW (pst)),
+			  paddress (gdbarch, PSYMTAB_TEXTHIGH (pst)),
 			  pst->n_global_syms, pst->n_static_syms);
     }
 }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ce180c4..b9a68c0 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2208,7 +2208,7 @@ parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines,
 	halt = base + fh->cbLine;
       base += pr->cbLineOffset;
 
-      adr = pst->textlow + pr->adr - lowest_pdr_addr;
+      adr = PSYMTAB_TEXTLOW (pst) + pr->adr - lowest_pdr_addr;
 
       l = adr >> 2;		/* in words */
       for (lineno = pr->lnLow; base < halt;)
@@ -2695,7 +2695,7 @@ parse_partial_symbols (struct objfile *objfile)
 	psymtab_language = prev_language;
       PST_PRIVATE (pst)->pst_language = psymtab_language;
 
-      pst->texthigh = pst->textlow;
+      SET_PSYMTAB_TEXTHIGH (pst, PSYMTAB_TEXTLOW (pst));
 
       /* For stabs-in-ecoff files, the second symbol must be @stab.
          This symbol is emitted by mips-tfile to signal that the
@@ -2760,10 +2760,11 @@ parse_partial_symbols (struct objfile *objfile)
 
 			  /* Kludge for Irix 5.2 zero fh->adr.  */
 			  if (!relocatable
-			  && (pst->textlow == 0 || procaddr < pst->textlow))
-			    pst->textlow = procaddr;
-			  if (high > pst->texthigh)
-			    pst->texthigh = high;
+			      && (PSYMTAB_TEXTLOW (pst) == 0
+				  || procaddr < PSYMTAB_TEXTLOW (pst)))
+			    SET_PSYMTAB_TEXTLOW (pst, procaddr);
+			  if (high > PSYMTAB_TEXTHIGH (pst))
+			    SET_PSYMTAB_TEXTHIGH (pst, high);
 			}
 		    }
 		  else if (sh.st == stStatic)
@@ -3365,8 +3366,8 @@ parse_partial_symbols (struct objfile *objfile)
 		    continue;
 
 		  case N_RBRAC:
-		    if (sh.value > save_pst->texthigh)
-		      save_pst->texthigh = sh.value;
+		    if (sh.value > PSYMTAB_TEXTHIGH (save_pst))
+		      SET_PSYMTAB_TEXTHIGH (save_pst, sh.value);
 		    continue;
 		  case N_EINCL:
 		  case N_DSLINE:
@@ -3557,12 +3558,13 @@ parse_partial_symbols (struct objfile *objfile)
 
 		  /* Kludge for Irix 5.2 zero fh->adr.  */
 		  if (!relocatable
-		      && (pst->textlow == 0 || procaddr < pst->textlow))
-		    pst->textlow = procaddr;
+		      && (PSYMTAB_TEXTLOW (pst) == 0
+			  || procaddr < PSYMTAB_TEXTLOW (pst)))
+		    SET_PSYMTAB_TEXTLOW (pst, procaddr);
 
 		  high = procaddr + sh.value;
-		  if (high > pst->texthigh)
-		    pst->texthigh = high;
+		  if (high > PSYMTAB_TEXTHIGH (pst))
+		    SET_PSYMTAB_TEXTHIGH (pst, high);
 		  continue;
 
 		case stStatic:	/* Variable */
@@ -3739,7 +3741,7 @@ parse_partial_symbols (struct objfile *objfile)
          empty and put on the free list.  */
       fdr_to_pst[f_idx].pst = end_psymtab (objfile, save_pst,
 					psymtab_include_list, includes_used,
-					   -1, save_pst->texthigh,
+					   -1, PSYMTAB_TEXTHIGH (save_pst),
 		       dependency_list, dependencies_used, textlow_not_set);
       includes_used = 0;
       dependencies_used = 0;
@@ -3757,15 +3759,15 @@ parse_partial_symbols (struct objfile *objfile)
          other cases.  */
       save_pst = fdr_to_pst[f_idx].pst;
       if (save_pst != NULL
-	  && save_pst->textlow != 0
+	  && PSYMTAB_TEXTLOW (save_pst) != 0
 	  && !(objfile->flags & OBJF_REORDERED))
 	{
 	  ALL_OBJFILE_PSYMTABS (objfile, pst)
 	  {
 	    if (save_pst != pst
-		&& save_pst->textlow >= pst->textlow
-		&& save_pst->textlow < pst->texthigh
-		&& save_pst->texthigh > pst->texthigh)
+		&& PSYMTAB_TEXTLOW (save_pst) >= PSYMTAB_TEXTLOW (pst)
+		&& PSYMTAB_TEXTLOW (save_pst) < PSYMTAB_TEXTHIGH (pst)
+		&& PSYMTAB_TEXTHIGH (save_pst) > PSYMTAB_TEXTHIGH (pst))
 	      {
 		objfile->flags |= OBJF_REORDERED;
 		break;
@@ -3971,7 +3973,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
   /* Do nothing if this is a dummy psymtab.  */
 
   if (pst->n_global_syms == 0 && pst->n_static_syms == 0
-      && pst->textlow == 0 && pst->texthigh == 0)
+      && PSYMTAB_TEXTLOW (pst) == 0 && PSYMTAB_TEXTHIGH (pst) == 0)
     return;
 
   /* Now read the symbols for this symtab.  */
@@ -4123,7 +4125,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 
       if (! last_symtab_ended)
 	{
-	  st = end_symtab (pst->texthigh, objfile,
+	  st = end_symtab (PSYMTAB_TEXTHIGH (pst), objfile,
 			   SECT_OFF_TEXT (objfile));
 	  end_stabs ();
 	}
@@ -4205,7 +4207,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
       top_stack->cur_st = st;
       top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (st),
 						STATIC_BLOCK);
-      BLOCK_START (top_stack->cur_block) = pst->textlow;
+      BLOCK_START (top_stack->cur_block) = PSYMTAB_TEXTLOW (pst);
       BLOCK_END (top_stack->cur_block) = 0;
       top_stack->blocktype = stFile;
       top_stack->cur_type = 0;
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 9648ded..1824bdd 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -136,10 +136,11 @@ struct partial_symtab
 
   /* Range of text addresses covered by this file; texthigh is the
      beginning of the next section.  Do not use if PSYMTABS_ADDRMAP_SUPPORTED
-     is set.  */
+     is set.  Do not refer directly to these fields.  Instead, use the
+     accessor macros.  */
 
-  CORE_ADDR textlow;
-  CORE_ADDR texthigh;
+  CORE_ADDR textlow_;
+  CORE_ADDR texthigh_;
 
   /* If NULL, this is an ordinary partial symbol table.
 
@@ -247,6 +248,12 @@ struct partial_symtab
   (ANOFFSET ((OBJF)->section_offsets, (INDEX))			\
    + ((((OFFS) == NULL)) ? 0 : ANOFFSET ((OFFS), (INDEX))))
 
+#define PSYMTAB_TEXTLOW(PST) ((PST)->textlow_ + 0)
+#define PSYMTAB_TEXTHIGH(PST) ((PST)->texthigh_ + 0)
+
+#define SET_PSYMTAB_TEXTLOW(PST, V) (((PST)->textlow_) = (V))
+#define SET_PSYMTAB_TEXTHIGH(PST, V) (((PST)->texthigh_) = (V))
+
 extern void sort_pst_symbols (struct objfile *, struct partial_symtab *);
 
 /* Add any kind of symbol to a psymbol_allocation_list.  */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 35f376e..4eaf05f 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -230,7 +230,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 {
   struct partial_symtab *tpst;
   struct partial_symtab *best_pst = pst;
-  CORE_ADDR best_addr = pst->textlow;
+  CORE_ADDR best_addr = PSYMTAB_TEXTLOW (pst);
 
   gdb_assert (!pst->psymtabs_addrmap_supported);
 
@@ -254,7 +254,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
      that is closest and still less than the given PC.  */
   for (tpst = pst; tpst != NULL; tpst = tpst->next)
     {
-      if (pc >= tpst->textlow && pc < tpst->texthigh)
+      if (pc >= PSYMTAB_TEXTLOW (tpst) && pc < PSYMTAB_TEXTHIGH (tpst))
 	{
 	  struct partial_symbol *p;
 	  CORE_ADDR this_addr;
@@ -276,7 +276,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 	  if (p != NULL)
 	    this_addr = PSYMBOL_VALUE_ADDRESS (objfile, p);
 	  else
-	    this_addr = tpst->textlow;
+	    this_addr = PSYMTAB_TEXTLOW (tpst);
 
 	  /* Check whether it is closer than our current
 	     BEST_ADDR.  Since this symbol address is
@@ -358,7 +358,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
     if (!pst->psymtabs_addrmap_supported
-	&& pc >= pst->textlow && pc < pst->texthigh)
+	&& pc >= PSYMTAB_TEXTLOW (pst) && pc < PSYMTAB_TEXTHIGH (pst))
       {
 	struct partial_symtab *best_pst;
 
@@ -408,7 +408,8 @@ find_pc_sect_psymbol (struct objfile *objfile,
   gdb_assert (psymtab != NULL);
 
   /* Cope with programs that start at address 0.  */
-  best_pc = (psymtab->textlow != 0) ? psymtab->textlow - 1 : 0;
+  best_pc = ((PSYMTAB_TEXTLOW (psymtab) != 0)
+	     ? PSYMTAB_TEXTLOW (psymtab) - 1 : 0);
 
   /* Search the global symbols as well as the static symbols, so that
      find_pc_partial_function doesn't use a minimal symbol and thus
@@ -423,7 +424,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
 	  && pc >= PSYMBOL_VALUE_ADDRESS (objfile, p)
 	  && (PSYMBOL_VALUE_ADDRESS (objfile, p) > best_pc
-	      || (psymtab->textlow == 0
+	      || (PSYMTAB_TEXTLOW (psymtab) == 0
 		  && best_pc == 0
 		  && PSYMBOL_VALUE_ADDRESS (objfile, p) == 0)))
 	{
@@ -449,7 +450,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
 	  && pc >= PSYMBOL_VALUE_ADDRESS (objfile, p)
 	  && (PSYMBOL_VALUE_ADDRESS (objfile, p) > best_pc
-	      || (psymtab->textlow == 0
+	      || (PSYMTAB_TEXTLOW (psymtab) == 0
 		  && best_pc == 0
 		  && PSYMBOL_VALUE_ADDRESS (objfile, p) == 0)))
 	{
@@ -795,8 +796,10 @@ relocate_psymtabs (struct objfile *objfile,
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
     {
-      p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-      p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+      SET_PSYMTAB_TEXTLOW (p, (PSYMTAB_TEXTLOW (p)
+			       + ANOFFSET (delta, SECT_OFF_TEXT (objfile))));
+      SET_PSYMTAB_TEXTHIGH (p, (PSYMTAB_TEXTHIGH (p)
+				+ ANOFFSET (delta, SECT_OFF_TEXT (objfile))));
     }
 
   for (psym = objfile->global_psymbols.list;
@@ -1010,9 +1013,9 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
   fprintf_filtered (outfile, "\n");
 
   fprintf_filtered (outfile, "  Symbols cover text addresses ");
-  fputs_filtered (paddress (gdbarch, psymtab->textlow), outfile);
+  fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (psymtab)), outfile);
   fprintf_filtered (outfile, "-");
-  fputs_filtered (paddress (gdbarch, psymtab->texthigh), outfile);
+  fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (psymtab)), outfile);
   fprintf_filtered (outfile, "\n");
   fprintf_filtered (outfile, "  Address map supported - %s.\n",
 		    psymtab->psymtabs_addrmap_supported ? "yes" : "no");
@@ -1484,8 +1487,8 @@ start_psymtab_common (struct objfile *objfile,
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (filename, objfile);
-  psymtab->textlow = textlow;
-  psymtab->texthigh = psymtab->textlow;		/* default */
+  SET_PSYMTAB_TEXTLOW (psymtab, textlow);
+  SET_PSYMTAB_TEXTHIGH (psymtab, textlow);		/* default */
   psymtab->globals_offset = global_syms - objfile->global_psymbols.list;
   psymtab->statics_offset = static_syms - objfile->static_psymbols.list;
   return (psymtab);
@@ -1943,10 +1946,10 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
 			       psymtab->fullname
 			       ? psymtab->fullname : "(null)");
 	      printf_filtered ("    text addresses ");
-	      fputs_filtered (paddress (gdbarch, psymtab->textlow),
+	      fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (psymtab)),
 			      gdb_stdout);
 	      printf_filtered (" -- ");
-	      fputs_filtered (paddress (gdbarch, psymtab->texthigh),
+	      fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (psymtab)),
 			      gdb_stdout);
 	      printf_filtered ("\n");
 	      printf_filtered ("    psymtabs_addrmap_supported %s\n",
@@ -2025,14 +2028,14 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
     s = ps->symtab;
 
     /* First do some checks that don't require the associated symtab.  */
-    if (ps->texthigh < ps->textlow)
+    if (PSYMTAB_TEXTHIGH (ps) < PSYMTAB_TEXTLOW (ps))
       {
 	printf_filtered ("Psymtab ");
 	puts_filtered (ps->filename);
 	printf_filtered (" covers bad range ");
-	fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (ps)), gdb_stdout);
 	printf_filtered (" - ");
-	fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (ps)), gdb_stdout);
 	printf_filtered ("\n");
 	continue;
       }
@@ -2075,15 +2078,16 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
 	  }
 	psym++;
       }
-    if (ps->texthigh != 0
-	&& (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)))
+    if (PSYMTAB_TEXTHIGH (ps) != 0
+	&& (PSYMTAB_TEXTLOW (ps) < BLOCK_START (b)
+	    || PSYMTAB_TEXTHIGH (ps) > BLOCK_END (b)))
       {
 	printf_filtered ("Psymtab ");
 	puts_filtered (ps->filename);
 	printf_filtered (" covers ");
-	fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (ps)), gdb_stdout);
 	printf_filtered (" - ");
-	fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (ps)), gdb_stdout);
 	printf_filtered (" but symtab covers only ");
 	fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout);
 	printf_filtered (" - ");
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 261fc7b..13b4284 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2096,8 +2096,6 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 						   sizeof (struct symloc));
       ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0;
       ((struct symloc *) subpst->read_symtab_private)->numsyms = 0;
-      subpst->textlow = 0;
-      subpst->texthigh = 0;
 
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
@@ -2349,10 +2347,11 @@ scan_xcoff_symtab (struct objfile *objfile)
 			CORE_ADDR highval =
 			  symbol.n_value + csect_aux.x_csect.x_scnlen.l;
 
-			if (highval > pst->texthigh)
-			  pst->texthigh = highval;
-			if (pst->textlow == 0 || symbol.n_value < pst->textlow)
-			  pst->textlow = symbol.n_value;
+			if (highval > PSYMTAB_TEXTHIGH (pst))
+			  SET_PSYMTAB_TEXTHIGH (pst, highval);
+			if (PSYMTAB_TEXTLOW (pst) == 0
+			    || symbol.n_value < PSYMTAB_TEXTLOW (pst))
+			  SET_PSYMTAB_TEXTLOW (pst, symbol.n_value);
 		      }
 		    misc_func_recorded = 0;
 		    break;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 4/7] make PSYMBOL_VALUE_ADDRESS take objfile argument
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
  2014-02-20 21:32 ` [RFC 5/7] introduce accessors for psymtab high and low fields Tom Tromey
@ 2014-02-20 21:32 ` Tom Tromey
  2014-02-20 21:32 ` [RFC 3/7] change representation of psymbol to flush out accessors Tom Tromey
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes PSYMBOL_VALUE_ADDRESS to take an objfile argument.  This
is necessary so that we can later relocate a partial symbol at its
point of use.  It also adds a "raw" form of the accessor, to compute
the unrelocated value; and a special macro to be used for setting the
field.

Note that the macro doesn't actually perform any relocation -- it uses
the argument, to ensure that any possible syntax errors are caught,
but it multiplies it by 0 so that it has no effect.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* psympriv.h (SET_PSYMBOL_VALUE_ADDRESS)
	(PSYMBOL_VALUE_RAW_ADDRESS): New macros.
	(PSYMBOL_VALUE_ADDRESS): Add 'objfile' parameter.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol)
	(fixup_psymbol_section, relocate_psymtabs): Update.
	(print_partial_symbols): Add 'objfile' parameter.  Update.
	(dump_psymtab, add_psymbol_to_bcache): Update.
---
 gdb/ChangeLog  | 10 ++++++++++
 gdb/psympriv.h |  7 ++++++-
 gdb/psymtab.c  | 47 +++++++++++++++++++++++++++--------------------
 3 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index ccf3d59..9648ded 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -54,7 +54,12 @@ struct partial_symbol
 };
 
 #define PSYMBOL_VALUE(symbol)		(symbol)->pginfo.value.ivalue
-#define PSYMBOL_VALUE_ADDRESS(symbol)	(symbol)->pginfo.value.address
+#define SET_PSYMBOL_VALUE_ADDRESS(symbol, addr) \
+  (((symbol)->pginfo.value.address) = (addr))
+#define PSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->pginfo.value.address + 0)
+#define PSYMBOL_VALUE_ADDRESS(objfile, symbol)	\
+  ((symbol)->pginfo.value.address \
+   + (0 * (ANOFFSET ((objfile)->section_offsets, ((symbol)->pginfo.section)))))
 #define PSYMBOL_LANGUAGE(symbol)	(symbol)->pginfo.language
 #define PSYMBOL_SECTION(symbol)		(symbol)->pginfo.section
 #define PSYMBOL_OBJ_SECTION(objfile, symbol)			\
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index fcffee6..35f376e 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -265,7 +265,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 	     object's symbol table.  */
 	  p = find_pc_sect_psymbol (objfile, tpst, pc, section);
 	  if (p != NULL
-	      && PSYMBOL_VALUE_ADDRESS (p)
+	      && PSYMBOL_VALUE_ADDRESS (objfile, p)
 	      == BMSYMBOL_VALUE_ADDRESS (msymbol))
 	    return tpst;
 
@@ -274,7 +274,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 	     symbol tables with line information but no debug
 	     symbols (e.g. those produced by an assembler).  */
 	  if (p != NULL)
-	    this_addr = PSYMBOL_VALUE_ADDRESS (p);
+	    this_addr = PSYMBOL_VALUE_ADDRESS (objfile, p);
 	  else
 	    this_addr = tpst->textlow;
 
@@ -330,7 +330,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
 		 object's symbol table.  */
 	      p = find_pc_sect_psymbol (objfile, pst, pc, section);
 	      if (!p
-		  || PSYMBOL_VALUE_ADDRESS (p)
+		  || PSYMBOL_VALUE_ADDRESS (objfile, p)
 		  != BMSYMBOL_VALUE_ADDRESS (msymbol))
 		goto next;
 	    }
@@ -421,10 +421,11 @@ find_pc_sect_psymbol (struct objfile *objfile,
       p = *pp;
       if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
-	  && pc >= PSYMBOL_VALUE_ADDRESS (p)
-	  && (PSYMBOL_VALUE_ADDRESS (p) > best_pc
+	  && pc >= PSYMBOL_VALUE_ADDRESS (objfile, p)
+	  && (PSYMBOL_VALUE_ADDRESS (objfile, p) > best_pc
 	      || (psymtab->textlow == 0
-		  && best_pc == 0 && PSYMBOL_VALUE_ADDRESS (p) == 0)))
+		  && best_pc == 0
+		  && PSYMBOL_VALUE_ADDRESS (objfile, p) == 0)))
 	{
 	  if (section)		/* Match on a specific section.  */
 	    {
@@ -433,7 +434,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
 					  section))
 		continue;
 	    }
-	  best_pc = PSYMBOL_VALUE_ADDRESS (p);
+	  best_pc = PSYMBOL_VALUE_ADDRESS (objfile, p);
 	  best = p;
 	}
     }
@@ -446,10 +447,11 @@ find_pc_sect_psymbol (struct objfile *objfile,
       p = *pp;
       if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
-	  && pc >= PSYMBOL_VALUE_ADDRESS (p)
-	  && (PSYMBOL_VALUE_ADDRESS (p) > best_pc
+	  && pc >= PSYMBOL_VALUE_ADDRESS (objfile, p)
+	  && (PSYMBOL_VALUE_ADDRESS (objfile, p) > best_pc
 	      || (psymtab->textlow == 0
-		  && best_pc == 0 && PSYMBOL_VALUE_ADDRESS (p) == 0)))
+		  && best_pc == 0
+		  && PSYMBOL_VALUE_ADDRESS (objfile, p) == 0)))
 	{
 	  if (section)		/* Match on a specific section.  */
 	    {
@@ -458,7 +460,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
 					  section))
 		continue;
 	    }
-	  best_pc = PSYMBOL_VALUE_ADDRESS (p);
+	  best_pc = PSYMBOL_VALUE_ADDRESS (objfile, p);
 	  best = p;
 	}
     }
@@ -484,7 +486,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
     case LOC_STATIC:
     case LOC_LABEL:
     case LOC_BLOCK:
-      addr = PSYMBOL_VALUE_ADDRESS (psym);
+      addr = PSYMBOL_VALUE_ADDRESS (objfile, psym);
       break;
     default:
       /* Nothing else will be listed in the minsyms -- no use looking
@@ -803,8 +805,9 @@ relocate_psymtabs (struct objfile *objfile,
     {
       fixup_psymbol_section (*psym, objfile);
       if (PSYMBOL_SECTION (*psym) >= 0)
-	PSYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
-						   PSYMBOL_SECTION (*psym));
+	SET_PSYMBOL_VALUE_ADDRESS (*psym,
+				   PSYMBOL_VALUE_RAW_ADDRESS (*psym)
+				   + ANOFFSET (delta, PSYMBOL_SECTION (*psym)));
     }
   for (psym = objfile->static_psymbols.list;
        psym < objfile->static_psymbols.next;
@@ -812,8 +815,9 @@ relocate_psymtabs (struct objfile *objfile,
     {
       fixup_psymbol_section (*psym, objfile);
       if (PSYMBOL_SECTION (*psym) >= 0)
-	PSYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
-						   PSYMBOL_SECTION (*psym));
+	SET_PSYMBOL_VALUE_ADDRESS (*psym,
+				   PSYMBOL_VALUE_RAW_ADDRESS (*psym)
+				   + ANOFFSET (delta, PSYMBOL_SECTION (*psym)));
     }
 }
 
@@ -864,6 +868,7 @@ forget_cached_source_info_partial (struct objfile *objfile)
 
 static void
 print_partial_symbols (struct gdbarch *gdbarch,
+		       struct objfile *objfile,
 		       struct partial_symbol **p, int count, char *what,
 		       struct ui_file *outfile)
 {
@@ -947,7 +952,9 @@ print_partial_symbols (struct gdbarch *gdbarch,
 	  break;
 	}
       fputs_filtered (", ", outfile);
-      fputs_filtered (paddress (gdbarch, PSYMBOL_VALUE_ADDRESS (*p)), outfile);
+      fputs_filtered (paddress (gdbarch,
+				PSYMBOL_VALUE_RAW_ADDRESS (*p)),
+		      outfile);
       fprintf_filtered (outfile, "\n");
       p++;
     }
@@ -1026,14 +1033,14 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
     }
   if (psymtab->n_global_syms > 0)
     {
-      print_partial_symbols (gdbarch,
+      print_partial_symbols (gdbarch, objfile,
 			     objfile->global_psymbols.list
 			     + psymtab->globals_offset,
 			     psymtab->n_global_syms, "Global", outfile);
     }
   if (psymtab->n_static_syms > 0)
     {
-      print_partial_symbols (gdbarch,
+      print_partial_symbols (gdbarch, objfile,
 			     objfile->static_psymbols.list
 			     + psymtab->statics_offset,
 			     psymtab->n_static_syms, "Static", outfile);
@@ -1599,7 +1606,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
     }
   else
     {
-      PSYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
+      SET_PSYMBOL_VALUE_ADDRESS (&psymbol, coreaddr);
     }
   PSYMBOL_SECTION (&psymbol) = -1;
   PSYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 2/7] change how psymtab section offsets are handled
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
                   ` (2 preceding siblings ...)
  2014-02-20 21:32 ` [RFC 3/7] change representation of psymbol to flush out accessors Tom Tromey
@ 2014-02-20 21:32 ` Tom Tromey
  2014-02-20 21:32 ` [RFC 7/7] make psymbols and psymtabs independent of the program space Tom Tromey
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Currently, a partial symbol table includes a section_offsets field.
This either comes verbatim from the objfile, or, in one case, is
computed separately.

This approach will not work if partial symtabs are to be independent
of the program space.

So, this patch changes the semantics of this field so that the partial
symtab holds offsets to be applied in addition to the objfile's
offsets.  It also arranges for the "normal" case to be that the
psymtab's section_offsets field is NULL.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (start_psymtab): Update.
	(read_ofile_symtab): Remove comment.
	(cp_set_block_scope): Update comment.
	(process_one_symbol): Use PST_OFFSET.
	* dwarf2read.c (create_partial_symtab): Update.
	* elfread.c (elfstab_offset_sections): Compute new offset relative
	to the objfile's offset.
	* mdebugread.c (parse_symbol): Use PST_OFFSET.
	(parse_partial_symbols): Update.  Use PST_OFFSET.
	(new_psymtab): Don't initialize section_offsets field.
	* psympriv.h (struct partial_symtab) <section_offsets>: Update
	comment.
	(PST_OFFSET): New macro.
	(start_psymtab_common): Remove section_offsets argument.
	* psymtab.c (dump_psymtab): Use PST_OFFSET.
	(start_psymtab_common): Remove section_offsets argument.
	* xcoffread.c (xcoff_start_psymtab): Update.
---
 gdb/ChangeLog    | 20 ++++++++++++++++++++
 gdb/dbxread.c    | 37 +++++++++++++++++--------------------
 gdb/dwarf2read.c |  3 +--
 gdb/elfread.c    |  3 ++-
 gdb/mdebugread.c | 20 +++++++++++---------
 gdb/psympriv.h   | 16 ++++++++++++----
 gdb/psymtab.c    |  6 +++---
 gdb/xcoffread.c  |  2 +-
 8 files changed, 67 insertions(+), 40 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index ceb593a..216c86c 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2178,8 +2178,7 @@ start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow,
 	       struct partial_symbol **static_syms)
 {
   struct partial_symtab *result =
-    start_psymtab_common (objfile, objfile->section_offsets,
-			  filename, textlow, global_syms, static_syms);
+    start_psymtab_common (objfile, filename, textlow, global_syms, static_syms);
 
   result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
 					       sizeof (struct symloc));
@@ -2501,10 +2500,6 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
   sym_size = LDSYMLEN (pst);
   text_offset = pst->textlow;
   text_size = pst->texthigh - pst->textlow;
-  /* This cannot be simply objfile->section_offsets because of
-     elfstab_offset_sections() which initializes the psymtab section
-     offsets information in a special way, and that is different from
-     objfile->section_offsets.  */ 
   section_offsets = pst->section_offsets;
 
   dbxread_objfile = objfile;
@@ -2689,8 +2684,9 @@ cp_set_block_scope (const struct symbol *symbol,
    SECTION_OFFSETS is a set of amounts by which the sections of this
    object file were relocated when it was loaded into memory.  Note
    that these section_offsets are not the objfile->section_offsets but
-   the pst->section_offsets.  All symbols that refer to memory
-   locations need to be offset by these amounts.
+   the pst->section_offsets, used in addition to the objfile's
+   offsets.  All symbols that refer to memory locations need to be
+   offset by these amounts.
    OBJFILE is the object file from which we are reading symbols.  It
    is used in end_symtab.  */
 
@@ -2732,7 +2728,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
       /* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the
 	 function start address, so just use the text offset.  */
       function_start_offset =
-	ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+	PST_OFFSET (objfile, section_offsets, SECT_OFF_TEXT (objfile));
     }
 
   /* Something is wrong if we see real data before seeing a source
@@ -2799,7 +2795,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
       sline_found_in_function = 0;
 
       /* Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_TEXT (objfile));
       valu = gdbarch_addr_bits_remove (gdbarch, valu);
       last_function_start = valu;
 
@@ -2901,7 +2897,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
     case N_FN_SEQ:
       /* This kind of symbol indicates the start of an object file.
          Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_TEXT (objfile));
       break;
 
     case N_SO:
@@ -2909,7 +2905,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
          source file.  Finish the symbol table of the previous source
          file (if any) and start accumulating a new symbol table.
          Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_TEXT (objfile));
 
       n_opt_found = 0;
 
@@ -2946,7 +2942,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
          sub-source-file, one whose contents were copied or included
          in the compilation of the main source file (whose name was
          given in the N_SO symbol).  Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_TEXT (objfile));
       start_subfile (name, current_subfile->dirname);
       break;
 
@@ -3051,7 +3047,8 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 		   elfstab_offset_sections ever starts dealing with
 		   the text offset, and we still need to do this, we
 		   need to invent a SECT_OFF_ADDR_KLUDGE or something.  */
-		valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+		valu += PST_OFFSET (objfile, section_offsets,
+				     SECT_OFF_TEXT (objfile));
 		goto define_a_symbol;
 	      }
 	  }
@@ -3073,22 +3070,22 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 
     case_N_STSYM:		/* Static symbol in data segment.  */
     case N_DSLINE:		/* Source line number, data segment.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_DATA (objfile));
       goto define_a_symbol;
 
     case_N_LCSYM:		/* Static symbol in BSS segment.  */
     case N_BSLINE:		/* Source line number, BSS segment.  */
       /* N_BROWS: overlaps with N_BSLINE.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_BSS (objfile));
       goto define_a_symbol;
 
     case_N_ROSYM:		/* Static symbol in read-only data segment.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_RODATA (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_RODATA (objfile));
       goto define_a_symbol;
 
     case N_ENTRY:		/* Alternate entry point.  */
       /* Relocate for dynamic loading.  */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+      valu += PST_OFFSET (objfile, section_offsets, SECT_OFF_TEXT (objfile));
       goto define_a_symbol;
 
       /* The following symbol types we don't know how to process.
@@ -3141,8 +3138,8 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 	      /* Deal with the SunPRO 3.0 compiler which omits the
 	         address from N_FUN symbols.  */
 	      if (type == N_FUN
-		  && valu == ANOFFSET (section_offsets,
-				       SECT_OFF_TEXT (objfile))
+		  && valu == PST_OFFSET (objfile, section_offsets,
+					  SECT_OFF_TEXT (objfile))
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
 		  CORE_ADDR minsym_valu = 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 87c6ba2..72662a5 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5925,8 +5925,7 @@ create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
   struct objfile *objfile = per_cu->objfile;
   struct partial_symtab *pst;
 
-  pst = start_psymtab_common (objfile, objfile->section_offsets,
-			      name, 0,
+  pst = start_psymtab_common (objfile, name, 0,
 			      objfile->global_psymbols.next,
 			      objfile->static_psymbols.next);
 
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 88fb018..d25b09a 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1481,7 +1481,8 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
 	obstack_alloc (&objfile->objfile_obstack,
 		       SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
       for (i = 0; i < maybe->num_sections; i++)
-	(pst->section_offsets)->offsets[i] = maybe->sections[i];
+	(pst->section_offsets)->offsets[i]
+	  = maybe->sections[i] - ANOFFSET (objfile->section_offsets, i);
       return;
     }
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 94af07b..ce180c4 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -581,18 +581,21 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
          The value of a stBlock symbol is the displacement from the
          procedure address.  */
       if (sh->st != stEnd && sh->st != stBlock)
-	sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+	sh->value += PST_OFFSET (objfile, section_offsets,
+				   SECT_OFF_TEXT (objfile));
       break;
     case scData:
     case scSData:
     case scRData:
     case scPData:
     case scXData:
-      sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
+      sh->value += PST_OFFSET (objfile, section_offsets,
+			       SECT_OFF_DATA (objfile));
       break;
     case scBss:
     case scSBss:
-      sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
+      sh->value += PST_OFFSET (objfile, section_offsets,
+			       SECT_OFF_BSS (objfile));
       break;
     }
 
@@ -2647,7 +2650,7 @@ parse_partial_symbols (struct objfile *objfile)
 	}
       else
 	textlow = 0;
-      pst = start_psymtab_common (objfile, objfile->section_offsets,
+      pst = start_psymtab_common (objfile,
 				  fdr_name (fh),
 				  textlow,
 				  objfile->global_psymbols.next,
@@ -4052,8 +4055,8 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 		      && previous_stab_code != (unsigned char) N_SO
 		      && *name == '\000')
 		    {
-		      valu += ANOFFSET (pst->section_offsets,
-					SECT_OFF_TEXT (objfile));
+		      valu += PST_OFFSET (objfile, pst->section_offsets,
+					  SECT_OFF_TEXT (objfile));
 		      previous_stab_code = N_SO;
 		      st = end_symtab (valu, objfile,
 				       SECT_OFF_TEXT (objfile));
@@ -4103,8 +4106,8 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 	      else
 		{
 		  /* Handle encoded stab line number.  */
-		  valu += ANOFFSET (pst->section_offsets,
-				    SECT_OFF_TEXT (objfile));
+		  valu += PST_OFFSET (objfile, pst->section_offsets,
+				      SECT_OFF_TEXT (objfile));
 		  record_line (current_subfile, sh.index,
 			       gdbarch_addr_bits_remove (gdbarch, valu));
 		}
@@ -4753,7 +4756,6 @@ new_psymtab (char *name, struct objfile *objfile)
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (name, objfile);
-  psymtab->section_offsets = objfile->section_offsets;
 
   /* Keep a backpointer to the file's symbols.  */
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 006e134..57442c2 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -98,9 +98,11 @@ struct partial_symtab
 
   const char *dirname;
 
-  /* Set of relocation offsets to apply to each section.
-     This is typically objfile->section_offsets, but in some cases
-     it's different.  See, e.g., elfstab_offset_sections.  */
+  /* Set of relocation offsets to apply to each section.  Offsets here
+     are applied when expanding this psymtab to a full symtab.  This
+     is typically NULL, which means no additional offsets need to be
+     applied, but in some cases it's different.  See, e.g.,
+     elfstab_offset_sections.  */
 
   struct section_offsets *section_offsets;
 
@@ -210,6 +212,13 @@ struct partial_symtab
   void *read_symtab_private;
 };
 
+/* Compute a section offset given an objfile, a section_offsets field
+   from a partial symtab, and an index.  */
+
+#define PST_OFFSET(OBJF, OFFS, INDEX)				\
+  (ANOFFSET ((OBJF)->section_offsets, (INDEX))			\
+   + ((((OFFS) == NULL)) ? 0 : ANOFFSET ((OFFS), (INDEX))))
+
 extern void sort_pst_symbols (struct objfile *, struct partial_symtab *);
 
 /* Add any kind of symbol to a psymbol_allocation_list.  */
@@ -224,7 +233,6 @@ extern void add_psymbol_to_list (const char *, int,
 extern void init_psymbol_list (struct objfile *, int);
 
 extern struct partial_symtab *start_psymtab_common (struct objfile *,
-						    struct section_offsets *,
 						    const char *, CORE_ADDR,
 						    struct partial_symbol **,
 						    struct partial_symbol **);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 2787f4c..24faef9 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -995,7 +995,9 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
 	fprintf_filtered (outfile, ", ");
       wrap_here ("    ");
       fputs_filtered (paddress (gdbarch,
-				ANOFFSET (psymtab->section_offsets, i)),
+				PST_OFFSET (objfile,
+					    psymtab->section_offsets,
+					    i)),
 		      outfile);
     }
   fprintf_filtered (outfile, "\n");
@@ -1468,7 +1470,6 @@ sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst)
 
 struct partial_symtab *
 start_psymtab_common (struct objfile *objfile,
-		      struct section_offsets *section_offsets,
 		      const char *filename,
 		      CORE_ADDR textlow, struct partial_symbol **global_syms,
 		      struct partial_symbol **static_syms)
@@ -1476,7 +1477,6 @@ start_psymtab_common (struct objfile *objfile,
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (filename, objfile);
-  psymtab->section_offsets = section_offsets;
   psymtab->textlow = textlow;
   psymtab->texthigh = psymtab->textlow;		/* default */
   psymtab->globals_offset = global_syms - objfile->global_psymbols.list;
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index b986dbd..261fc7b 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2028,7 +2028,7 @@ xcoff_start_psymtab (struct objfile *objfile,
 		     struct partial_symbol **static_syms)
 {
   struct partial_symtab *result =
-    start_psymtab_common (objfile, objfile->section_offsets,
+    start_psymtab_common (objfile,
 			  filename,
 			  /* We fill in textlow later.  */
 			  0,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 1/7] remove dead code in end_psymtab
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
                   ` (4 preceding siblings ...)
  2014-02-20 21:32 ` [RFC 7/7] make psymbols and psymtabs independent of the program space Tom Tromey
@ 2014-02-20 21:32 ` Tom Tromey
  2014-02-20 22:08 ` [RFC 6/7] add validity bits for psymtab high and low fields Tom Tromey
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that there is a bit of dead code in end_psymtab.
This deletes it.

Normally I would investigate a fix for the code.  However, considering
that the code has been this way a long time (since the first import to
sourceware) and considering that dbxread.c is not as important any
more, I think it's safe to just consider that there's no bug.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (end_psymtab): Remove dead code.
---
 gdb/ChangeLog | 4 ++++
 gdb/dbxread.c | 8 +-------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 3290c67..ceb593a 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2289,13 +2289,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       ALL_OBJFILE_PSYMTABS (objfile, p1)
       {
 	if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst)
-	  {
-	    p1->texthigh = pst->textlow;
-	    /* If this file has only data, then make textlow match
-	       texthigh.  */
-	    if (p1->textlow == 0)
-	      p1->textlow = p1->texthigh;
-	  }
+	  p1->texthigh = pst->textlow;
       }
     }
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 7/7] make psymbols and psymtabs independent of the program space
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
                   ` (3 preceding siblings ...)
  2014-02-20 21:32 ` [RFC 2/7] change how psymtab section offsets are handled Tom Tromey
@ 2014-02-20 21:32 ` Tom Tromey
  2014-02-20 21:32 ` [RFC 1/7] remove dead code in end_psymtab Tom Tromey
  2014-02-20 22:08 ` [RFC 6/7] add validity bits for psymtab high and low fields Tom Tromey
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch finally makes partial symbols and partial symtabs
independent of the program space.

Specifically:

It changes add_psymbol_to_list to accept a section index, and changes
the psymbol readers to pass this.  At the same time it removes the
code to add the objfile's section offset to the psymbol.

It adds an objfile argument to the psymtab textlow and texthigh
accessors and changes some code to use the raw variants instead.

It removes the "relocate" method from struct quick_symbol_functions,
as it is no longer needed any more.

It removes the "0 *" from PSYMBOL_VALUE_ADDRESS, so that the relevant
offset is now applied at the point of use.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (find_stab_function_addr): Use
	MSYMBOL_VALUE_RAW_ADDRESS.
	(read_dbx_symtab): Use PSYMTAB_RAW_TEXTLOW, PSYMTAB_RAW_TEXTHIGH.
	Don't add objfile offsets.
	(end_psymtab): Use PSYMTAB_RAW_TEXTLOW, PSYMTAB_RAW_TEXTHIGH,
	MSYMBOL_VALUE_RAW_ADDRESS.
	(read_ofile_symtab): Update.
	* dwarf2read.c (create_addrmap_from_index): Don't add objfile
	offsets.
	(dw2_relocate): Remove.
	(dw2_find_pc_sect_symtab): Bias PC by the text offset before
	searching addrmap.
	(dwarf2_gdb_index_functions): Update.
	(process_psymtab_comp_unit_reader, add_partial_symbol)
	(add_partial_subprogram, dwarf2_ranges_read): Don't add objfile
	offsets.  Update.
	(load_partial_dies): Update.
	(add_address_entry): Don't add objfile offsets.
	* mdebugread.c (parse_symbol): Don't add objfile offsets.
	(parse_lines): Remove 'pst' parameter, replace with 'textlow'.
	Update.
	(parse_partial_symbols): Don't add objfile offsets.  Use
	PSYMTAB_RAW_TEXTLOW, PSYMTAB_RAW_TEXTHIGH.  Update.
	(handle_psymbol_enumerators, psymtab_to_symtab_1): Update.
	* objfiles.c (objfile_relocate1): Don't relocate psymtabs_addrmap
	or call 'relocate' quick function.
	* psympriv.h (PSYMBOL_VALUE_ADDRESS): Remove "0 *".
	(PSYMTAB_RAW_TEXTLOW, PSYMTAB_RAW_TEXTHIGH): New macros.
	(PSYMTAB_TEXTLOW, PSYMTAB_TEXTHIGH): Add 'objfile' parameter.
	(add_psymbol_to_bcache): Add 'section' parameter.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_psymbol): Update.
	(fixup_psymbol_section, relocate_psymtabs): Remove.
	(dump_psymtab, psym_functions): Update.
	(add_psymbol_to_bcache, add_psymbol_to_list): Add 'section'
	parameter.
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	* symfile-debug.c (debug_qf_relocate): Remove.
	(debug_sym_quick_functions): Update.
	* symfile.h (struct quick_symbol_functions) <relocate>: Remove.
	* xcoffread.c (scan_xcoff_symtab): Don't add objfile offsets.
	Update.
---
 gdb/ChangeLog       |  45 +++++++++++++++++
 gdb/dbxread.c       |  81 +++++++++++++------------------
 gdb/dwarf2read.c    |  80 +++++++++++--------------------
 gdb/mdebugread.c    | 131 ++++++++++++++++++++++++--------------------------
 gdb/objfiles.c      |   7 ---
 gdb/psympriv.h      |  14 ++++--
 gdb/psymtab.c       | 136 ++++++++++++++++------------------------------------
 gdb/symfile-debug.c |  17 -------
 gdb/symfile.h       |   6 ---
 gdb/xcoffread.c     |  27 +++++------
 10 files changed, 232 insertions(+), 312 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index bdb81ce..2b8d224 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1162,7 +1162,7 @@ find_stab_function_addr (char *namestring, const char *filename,
       msym = lookup_minimal_symbol (p, NULL, objfile);
     }
 
-  return msym.minsym == NULL ? 0 : BMSYMBOL_VALUE_ADDRESS (msym);
+  return msym.minsym == NULL ? 0 : MSYMBOL_VALUE_RAW_ADDRESS (msym.minsym);
 }
 
 static void
@@ -1357,18 +1357,15 @@ read_dbx_symtab (struct objfile *objfile)
 	      || (namestring[(nsl = strlen (namestring)) - 1] == 'o'
 		  && namestring[nsl - 2] == '.'))
 	    {
-	      nlist.n_value += ANOFFSET (objfile->section_offsets,
-					 SECT_OFF_TEXT (objfile));
-
 	      if (past_first_source_file && pst
 		  /* The gould NP1 uses low values for .o and -l symbols
 		     which are not the address.  */
-		  && nlist.n_value >= PSYMTAB_TEXTLOW (pst))
+		  && nlist.n_value >= PSYMTAB_RAW_TEXTLOW (pst))
 		{
 		  end_psymtab (objfile, pst, psymtab_include_list,
 			       includes_used, symnum * symbol_size,
-			       nlist.n_value > PSYMTAB_TEXTHIGH (pst)
-			       ? nlist.n_value : PSYMTAB_TEXTHIGH (pst),
+			       nlist.n_value > PSYMTAB_RAW_TEXTHIGH (pst)
+			       ? nlist.n_value : PSYMTAB_RAW_TEXTHIGH (pst),
 			       dependency_list, dependencies_used,
 			       textlow_not_set);
 		  pst = (struct partial_symtab *) 0;
@@ -1456,8 +1453,7 @@ read_dbx_symtab (struct objfile *objfile)
 	    static char *dirname_nso;
 	    int prev_textlow_not_set;
 
-	    valu = nlist.n_value + ANOFFSET (objfile->section_offsets,
-					     SECT_OFF_TEXT (objfile));
+	    valu = nlist.n_value;
 
 	    prev_textlow_not_set = textlow_not_set;
 
@@ -1484,8 +1480,8 @@ read_dbx_symtab (struct objfile *objfile)
 		  {
 		    end_psymtab (objfile, pst, psymtab_include_list,
 				 includes_used, symnum * symbol_size,
-				 (valu > PSYMTAB_TEXTHIGH (pst)
-				  ? valu : PSYMTAB_TEXTHIGH (pst)),
+				 (valu > PSYMTAB_RAW_TEXTHIGH (pst)
+				  ? valu : PSYMTAB_RAW_TEXTHIGH (pst)),
 				 dependency_list, dependencies_used,
 				 prev_textlow_not_set);
 		    pst = (struct partial_symtab *) 0;
@@ -1660,7 +1656,8 @@ read_dbx_symtab (struct objfile *objfile)
 		 function relative stabs, or the address of the function's
 		 end for old style stabs.  */
 	      valu = nlist.n_value + last_function_start;
-	      if (PSYMTAB_TEXTHIGH (pst) == 0 || valu > PSYMTAB_TEXTHIGH (pst))
+	      if (PSYMTAB_RAW_TEXTHIGH (pst) == 0
+		  || valu > PSYMTAB_RAW_TEXTHIGH (pst))
 		SET_PSYMTAB_TEXTHIGH (pst, valu);
 	      break;
 	    }
@@ -1704,26 +1701,23 @@ read_dbx_symtab (struct objfile *objfile)
 	  switch (p[1])
 	    {
 	    case 'S':
-	      nlist.n_value += ANOFFSET (objfile->section_offsets,
-					 data_sect_index);
-
 	      if (gdbarch_static_transform_name_p (gdbarch))
 		gdbarch_static_transform_name (gdbarch, namestring);
 
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_STATIC,
+				   data_sect_index,
 				   &objfile->static_psymbols,
 				   0, nlist.n_value,
 				   psymtab_language, objfile);
 	      continue;
 
 	    case 'G':
-	      nlist.n_value += ANOFFSET (objfile->section_offsets,
-					 data_sect_index);
 	      /* The addresses in these entries are reported to be
 		 wrong.  See the code that reads 'G's for symtabs.  */
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_STATIC,
+				   data_sect_index,
 				   &objfile->global_psymbols,
 				   0, nlist.n_value,
 				   psymtab_language, objfile);
@@ -1741,7 +1735,7 @@ read_dbx_symtab (struct objfile *objfile)
 		      && namestring[0] != ' '))
 		{
 		  add_psymbol_to_list (sym_name, sym_len, 1,
-				       STRUCT_DOMAIN, LOC_TYPEDEF,
+				       STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 				       &objfile->static_psymbols,
 				       nlist.n_value, 0,
 				       psymtab_language, objfile);
@@ -1749,7 +1743,7 @@ read_dbx_symtab (struct objfile *objfile)
 		    {
 		      /* Also a typedef with the same name.  */
 		      add_psymbol_to_list (sym_name, sym_len, 1,
-					   VAR_DOMAIN, LOC_TYPEDEF,
+					   VAR_DOMAIN, LOC_TYPEDEF, -1,
 					   &objfile->static_psymbols,
 					   nlist.n_value, 0,
 					   psymtab_language, objfile);
@@ -1762,7 +1756,7 @@ read_dbx_symtab (struct objfile *objfile)
 	      if (p != namestring)	/* a name is there, not just :T...  */
 		{
 		  add_psymbol_to_list (sym_name, sym_len, 1,
-				       VAR_DOMAIN, LOC_TYPEDEF,
+				       VAR_DOMAIN, LOC_TYPEDEF, -1,
 				       &objfile->static_psymbols,
 				       nlist.n_value, 0,
 				       psymtab_language, objfile);
@@ -1824,7 +1818,7 @@ read_dbx_symtab (struct objfile *objfile)
 		      /* Note that the value doesn't matter for
 			 enum constants in psymtabs, just in symtabs.  */
 		      add_psymbol_to_list (p, q - p, 1,
-					   VAR_DOMAIN, LOC_CONST,
+					   VAR_DOMAIN, LOC_CONST, -1,
 					   &objfile->static_psymbols, 0,
 					   0, psymtab_language, objfile);
 		      /* Point past the name.  */
@@ -1842,7 +1836,7 @@ read_dbx_symtab (struct objfile *objfile)
 	    case 'c':
 	      /* Constant, e.g. from "const" in Pascal.  */
 	      add_psymbol_to_list (sym_name, sym_len, 1,
-				   VAR_DOMAIN, LOC_CONST,
+				   VAR_DOMAIN, LOC_CONST, -1,
 				   &objfile->static_psymbols, nlist.n_value,
 				   0, psymtab_language, objfile);
 	      continue;
@@ -1858,14 +1852,11 @@ read_dbx_symtab (struct objfile *objfile)
 		  function_outside_compilation_unit_complaint (name);
 		  xfree (name);
 		}
-	      nlist.n_value += ANOFFSET (objfile->section_offsets, 
-					 SECT_OFF_TEXT (objfile));
 	      /* Kludges for ELF/STABS with Sun ACC.  */
 	      last_function_name = namestring;
 	      /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
 		 value for the bottom of the text seg in those cases.  */
-	      if (nlist.n_value == ANOFFSET (objfile->section_offsets, 
-					     SECT_OFF_TEXT (objfile))
+	      if (nlist.n_value == 0
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
 		  CORE_ADDR minsym_valu = 
@@ -1899,16 +1890,15 @@ read_dbx_symtab (struct objfile *objfile)
 		 the partial symbol table.  */
 	      if (pst
 		  && (textlow_not_set
-		      || (nlist.n_value < PSYMTAB_TEXTLOW (pst)
-			  && (nlist.n_value
-			      != ANOFFSET (objfile->section_offsets,
-					   SECT_OFF_TEXT (objfile))))))
+		      || (nlist.n_value < PSYMTAB_RAW_TEXTLOW (pst)
+			  && (nlist.n_value != 0))))
 		{
 		  SET_PSYMTAB_TEXTLOW (pst, nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_BLOCK,
+				   SECT_OFF_TEXT (objfile),
 				   &objfile->static_psymbols,
 				   0, nlist.n_value,
 				   psymtab_language, objfile);
@@ -1928,14 +1918,11 @@ read_dbx_symtab (struct objfile *objfile)
 		  function_outside_compilation_unit_complaint (name);
 		  xfree (name);
 		}
-	      nlist.n_value += ANOFFSET (objfile->section_offsets, 
-					 SECT_OFF_TEXT (objfile));
 	      /* Kludges for ELF/STABS with Sun ACC.  */
 	      last_function_name = namestring;
 	      /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
 		 value for the bottom of the text seg in those cases.  */
-	      if (nlist.n_value == ANOFFSET (objfile->section_offsets, 
-					     SECT_OFF_TEXT (objfile))
+	      if (nlist.n_value == 0
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
 		  CORE_ADDR minsym_valu = 
@@ -1969,16 +1956,15 @@ read_dbx_symtab (struct objfile *objfile)
 		 the partial symbol table.  */
 	      if (pst
 		  && (textlow_not_set
-		      || (nlist.n_value < PSYMTAB_TEXTLOW (pst)
-			  && (nlist.n_value
-			      != ANOFFSET (objfile->section_offsets,
-					   SECT_OFF_TEXT (objfile))))))
+		      || (nlist.n_value < PSYMTAB_RAW_TEXTLOW (pst)
+			  && (nlist.n_value != 0))))
 		{
 		  SET_PSYMTAB_TEXTLOW (pst, nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_BLOCK,
+				   SECT_OFF_TEXT (objfile),
 				   &objfile->global_psymbols,
 				   0, nlist.n_value,
 				   psymtab_language, objfile);
@@ -2152,15 +2138,14 @@ read_dbx_symtab (struct objfile *objfile)
       /* Don't set pst->texthigh lower than it already is.  */
       CORE_ADDR text_end =
 	(lowest_text_address == (CORE_ADDR) -1
-	 ? (text_addr + ANOFFSET (objfile->section_offsets,
-				  SECT_OFF_TEXT (objfile)))
+	 ? text_addr
 	 : lowest_text_address)
 	+ text_size;
 
       end_psymtab (objfile, pst, psymtab_include_list, includes_used,
 		   symnum * symbol_size,
-		   (text_end > PSYMTAB_TEXTHIGH (pst)
-		    ? text_end : PSYMTAB_TEXTHIGH (pst)),
+		   (text_end > PSYMTAB_RAW_TEXTHIGH (pst)
+		    ? text_end : PSYMTAB_RAW_TEXTHIGH (pst)),
 		   dependency_list, dependencies_used, textlow_not_set);
     }
 
@@ -2239,7 +2224,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
      a reliable texthigh by taking the address plus size of the
      last function in the file.  */
 
-  if (PSYMTAB_TEXTHIGH (pst) == 0 && last_function_name
+  if (PSYMTAB_RAW_TEXTHIGH (pst) == 0 && last_function_name
       && gdbarch_sofun_address_maybe_missing (gdbarch))
     {
       char *p;
@@ -2266,7 +2251,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 	}
 
       if (minsym.minsym)
-	SET_PSYMTAB_TEXTHIGH (pst, (BMSYMBOL_VALUE_ADDRESS (minsym)
+	SET_PSYMTAB_TEXTHIGH (pst, (MSYMBOL_VALUE_RAW_ADDRESS (minsym.minsym)
 				    + MSYMBOL_SIZE (minsym.minsym)));
 
       last_function_name = NULL;
@@ -2276,7 +2261,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
     ;
   /* This test will be true if the last .o file is only data.  */
   else if (textlow_not_set)
-    SET_PSYMTAB_TEXTLOW (pst, PSYMTAB_TEXTHIGH (pst));
+    SET_PSYMTAB_TEXTLOW (pst, PSYMTAB_RAW_TEXTHIGH (pst));
   else
     {
       struct partial_symtab *p1;
@@ -2289,7 +2274,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       ALL_OBJFILE_PSYMTABS (objfile, p1)
       {
 	if (!p1->texthigh_valid && p1->textlow_valid && p1 != pst)
-	  SET_PSYMTAB_TEXTHIGH (p1, PSYMTAB_TEXTLOW (pst));
+	  SET_PSYMTAB_TEXTHIGH (p1, PSYMTAB_RAW_TEXTLOW (pst));
       }
     }
 
@@ -2497,8 +2482,8 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
 
   sym_offset = LDSYMOFF (pst);
   sym_size = LDSYMLEN (pst);
-  text_offset = PSYMTAB_TEXTLOW (pst);
-  text_size = PSYMTAB_TEXTHIGH (pst) - PSYMTAB_TEXTLOW (pst);
+  text_offset = PSYMTAB_TEXTLOW (objfile, pst);
+  text_size = PSYMTAB_TEXTHIGH (objfile, pst) - PSYMTAB_TEXTLOW (objfile, pst);
   section_offsets = pst->section_offsets;
 
   dbxread_objfile = objfile;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index df95d04..8fdc22d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2818,7 +2818,6 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
   struct obstack temp_obstack;
   struct addrmap *mutable_map;
   struct cleanup *cleanup;
-  CORE_ADDR baseaddr;
 
   obstack_init (&temp_obstack);
   cleanup = make_cleanup_obstack_free (&temp_obstack);
@@ -2827,8 +2826,6 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
   iter = index->address_table;
   end = iter + index->address_table_size;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
-
   while (iter < end)
     {
       ULONGEST hi, lo, cu_index;
@@ -2855,8 +2852,7 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
 	  continue;
 	}
 
-      addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
-			 dw2_get_cu (cu_index));
+      addrmap_set_empty (mutable_map, lo, hi - 1, dw2_get_cu (cu_index));
     }
 
   objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
@@ -3666,14 +3662,6 @@ dw2_dump (struct objfile *objfile)
 }
 
 static void
-dw2_relocate (struct objfile *objfile,
-	      const struct section_offsets *new_offsets,
-	      const struct section_offsets *delta)
-{
-  /* There's nothing to relocate here.  */
-}
-
-static void
 dw2_expand_symtabs_for_function (struct objfile *objfile,
 				 const char *func_name)
 {
@@ -3985,13 +3973,15 @@ dw2_find_pc_sect_symtab (struct objfile *objfile,
 {
   struct dwarf2_per_cu_data *data;
   struct symtab *result;
+  CORE_ADDR baseaddr
+    = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   dw2_setup (objfile);
 
   if (!objfile->psymtabs_addrmap)
     return NULL;
 
-  data = addrmap_find (objfile->psymtabs_addrmap, pc);
+  data = addrmap_find (objfile->psymtabs_addrmap, pc - baseaddr);
   if (!data)
     return NULL;
 
@@ -4086,7 +4076,6 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
   dw2_lookup_symbol,
   dw2_print_stats,
   dw2_dump,
-  dw2_relocate,
   dw2_expand_symtabs_for_function,
   dw2_expand_all_symtabs,
   dw2_expand_symtabs_with_fullname,
@@ -5965,7 +5954,6 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
   struct objfile *objfile = cu->objfile;
   struct dwarf2_per_cu_data *per_cu = cu->per_cu;
   struct attribute *attr;
-  CORE_ADDR baseaddr;
   CORE_ADDR best_lowpc = 0, best_highpc = 0;
   struct partial_symtab *pst;
   int has_pc_info;
@@ -5995,8 +5983,6 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
   if (attr != NULL)
     pst->dirname = DW_STRING (attr);
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
-
   dwarf2_find_base_address (comp_unit_die, cu);
 
   /* Possibly set the default values of LOWPC and HIGHPC from
@@ -6007,8 +5993,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
     /* Store the contiguous range if it is not empty; it can be empty for
        CUs with no code.  */
     addrmap_set_empty (objfile->psymtabs_addrmap,
-		       best_lowpc + baseaddr,
-		       best_highpc + baseaddr - 1, pst);
+		       best_lowpc, best_highpc - 1, pst);
 
   /* Check if comp unit has_children.
      If so, read the rest of the partial symbols from this comp unit.
@@ -6039,8 +6024,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 	  best_highpc = highpc;
 	}
     }
-  SET_PSYMTAB_TEXTLOW (pst, best_lowpc + baseaddr);
-  SET_PSYMTAB_TEXTHIGH (pst, best_highpc + baseaddr);
+  SET_PSYMTAB_TEXTLOW (pst, best_lowpc);
+  SET_PSYMTAB_TEXTHIGH (pst, best_highpc);
 
   pst->n_global_syms = objfile->global_psymbols.next -
     (objfile->global_psymbols.list + pst->globals_offset);
@@ -6081,8 +6066,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 			  ", %d global, %d static syms\n",
 			  per_cu->is_debug_types ? "type" : "comp",
 			  per_cu->offset.sect_off,
-			  paddress (gdbarch, PSYMTAB_TEXTLOW (pst)),
-			  paddress (gdbarch, PSYMTAB_TEXTHIGH (pst)),
+			  paddress (gdbarch, PSYMTAB_TEXTLOW (objfile, pst)),
+			  paddress (gdbarch, PSYMTAB_TEXTHIGH (objfile, pst)),
 			  pst->n_global_syms, pst->n_static_syms);
     }
 }
@@ -6673,11 +6658,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
   struct objfile *objfile = cu->objfile;
   CORE_ADDR addr = 0;
   const char *actual_name = NULL;
-  CORE_ADDR baseaddr;
   char *built_actual_name;
 
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
-
   built_actual_name = partial_die_full_name (pdi, cu);
   if (built_actual_name != NULL)
     actual_name = built_actual_name;
@@ -6699,8 +6681,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	  add_psymbol_to_list (actual_name, strlen (actual_name),
 			       built_actual_name != NULL,
 			       VAR_DOMAIN, LOC_BLOCK,
+			       SECT_OFF_TEXT (objfile),
 			       &objfile->global_psymbols,
-			       0, pdi->lowpc + baseaddr,
+			       0, pdi->lowpc,
 			       cu->language, objfile);
 	}
       else
@@ -6710,8 +6693,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	  add_psymbol_to_list (actual_name, strlen (actual_name),
 			       built_actual_name != NULL,
 			       VAR_DOMAIN, LOC_BLOCK,
+			       SECT_OFF_TEXT (objfile),
 			       &objfile->static_psymbols,
-			       0, pdi->lowpc + baseaddr,
+			       0, pdi->lowpc,
 			       cu->language, objfile);
 	}
       break;
@@ -6725,6 +6709,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	  list = &objfile->static_psymbols;
 	add_psymbol_to_list (actual_name, strlen (actual_name),
 			     built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC,
+			     -1,
 			     list, 0, 0, cu->language, objfile);
       }
       break;
@@ -6760,8 +6745,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	    add_psymbol_to_list (actual_name, strlen (actual_name),
 				 built_actual_name != NULL,
 				 VAR_DOMAIN, LOC_STATIC,
+				 SECT_OFF_TEXT (objfile),
 				 &objfile->global_psymbols,
-				 0, addr + baseaddr,
+				 0, addr,
 				 cu->language, objfile);
 	}
       else
@@ -6777,8 +6763,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	  add_psymbol_to_list (actual_name, strlen (actual_name),
 			       built_actual_name != NULL,
 			       VAR_DOMAIN, LOC_STATIC,
+			       SECT_OFF_TEXT (objfile),
 			       &objfile->static_psymbols,
-			       0, addr + baseaddr,
+			       0, addr,
 			       cu->language, objfile);
 	}
       break;
@@ -6787,7 +6774,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
     case DW_TAG_subrange_type:
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
-			   VAR_DOMAIN, LOC_TYPEDEF,
+			   VAR_DOMAIN, LOC_TYPEDEF, -1,
 			   &objfile->static_psymbols,
 			   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
@@ -6795,14 +6782,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
     case DW_TAG_namespace:
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
-			   VAR_DOMAIN, LOC_TYPEDEF,
+			   VAR_DOMAIN, LOC_TYPEDEF, -1,
 			   &objfile->global_psymbols,
 			   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
     case DW_TAG_module:
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
-			   MODULE_DOMAIN, LOC_TYPEDEF,
+			   MODULE_DOMAIN, LOC_TYPEDEF, -1,
 			   &objfile->global_psymbols,
 			   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
@@ -6826,7 +6813,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	 static vs. global.  */
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
-			   STRUCT_DOMAIN, LOC_TYPEDEF,
+			   STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 			   (cu->language == language_cplus
 			    || cu->language == language_java)
 			   ? &objfile->global_psymbols
@@ -6837,7 +6824,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
     case DW_TAG_enumerator:
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
-			   VAR_DOMAIN, LOC_CONST,
+			   VAR_DOMAIN, LOC_CONST, -1,
 			   (cu->language == language_cplus
 			    || cu->language == language_java)
 			   ? &objfile->global_psymbols
@@ -6911,14 +6898,10 @@ add_partial_subprogram (struct partial_die_info *pdi,
             *highpc = pdi->highpc;
 	  if (need_pc)
 	    {
-	      CORE_ADDR baseaddr;
 	      struct objfile *objfile = cu->objfile;
 
-	      baseaddr = ANOFFSET (objfile->section_offsets,
-				   SECT_OFF_TEXT (objfile));
 	      addrmap_set_empty (objfile->psymtabs_addrmap,
-				 pdi->lowpc + baseaddr,
-				 pdi->highpc - 1 + baseaddr,
+				 pdi->lowpc, pdi->highpc - 1,
 				 cu->per_cu->v.psymtab);
 	    }
         }
@@ -11615,9 +11598,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 
       if (ranges_pst != NULL)
 	addrmap_set_empty (objfile->psymtabs_addrmap,
-			   range_beginning + baseaddr,
-			   range_end - 1 + baseaddr,
-			   ranges_pst);
+			   range_beginning, range_end - 1, ranges_pst);
 
       /* FIXME: This is recording everything as a low-high
 	 segment of consecutive addresses.  We should have a
@@ -15026,7 +15007,7 @@ load_partial_dies (const struct die_reader_specs *reader,
 	{
 	  if (building_psymtab && part_die->name != NULL)
 	    add_psymbol_to_list (part_die->name, strlen (part_die->name), 0,
-				 VAR_DOMAIN, LOC_TYPEDEF,
+				 VAR_DOMAIN, LOC_TYPEDEF, -1,
 				 &objfile->static_psymbols,
 				 0, (CORE_ADDR) 0, cu->language, objfile);
 	  info_ptr = locate_pdi_sibling (reader, part_die, info_ptr);
@@ -15062,7 +15043,7 @@ load_partial_dies (const struct die_reader_specs *reader,
 		       _("malformed enumerator DIE ignored"));
 	  else if (building_psymtab)
 	    add_psymbol_to_list (part_die->name, strlen (part_die->name), 0,
-				 VAR_DOMAIN, LOC_CONST,
+				 VAR_DOMAIN, LOC_CONST, -1,
 				 (cu->language == language_cplus
 				  || cu->language == language_java)
 				 ? &objfile->global_psymbols
@@ -21994,13 +21975,10 @@ add_address_entry (struct objfile *objfile, struct obstack *obstack,
 {
   offset_type cu_index_to_write;
   gdb_byte addr[8];
-  CORE_ADDR baseaddr;
-
-  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, start - baseaddr);
+  store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, start);
   obstack_grow (obstack, addr, 8);
-  store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, end - baseaddr);
+  store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, end);
   obstack_grow (obstack, addr, 8);
   cu_index_to_write = MAYBE_SWAP (cu_index);
   obstack_grow (obstack, &cu_index_to_write, sizeof (offset_type));
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 2cc9be4..5f63eaf 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -565,6 +565,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
   TIR tir;
   long svalue = sh->value;
   int bitsize;
+  int section;
 
   if (ext_sh == (char *) NULL)
     name = debug_info->ssext + sh->iss;
@@ -581,21 +582,26 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
          The value of a stBlock symbol is the displacement from the
          procedure address.  */
       if (sh->st != stEnd && sh->st != stBlock)
-	sh->value += PST_OFFSET (objfile, section_offsets,
-				   SECT_OFF_TEXT (objfile));
+	{
+	  if (section_offsets != NULL)
+	    sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+	  section = SECT_OFF_TEXT (objfile);
+	}
       break;
     case scData:
     case scSData:
     case scRData:
     case scPData:
     case scXData:
-      sh->value += PST_OFFSET (objfile, section_offsets,
-			       SECT_OFF_DATA (objfile));
+      if (section_offsets != NULL)
+	sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
+      section = SECT_OFF_DATA (objfile);
       break;
     case scBss:
     case scSBss:
-      sh->value += PST_OFFSET (objfile, section_offsets,
-			       SECT_OFF_BSS (objfile));
+      if (section_offsets != NULL)
+	sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
+      section = SECT_OFF_BSS (objfile);
       break;
     }
 
@@ -2172,12 +2178,9 @@ parse_external (EXTR *es, int bigend, struct section_offsets *section_offsets,
    numbers can go back and forth, apparently we can live
    with that and do not need to reorder our linetables.  */
 
-static void parse_lines (FDR *, PDR *, struct linetable *, int,
-			 struct partial_symtab *, CORE_ADDR);
-
 static void
 parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines,
-	     struct partial_symtab *pst, CORE_ADDR lowest_pdr_addr)
+	     CORE_ADDR textlow, CORE_ADDR lowest_pdr_addr)
 {
   unsigned char *base;
   int j, k;
@@ -2208,7 +2211,7 @@ parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines,
 	halt = base + fh->cbLine;
       base += pr->cbLineOffset;
 
-      adr = PSYMTAB_TEXTLOW (pst) + pr->adr - lowest_pdr_addr;
+      adr = textlow + pr->adr - lowest_pdr_addr;
 
       l = adr >> 2;		/* in words */
       for (lineno = pr->lnLow; base < halt;)
@@ -2630,6 +2633,7 @@ parse_partial_symbols (struct objfile *objfile)
       struct partial_symtab *save_pst;
       EXTR *ext_ptr;
       CORE_ADDR textlow;
+      int section = -1;
 
       cur_fdr = fh = debug_info->fdr + f_idx;
 
@@ -2645,8 +2649,7 @@ parse_partial_symbols (struct objfile *objfile)
 	{
 	  textlow = fh->adr;
 	  if (relocatable || textlow != 0)
-	    textlow += ANOFFSET (objfile->section_offsets,
-				 SECT_OFF_TEXT (objfile));
+	    section = SECT_OFF_TEXT (objfile);
 	}
       else
 	textlow = 0;
@@ -2695,7 +2698,7 @@ parse_partial_symbols (struct objfile *objfile)
 	psymtab_language = prev_language;
       PST_PRIVATE (pst)->pst_language = psymtab_language;
 
-      SET_PSYMTAB_TEXTHIGH (pst, PSYMTAB_TEXTLOW (pst));
+      SET_PSYMTAB_TEXTHIGH (pst, PSYMTAB_RAW_TEXTLOW (pst));
 
       /* For stabs-in-ecoff files, the second symbol must be @stab.
          This symbol is emitted by mips-tfile to signal that the
@@ -2741,8 +2744,7 @@ parse_partial_symbols (struct objfile *objfile)
                                                  mst_file_text, sh.sc,
                                                  objfile);
 			}
-		      sh.value += ANOFFSET (objfile->section_offsets,
-					    SECT_OFF_TEXT (objfile));
+		      section = SECT_OFF_TEXT (objfile);
 		      procaddr = sh.value;
 
 		      isym = AUX_GET_ISYM (fh->fBigendian,
@@ -2761,9 +2763,9 @@ parse_partial_symbols (struct objfile *objfile)
 			  /* Kludge for Irix 5.2 zero fh->adr.  */
 			  if (!relocatable
 			      && (!pst->textlow_valid
-				  || procaddr < PSYMTAB_TEXTLOW (pst)))
+				  || procaddr < PSYMTAB_RAW_TEXTLOW (pst)))
 			    SET_PSYMTAB_TEXTLOW (pst, procaddr);
-			  if (high > PSYMTAB_TEXTHIGH (pst))
+			  if (high > PSYMTAB_RAW_TEXTHIGH (pst))
 			    SET_PSYMTAB_TEXTHIGH (pst, high);
 			}
 		    }
@@ -2786,8 +2788,7 @@ parse_partial_symbols (struct objfile *objfile)
                           record_minimal_symbol (namestring, sh.value,
                                                  mst_file_data, sh.sc,
                                                  objfile);
-			  sh.value += ANOFFSET (objfile->section_offsets,
-						SECT_OFF_DATA (objfile));
+			  section = SECT_OFF_DATA (objfile);
 			  break;
 
 			default:
@@ -2797,8 +2798,7 @@ parse_partial_symbols (struct objfile *objfile)
                           record_minimal_symbol (namestring, sh.value,
                                                  mst_file_bss, sh.sc,
                                                  objfile);
-			  sh.value += ANOFFSET (objfile->section_offsets,
-						SECT_OFF_BSS (objfile));
+			  section = SECT_OFF_BSS (objfile);
 			  break;
 			}
 		    }
@@ -2850,22 +2850,19 @@ parse_partial_symbols (struct objfile *objfile)
 
 		  case N_TEXT | N_EXT:
 		  case N_NBTEXT | N_EXT:
-		    sh.value += ANOFFSET (objfile->section_offsets,
-					  SECT_OFF_TEXT (objfile));
+		    section = SECT_OFF_TEXT (objfile);
 		    goto record_it;
 
 		  case N_DATA | N_EXT:
 		  case N_NBDATA | N_EXT:
-		    sh.value += ANOFFSET (objfile->section_offsets,
-					  SECT_OFF_DATA (objfile));
+		    section = SECT_OFF_DATA (objfile);
 		    goto record_it;
 
 		  case N_BSS:
 		  case N_BSS | N_EXT:
 		  case N_NBBSS | N_EXT:
 		  case N_SETV | N_EXT:		/* FIXME, is this in BSS?  */
-		    sh.value += ANOFFSET (objfile->section_offsets,
-					  SECT_OFF_BSS (objfile));
+		    section = SECT_OFF_BSS (objfile);
 		    goto record_it;
 
 		  case N_ABS | N_EXT:
@@ -2888,8 +2885,7 @@ parse_partial_symbols (struct objfile *objfile)
 		    continue;
 
 		  case N_DATA:
-		    sh.value += ANOFFSET (objfile->section_offsets,
-					  SECT_OFF_DATA (objfile));
+		    section = SECT_OFF_DATA (objfile);
 		    goto record_it;
 
 		  case N_UNDF | N_EXT:
@@ -2935,8 +2931,8 @@ parse_partial_symbols (struct objfile *objfile)
 		      const char *p;
 		      int prev_textlow_not_set;
 
-		      valu = sh.value + ANOFFSET (objfile->section_offsets,
-						  SECT_OFF_TEXT (objfile));
+		      valu = sh.value;
+		      section = SECT_OFF_TEXT (objfile);
 
 		      prev_textlow_not_set = textlow_not_set;
 
@@ -3105,27 +3101,24 @@ parse_partial_symbols (struct objfile *objfile)
 		    switch (p[1])
 		      {
 		      case 'S':
-			sh.value += ANOFFSET (objfile->section_offsets,
-					      SECT_OFF_DATA (objfile));
-
 			if (gdbarch_static_transform_name_p (gdbarch))
 			  namestring = gdbarch_static_transform_name
 					 (gdbarch, namestring);
 
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_STATIC,
+					     SECT_OFF_DATA (objfile),
 					     &objfile->static_psymbols,
 					     0, sh.value,
 					     psymtab_language, objfile);
 			continue;
 		      case 'G':
-			sh.value += ANOFFSET (objfile->section_offsets,
-					      SECT_OFF_DATA (objfile));
 			/* The addresses in these entries are reported
 			   to be wrong.  See the code that reads 'G's
 			   for symtabs.  */
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_STATIC,
+					     SECT_OFF_DATA (objfile),
 					     &objfile->global_psymbols,
 					     0, sh.value,
 					     psymtab_language, objfile);
@@ -3144,6 +3137,7 @@ parse_partial_symbols (struct objfile *objfile)
 			  {
 			    add_psymbol_to_list (namestring, p - namestring, 1,
 						 STRUCT_DOMAIN, LOC_TYPEDEF,
+						 -1,
 						 &objfile->static_psymbols,
 						 sh.value, 0,
 						 psymtab_language, objfile);
@@ -3153,6 +3147,7 @@ parse_partial_symbols (struct objfile *objfile)
 				add_psymbol_to_list (namestring,
 						     p - namestring, 1,
 						     VAR_DOMAIN, LOC_TYPEDEF,
+						     -1,
 						     &objfile->static_psymbols,
 						     sh.value, 0,
 						     psymtab_language,
@@ -3167,6 +3162,7 @@ parse_partial_symbols (struct objfile *objfile)
 			  {
 			    add_psymbol_to_list (namestring, p - namestring, 1,
 						 VAR_DOMAIN, LOC_TYPEDEF,
+						 -1,
 						 &objfile->static_psymbols,
 						 sh.value, 0,
 						 psymtab_language, objfile);
@@ -3232,6 +3228,7 @@ parse_partial_symbols (struct objfile *objfile)
 				   symtabs.  */
 				add_psymbol_to_list (p, q - p, 1,
 						     VAR_DOMAIN, LOC_CONST,
+						     -1,
 						     &objfile->static_psymbols,
 						     0, 0, psymtab_language,
 						     objfile);
@@ -3249,7 +3246,7 @@ parse_partial_symbols (struct objfile *objfile)
 		      case 'c':
 			/* Constant, e.g. from "const" in Pascal.  */
 			add_psymbol_to_list (namestring, p - namestring, 1,
-					     VAR_DOMAIN, LOC_CONST,
+					     VAR_DOMAIN, LOC_CONST, -1,
 					     &objfile->static_psymbols,
 					     sh.value, 0, psymtab_language,
 					     objfile);
@@ -3266,10 +3263,9 @@ parse_partial_symbols (struct objfile *objfile)
 			    function_outside_compilation_unit_complaint (name);
 			    xfree (name);
 			  }
-			sh.value += ANOFFSET (objfile->section_offsets,
-					      SECT_OFF_TEXT (objfile));
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_BLOCK,
+					     SECT_OFF_TEXT (objfile),
 					     &objfile->static_psymbols,
 					     0, sh.value,
 					     psymtab_language, objfile);
@@ -3290,10 +3286,9 @@ parse_partial_symbols (struct objfile *objfile)
 			    function_outside_compilation_unit_complaint (name);
 			    xfree (name);
 			  }
-			sh.value += ANOFFSET (objfile->section_offsets,
-					      SECT_OFF_TEXT (objfile));
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_BLOCK,
+					     SECT_OFF_TEXT (objfile),
 					     &objfile->global_psymbols,
 					     0, sh.value,
 					     psymtab_language, objfile);
@@ -3366,7 +3361,7 @@ parse_partial_symbols (struct objfile *objfile)
 		    continue;
 
 		  case N_RBRAC:
-		    if (sh.value > PSYMTAB_TEXTHIGH (save_pst))
+		    if (sh.value > PSYMTAB_RAW_TEXTHIGH (save_pst))
 		      SET_PSYMTAB_TEXTHIGH (save_pst, sh.value);
 		    continue;
 		  case N_EINCL:
@@ -3423,6 +3418,7 @@ parse_partial_symbols (struct objfile *objfile)
 	      char *name;
 	      enum address_class class;
 	      CORE_ADDR minsym_value;
+	      short section = -1;
 
 	      (*swap_sym_in) (cur_bfd,
 			      ((char *) debug_info->external_sym
@@ -3457,21 +3453,18 @@ parse_partial_symbols (struct objfile *objfile)
 		  /* The value of a stEnd symbol is the displacement from the
 		     corresponding start symbol value, do not relocate it.  */
 		  if (sh.st != stEnd)
-		    sh.value += ANOFFSET (objfile->section_offsets,
-					  SECT_OFF_TEXT (objfile));
+		    section = SECT_OFF_TEXT (objfile);
 		  break;
 		case scData:
 		case scSData:
 		case scRData:
 		case scPData:
 		case scXData:
-		  sh.value += ANOFFSET (objfile->section_offsets,
-					SECT_OFF_DATA (objfile));
+		  section = SECT_OFF_DATA (objfile);
 		  break;
 		case scBss:
 		case scSBss:
-		  sh.value += ANOFFSET (objfile->section_offsets,
-					SECT_OFF_BSS (objfile));
+		  section = SECT_OFF_BSS (objfile);
 		  break;
 		}
 
@@ -3537,11 +3530,13 @@ parse_partial_symbols (struct objfile *objfile)
 		  if (sh.st == stProc)
 		    add_psymbol_to_list (name, strlen (name), 1,
 					 VAR_DOMAIN, LOC_BLOCK,
+					 section,
 					 &objfile->global_psymbols,
 				    0, sh.value, psymtab_language, objfile);
 		  else
 		    add_psymbol_to_list (name, strlen (name), 1,
 					 VAR_DOMAIN, LOC_BLOCK,
+					 section,
 					 &objfile->static_psymbols,
 				    0, sh.value, psymtab_language, objfile);
 
@@ -3559,11 +3554,11 @@ parse_partial_symbols (struct objfile *objfile)
 		  /* Kludge for Irix 5.2 zero fh->adr.  */
 		  if (!relocatable
 		      && (!pst->textlow_valid
-			  || procaddr < PSYMTAB_TEXTLOW (pst)))
+			  || procaddr < PSYMTAB_RAW_TEXTLOW (pst)))
 		    SET_PSYMTAB_TEXTLOW (pst, procaddr);
 
 		  high = procaddr + sh.value;
-		  if (high > PSYMTAB_TEXTHIGH (pst))
+		  if (high > PSYMTAB_RAW_TEXTHIGH (pst))
 		    SET_PSYMTAB_TEXTHIGH (pst, high);
 		  continue;
 
@@ -3609,7 +3604,7 @@ parse_partial_symbols (struct objfile *objfile)
 		      && sh.index != cur_sdx + 2)
 		    {
 		      add_psymbol_to_list (name, strlen (name), 1,
-					   STRUCT_DOMAIN, LOC_TYPEDEF,
+					   STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 					   &objfile->static_psymbols,
 					   0, (CORE_ADDR) 0,
 					   psymtab_language, objfile);
@@ -3650,7 +3645,7 @@ parse_partial_symbols (struct objfile *objfile)
 		}
 	      /* Use this gdb symbol.  */
 	      add_psymbol_to_list (name, strlen (name), 1,
-				   VAR_DOMAIN, class,
+				   VAR_DOMAIN, class, section,
 				   &objfile->static_psymbols,
 				   0, sh.value, psymtab_language, objfile);
 	    skip:
@@ -3668,6 +3663,7 @@ parse_partial_symbols (struct objfile *objfile)
 	      SYMR *psh;
 	      char *name;
 	      CORE_ADDR svalue;
+	      short section;
 
 	      if (ext_ptr->ifd != f_idx)
 		internal_error (__FILE__, __LINE__,
@@ -3681,23 +3677,21 @@ parse_partial_symbols (struct objfile *objfile)
 	      svalue = psh->value;
 	      switch (psh->sc)
 		{
+		default:
 		case scText:
 		case scRConst:
-		  svalue += ANOFFSET (objfile->section_offsets,
-				      SECT_OFF_TEXT (objfile));
+		  section = SECT_OFF_TEXT (objfile);
 		  break;
 		case scData:
 		case scSData:
 		case scRData:
 		case scPData:
 		case scXData:
-		  svalue += ANOFFSET (objfile->section_offsets,
-				      SECT_OFF_DATA (objfile));
+		  section = SECT_OFF_DATA (objfile);
 		  break;
 		case scBss:
 		case scSBss:
-		  svalue += ANOFFSET (objfile->section_offsets,
-				      SECT_OFF_BSS (objfile));
+		  section = SECT_OFF_BSS (objfile);
 		  break;
 		}
 
@@ -3731,6 +3725,7 @@ parse_partial_symbols (struct objfile *objfile)
 	      name = debug_info->ssext + psh->iss;
 	      add_psymbol_to_list (name, strlen (name), 1,
 				   VAR_DOMAIN, class,
+				   section,
 				   &objfile->global_psymbols,
 				   0, svalue,
 				   psymtab_language, objfile);
@@ -3741,7 +3736,7 @@ parse_partial_symbols (struct objfile *objfile)
          empty and put on the free list.  */
       fdr_to_pst[f_idx].pst = end_psymtab (objfile, save_pst,
 					psymtab_include_list, includes_used,
-					   -1, PSYMTAB_TEXTHIGH (save_pst),
+					   -1, PSYMTAB_RAW_TEXTHIGH (save_pst),
 		       dependency_list, dependencies_used, textlow_not_set);
       includes_used = 0;
       dependencies_used = 0;
@@ -3765,9 +3760,9 @@ parse_partial_symbols (struct objfile *objfile)
 	  ALL_OBJFILE_PSYMTABS (objfile, pst)
 	  {
 	    if (save_pst != pst
-		&& PSYMTAB_TEXTLOW (save_pst) >= PSYMTAB_TEXTLOW (pst)
-		&& PSYMTAB_TEXTLOW (save_pst) < PSYMTAB_TEXTHIGH (pst)
-		&& PSYMTAB_TEXTHIGH (save_pst) > PSYMTAB_TEXTHIGH (pst))
+		&& PSYMTAB_RAW_TEXTLOW (save_pst) >= PSYMTAB_RAW_TEXTLOW (pst)
+		&& PSYMTAB_RAW_TEXTLOW (save_pst) < PSYMTAB_RAW_TEXTHIGH (pst)
+		&& PSYMTAB_RAW_TEXTHIGH (save_pst) > PSYMTAB_RAW_TEXTHIGH (pst))
 	      {
 		objfile->flags |= OBJF_REORDERED;
 		break;
@@ -3894,7 +3889,7 @@ handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
       /* Note that the value doesn't matter for enum constants
          in psymtabs, just in symtabs.  */
       add_psymbol_to_list (name, strlen (name), 1,
-			   VAR_DOMAIN, LOC_CONST,
+			   VAR_DOMAIN, LOC_CONST, -1,
 			   &objfile->static_psymbols, 0,
 			   (CORE_ADDR) 0, psymtab_language, objfile);
       ext_sym += external_sym_size;
@@ -4125,8 +4120,8 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 
       if (! last_symtab_ended)
 	{
-	  st = end_symtab (PSYMTAB_TEXTHIGH (pst), objfile,
-			   SECT_OFF_TEXT (objfile));
+	  st = end_symtab (PSYMTAB_TEXTHIGH (objfile, pst),
+			   objfile, SECT_OFF_TEXT (objfile));
 	  end_stabs ();
 	}
 
@@ -4207,7 +4202,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
       top_stack->cur_st = st;
       top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (st),
 						STATIC_BLOCK);
-      BLOCK_START (top_stack->cur_block) = PSYMTAB_TEXTLOW (pst);
+      BLOCK_START (top_stack->cur_block) = PSYMTAB_TEXTLOW (objfile, pst);
       BLOCK_END (top_stack->cur_block) = 0;
       top_stack->blocktype = stFile;
       top_stack->cur_type = 0;
@@ -4272,7 +4267,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 		}
 
 	      parse_lines (fh, pr_block, lines, maxlines,
-			   pst, lowest_pdr_addr);
+			   PSYMTAB_TEXTLOW (objfile, pst), lowest_pdr_addr);
 	      if (lines->nitems < fh->cline)
 		lines = shrink_linetable (lines);
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 83b8961..c9cbe80 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -794,13 +794,6 @@ objfile_relocate1 (struct objfile *objfile,
       relocate_one_symbol (iter, objfile, delta);
   }
 
-  if (objfile->psymtabs_addrmap)
-    addrmap_relocate (objfile->psymtabs_addrmap,
-		      ANOFFSET (delta, SECT_OFF_TEXT (objfile)));
-
-  if (objfile->sf)
-    objfile->sf->qf->relocate (objfile, new_offsets, delta);
-
   {
     int i;
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 6d732d6..0fe1025 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -59,7 +59,7 @@ struct partial_symbol
 #define PSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->pginfo.value.address + 0)
 #define PSYMBOL_VALUE_ADDRESS(objfile, symbol)	\
   ((symbol)->pginfo.value.address \
-   + (0 * (ANOFFSET ((objfile)->section_offsets, ((symbol)->pginfo.section)))))
+   + (ANOFFSET ((objfile)->section_offsets, ((symbol)->pginfo.section))))
 #define PSYMBOL_LANGUAGE(symbol)	(symbol)->pginfo.language
 #define PSYMBOL_SECTION(symbol)		(symbol)->pginfo.section
 #define PSYMBOL_OBJ_SECTION(objfile, symbol)			\
@@ -255,8 +255,15 @@ struct partial_symtab
   (ANOFFSET ((OBJF)->section_offsets, (INDEX))			\
    + ((((OFFS) == NULL)) ? 0 : ANOFFSET ((OFFS), (INDEX))))
 
-#define PSYMTAB_TEXTLOW(PST) ((PST)->textlow_ + 0)
-#define PSYMTAB_TEXTHIGH(PST) ((PST)->texthigh_ + 0)
+#define PSYMTAB_RAW_TEXTLOW(PST) ((PST)->textlow_ + 0)
+#define PSYMTAB_RAW_TEXTHIGH(PST) ((PST)->texthigh_ + 0)
+
+#define PSYMTAB_TEXTLOW(OBJFILE, PST)					\
+  ((PST)->textlow_							\
+   + ANOFFSET ((OBJFILE)->section_offsets, SECT_OFF_TEXT (OBJFILE)))
+#define PSYMTAB_TEXTHIGH(OBJFILE, PST)					\
+  ((PST)->texthigh_							\
+   + ANOFFSET ((OBJFILE)->section_offsets, SECT_OFF_TEXT (OBJFILE)))
 
 /* Set the "textlow" field on the partial symbol table, and mark the
    field as valid.  */
@@ -288,6 +295,7 @@ extern void sort_pst_symbols (struct objfile *, struct partial_symtab *);
 extern void add_psymbol_to_list (const char *, int,
 				 int, domain_enum,
 				 enum address_class,
+				 short /* section */,
 				 struct psymbol_allocation_list *,
 				 long, CORE_ADDR,
 				 enum language, struct objfile *);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 4eaf05f..da3bcba 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -65,9 +65,6 @@ static struct partial_symbol *find_pc_sect_psymbol (struct objfile *,
 						    CORE_ADDR,
 						    struct obj_section *);
 
-static void fixup_psymbol_section (struct partial_symbol *psym,
-				   struct objfile *objfile);
-
 static struct symtab *psymtab_to_symtab (struct objfile *objfile,
 					 struct partial_symtab *pst);
 
@@ -230,7 +227,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 {
   struct partial_symtab *tpst;
   struct partial_symtab *best_pst = pst;
-  CORE_ADDR best_addr = PSYMTAB_TEXTLOW (pst);
+  CORE_ADDR best_addr = PSYMTAB_TEXTLOW (objfile, pst);
 
   gdb_assert (!pst->psymtabs_addrmap_supported);
 
@@ -254,7 +251,8 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
      that is closest and still less than the given PC.  */
   for (tpst = pst; tpst != NULL; tpst = tpst->next)
     {
-      if (pc >= PSYMTAB_TEXTLOW (tpst) && pc < PSYMTAB_TEXTHIGH (tpst))
+      if (pc >= PSYMTAB_TEXTLOW (objfile, tpst)
+	  && pc < PSYMTAB_TEXTHIGH (objfile, tpst))
 	{
 	  struct partial_symbol *p;
 	  CORE_ADDR this_addr;
@@ -276,7 +274,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 	  if (p != NULL)
 	    this_addr = PSYMBOL_VALUE_ADDRESS (objfile, p);
 	  else
-	    this_addr = PSYMTAB_TEXTLOW (tpst);
+	    this_addr = PSYMTAB_TEXTHIGH (objfile, tpst);
 
 	  /* Check whether it is closer than our current
 	     BEST_ADDR.  Since this symbol address is
@@ -308,13 +306,15 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
 		      struct bound_minimal_symbol msymbol)
 {
   struct partial_symtab *pst;
+  CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
+				 SECT_OFF_TEXT (objfile));
 
   /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
      than the later used TEXTLOW/TEXTHIGH one.  */
 
   if (objfile->psymtabs_addrmap != NULL)
     {
-      pst = addrmap_find (objfile->psymtabs_addrmap, pc);
+      pst = addrmap_find (objfile->psymtabs_addrmap, pc - baseaddr);
       if (pst != NULL)
 	{
 	  /* FIXME: addrmaps currently do not handle overlayed sections,
@@ -358,7 +358,8 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
     if (!pst->psymtabs_addrmap_supported
-	&& pc >= PSYMTAB_TEXTLOW (pst) && pc < PSYMTAB_TEXTHIGH (pst))
+	&& pc >= PSYMTAB_TEXTLOW (objfile, pst)
+	&& pc < PSYMTAB_TEXTHIGH (objfile, pst))
       {
 	struct partial_symtab *best_pst;
 
@@ -404,12 +405,14 @@ find_pc_sect_psymbol (struct objfile *objfile,
 {
   struct partial_symbol *best = NULL, *p, **pp;
   CORE_ADDR best_pc;
+  CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
+				 SECT_OFF_TEXT (objfile));
+  const CORE_ADDR textlow = PSYMTAB_TEXTLOW (objfile, psymtab);
 
   gdb_assert (psymtab != NULL);
 
   /* Cope with programs that start at address 0.  */
-  best_pc = ((PSYMTAB_TEXTLOW (psymtab) != 0)
-	     ? PSYMTAB_TEXTLOW (psymtab) - 1 : 0);
+  best_pc = (textlow != 0) ? textlow - 1 : 0;
 
   /* Search the global symbols as well as the static symbols, so that
      find_pc_partial_function doesn't use a minimal symbol and thus
@@ -424,13 +427,12 @@ find_pc_sect_psymbol (struct objfile *objfile,
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
 	  && pc >= PSYMBOL_VALUE_ADDRESS (objfile, p)
 	  && (PSYMBOL_VALUE_ADDRESS (objfile, p) > best_pc
-	      || (PSYMTAB_TEXTLOW (psymtab) == 0
+	      || (textlow == 0
 		  && best_pc == 0
 		  && PSYMBOL_VALUE_ADDRESS (objfile, p) == 0)))
 	{
 	  if (section)		/* Match on a specific section.  */
 	    {
-	      fixup_psymbol_section (p, objfile);
 	      if (!matching_obj_sections (PSYMBOL_OBJ_SECTION (objfile, p),
 					  section))
 		continue;
@@ -450,13 +452,12 @@ find_pc_sect_psymbol (struct objfile *objfile,
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
 	  && pc >= PSYMBOL_VALUE_ADDRESS (objfile, p)
 	  && (PSYMBOL_VALUE_ADDRESS (objfile, p) > best_pc
-	      || (PSYMTAB_TEXTLOW (psymtab) == 0
+	      || (textlow == 0
 		  && best_pc == 0
 		  && PSYMBOL_VALUE_ADDRESS (objfile, p) == 0)))
 	{
 	  if (section)		/* Match on a specific section.  */
 	    {
-	      fixup_psymbol_section (p, objfile);
 	      if (!matching_obj_sections (PSYMBOL_OBJ_SECTION (objfile, p),
 					  section))
 		continue;
@@ -469,35 +470,6 @@ find_pc_sect_psymbol (struct objfile *objfile,
   return best;
 }
 
-static void
-fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
-{
-  CORE_ADDR addr;
-
-  if (!psym)
-    return;
-
-  if (PSYMBOL_SECTION (psym) >= 0)
-    return;
-
-  gdb_assert (objfile);
-
-  switch (PSYMBOL_CLASS (psym))
-    {
-    case LOC_STATIC:
-    case LOC_LABEL:
-    case LOC_BLOCK:
-      addr = PSYMBOL_VALUE_ADDRESS (objfile, psym);
-      break;
-    default:
-      /* Nothing else will be listed in the minsyms -- no use looking
-	 it up.  */
-      return;
-    }
-
-  fixup_section (&psym->pginfo, addr, objfile);
-}
-
 static struct symtab *
 lookup_symbol_aux_psymtabs (struct objfile *objfile,
 			    int block_index, const char *name,
@@ -786,44 +758,6 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
   return pst->symtab;
 }
 
-static void
-relocate_psymtabs (struct objfile *objfile,
-		   const struct section_offsets *new_offsets,
-		   const struct section_offsets *delta)
-{
-  struct partial_symbol **psym;
-  struct partial_symtab *p;
-
-  ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
-    {
-      SET_PSYMTAB_TEXTLOW (p, (PSYMTAB_TEXTLOW (p)
-			       + ANOFFSET (delta, SECT_OFF_TEXT (objfile))));
-      SET_PSYMTAB_TEXTHIGH (p, (PSYMTAB_TEXTHIGH (p)
-				+ ANOFFSET (delta, SECT_OFF_TEXT (objfile))));
-    }
-
-  for (psym = objfile->global_psymbols.list;
-       psym < objfile->global_psymbols.next;
-       psym++)
-    {
-      fixup_psymbol_section (*psym, objfile);
-      if (PSYMBOL_SECTION (*psym) >= 0)
-	SET_PSYMBOL_VALUE_ADDRESS (*psym,
-				   PSYMBOL_VALUE_RAW_ADDRESS (*psym)
-				   + ANOFFSET (delta, PSYMBOL_SECTION (*psym)));
-    }
-  for (psym = objfile->static_psymbols.list;
-       psym < objfile->static_psymbols.next;
-       psym++)
-    {
-      fixup_psymbol_section (*psym, objfile);
-      if (PSYMBOL_SECTION (*psym) >= 0)
-	SET_PSYMBOL_VALUE_ADDRESS (*psym,
-				   PSYMBOL_VALUE_RAW_ADDRESS (*psym)
-				   + ANOFFSET (delta, PSYMBOL_SECTION (*psym)));
-    }
-}
-
 static struct symtab *
 find_last_source_symtab_from_partial (struct objfile *ofp)
 {
@@ -1013,9 +947,11 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
   fprintf_filtered (outfile, "\n");
 
   fprintf_filtered (outfile, "  Symbols cover text addresses ");
-  fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (psymtab)), outfile);
+  fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (objfile, psymtab)),
+		  outfile);
   fprintf_filtered (outfile, "-");
-  fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (psymtab)), outfile);
+  fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (objfile, psymtab)),
+		  outfile);
   fprintf_filtered (outfile, "\n");
   fprintf_filtered (outfile, "  Address map supported - %s.\n",
 		    psymtab->psymtabs_addrmap_supported ? "yes" : "no");
@@ -1438,7 +1374,6 @@ const struct quick_symbol_functions psym_functions =
   lookup_symbol_aux_psymtabs,
   print_psymtab_stats_for_objfile,
   dump_psymtabs_for_objfile,
-  relocate_psymtabs,
   read_symtabs_for_function,
   expand_partial_symbol_tables,
   read_psymtabs_with_fullname,
@@ -1590,6 +1525,7 @@ static const struct partial_symbol *
 add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
 		       domain_enum domain,
 		       enum address_class class,
+		       short section,
 		       long val,	/* Value as a long */
 		       CORE_ADDR coreaddr,	/* Value as a CORE_ADDR */
 		       enum language language, struct objfile *objfile,
@@ -1611,7 +1547,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
     {
       SET_PSYMBOL_VALUE_ADDRESS (&psymbol, coreaddr);
     }
-  PSYMBOL_SECTION (&psymbol) = -1;
+  PSYMBOL_SECTION (&psymbol) = section;
   PSYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
   PSYMBOL_DOMAIN (&psymbol) = domain;
   PSYMBOL_CLASS (&psymbol) = class;
@@ -1675,6 +1611,7 @@ void
 add_psymbol_to_list (const char *name, int namelength, int copy_name,
 		     domain_enum domain,
 		     enum address_class class,
+		     short section,
 		     struct psymbol_allocation_list *list, 
 		     long val,	/* Value as a long */
 		     CORE_ADDR coreaddr,	/* Value as a CORE_ADDR */
@@ -1686,7 +1623,8 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
 
   /* Stash the partial symbol away in the cache.  */
   psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, class,
-				val, coreaddr, language, objfile, &added);
+				section, val, coreaddr, language,
+				objfile, &added);
 
   /* Do not duplicate global partial symbols.  */
   if (list == &objfile->global_psymbols
@@ -1946,10 +1884,12 @@ maintenance_info_psymtabs (char *regexp, int from_tty)
 			       psymtab->fullname
 			       ? psymtab->fullname : "(null)");
 	      printf_filtered ("    text addresses ");
-	      fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (psymtab)),
+	      fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (objfile,
+								  psymtab)),
 			      gdb_stdout);
 	      printf_filtered (" -- ");
-	      fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (psymtab)),
+	      fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (objfile,
+								   psymtab)),
 			      gdb_stdout);
 	      printf_filtered ("\n");
 	      printf_filtered ("    psymtabs_addrmap_supported %s\n",
@@ -2028,14 +1968,16 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
     s = ps->symtab;
 
     /* First do some checks that don't require the associated symtab.  */
-    if (PSYMTAB_TEXTHIGH (ps) < PSYMTAB_TEXTLOW (ps))
+    if (PSYMTAB_TEXTHIGH (objfile, ps) < PSYMTAB_TEXTLOW (objfile, ps))
       {
 	printf_filtered ("Psymtab ");
 	puts_filtered (ps->filename);
 	printf_filtered (" covers bad range ");
-	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (ps)), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (objfile, ps)),
+			gdb_stdout);
 	printf_filtered (" - ");
-	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (ps)), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (objfile, ps)),
+			gdb_stdout);
 	printf_filtered ("\n");
 	continue;
       }
@@ -2078,16 +2020,18 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
 	  }
 	psym++;
       }
-    if (PSYMTAB_TEXTHIGH (ps) != 0
-	&& (PSYMTAB_TEXTLOW (ps) < BLOCK_START (b)
-	    || PSYMTAB_TEXTHIGH (ps) > BLOCK_END (b)))
+    if (PSYMTAB_RAW_TEXTHIGH (ps) != 0
+	&& (PSYMTAB_TEXTLOW (objfile, ps) < BLOCK_START (b)
+	    || PSYMTAB_TEXTHIGH (objfile, ps) > BLOCK_END (b)))
       {
 	printf_filtered ("Psymtab ");
 	puts_filtered (ps->filename);
 	printf_filtered (" covers ");
-	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (ps)), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTLOW (objfile, ps)),
+			gdb_stdout);
 	printf_filtered (" - ");
-	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (ps)), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, PSYMTAB_TEXTHIGH (objfile, ps)),
+			gdb_stdout);
 	printf_filtered (" but symtab covers only ");
 	fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout);
 	printf_filtered (" - ");
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index e8491c8..841c202 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -198,22 +198,6 @@ debug_qf_dump (struct objfile *objfile)
 }
 
 static void
-debug_qf_relocate (struct objfile *objfile,
-		   const struct section_offsets *new_offsets,
-		   const struct section_offsets *delta)
-{
-  const struct debug_sym_fns_data *debug_data =
-    objfile_data (objfile, symfile_debug_objfile_data_key);
-
-  fprintf_filtered (gdb_stdlog, "qf->relocate (%s, %s, %s)\n",
-		    debug_objfile_name (objfile),
-		    host_address_to_string (new_offsets),
-		    host_address_to_string (delta));
-
-  debug_data->real_sf->qf->relocate (objfile, new_offsets, delta);
-}
-
-static void
 debug_qf_expand_symtabs_for_function (struct objfile *objfile,
 				      const char *func_name)
 {
@@ -362,7 +346,6 @@ static const struct quick_symbol_functions debug_sym_quick_functions =
   debug_qf_lookup_symbol,
   debug_qf_print_stats,
   debug_qf_dump,
-  debug_qf_relocate,
   debug_qf_expand_symtabs_for_function,
   debug_qf_expand_all_symtabs,
   debug_qf_expand_symtabs_with_fullname,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 614af3c..36cade7 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -210,12 +210,6 @@ struct quick_symbol_functions
      gdb_stdout.  This is used for "maint print objfiles".  */
   void (*dump) (struct objfile *objfile);
 
-  /* This is called by objfile_relocate to relocate any indices loaded
-     for OBJFILE.  */
-  void (*relocate) (struct objfile *objfile,
-		    const struct section_offsets *new_offsets,
-		    const struct section_offsets *delta);
-
   /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
      the corresponding symbol tables are loaded.  */
   void (*expand_symtabs_for_function) (struct objfile *objfile,
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 2a83894..840d21c 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2347,10 +2347,10 @@ scan_xcoff_symtab (struct objfile *objfile)
 			CORE_ADDR highval =
 			  symbol.n_value + csect_aux.x_csect.x_scnlen.l;
 
-			if (highval > PSYMTAB_TEXTHIGH (pst))
+			if (highval > PSYMTAB_RAW_TEXTHIGH (pst))
 			  SET_PSYMTAB_TEXTHIGH (pst, highval);
 			if (!pst->textlow_valid
-			    || symbol.n_value < PSYMTAB_TEXTLOW (pst))
+			    || symbol.n_value < PSYMTAB_RAW_TEXTLOW (pst))
 			  SET_PSYMTAB_TEXTLOW (pst, symbol.n_value);
 		      }
 		    misc_func_recorded = 0;
@@ -2666,27 +2666,24 @@ scan_xcoff_symtab (struct objfile *objfile)
 	    switch (p[1])
 	      {
 	      case 'S':
-		symbol.n_value += ANOFFSET (objfile->section_offsets,
-					    SECT_OFF_DATA (objfile));
-
 		if (gdbarch_static_transform_name_p (gdbarch))
 		  namestring = gdbarch_static_transform_name
 				 (gdbarch, namestring);
 
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_STATIC,
+				     SECT_OFF_DATA (objfile),
 				     &objfile->static_psymbols,
 				     0, symbol.n_value,
 				     psymtab_language, objfile);
 		continue;
 
 	      case 'G':
-		symbol.n_value += ANOFFSET (objfile->section_offsets,
-					    SECT_OFF_DATA (objfile));
 		/* The addresses in these entries are reported to be
 		   wrong.  See the code that reads 'G's for symtabs.  */
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_STATIC,
+				     SECT_OFF_DATA (objfile),
 				     &objfile->global_psymbols,
 				     0, symbol.n_value,
 				     psymtab_language, objfile);
@@ -2704,7 +2701,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 			&& namestring[0] != ' '))
 		  {
 		    add_psymbol_to_list (namestring, p - namestring, 1,
-					 STRUCT_DOMAIN, LOC_TYPEDEF,
+					 STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 					 &objfile->static_psymbols,
 					 symbol.n_value, 0,
 					 psymtab_language, objfile);
@@ -2712,7 +2709,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 		      {
 			/* Also a typedef with the same name.  */
 			add_psymbol_to_list (namestring, p - namestring, 1,
-					     VAR_DOMAIN, LOC_TYPEDEF,
+					     VAR_DOMAIN, LOC_TYPEDEF, -1,
 					     &objfile->static_psymbols,
 					     symbol.n_value, 0,
 					     psymtab_language, objfile);
@@ -2725,7 +2722,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 		if (p != namestring)	/* a name is there, not just :T...  */
 		  {
 		    add_psymbol_to_list (namestring, p - namestring, 1,
-					 VAR_DOMAIN, LOC_TYPEDEF,
+					 VAR_DOMAIN, LOC_TYPEDEF, -1,
 					 &objfile->static_psymbols,
 					 symbol.n_value, 0,
 					 psymtab_language, objfile);
@@ -2788,7 +2785,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 			/* Note that the value doesn't matter for
 			   enum constants in psymtabs, just in symtabs.  */
 			add_psymbol_to_list (p, q - p, 1,
-					     VAR_DOMAIN, LOC_CONST,
+					     VAR_DOMAIN, LOC_CONST, -1,
 					     &objfile->static_psymbols, 0,
 					     0, psymtab_language, objfile);
 			/* Point past the name.  */
@@ -2806,7 +2803,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 	      case 'c':
 		/* Constant, e.g. from "const" in Pascal.  */
 		add_psymbol_to_list (namestring, p - namestring, 1,
-				     VAR_DOMAIN, LOC_CONST,
+				     VAR_DOMAIN, LOC_CONST, -1,
 				     &objfile->static_psymbols, symbol.n_value,
 				     0, psymtab_language, objfile);
 		continue;
@@ -2822,10 +2819,9 @@ scan_xcoff_symtab (struct objfile *objfile)
 		    function_outside_compilation_unit_complaint (name);
 		    xfree (name);
 		  }
-		symbol.n_value += ANOFFSET (objfile->section_offsets,
-					    SECT_OFF_TEXT (objfile));
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_BLOCK,
+				     SECT_OFF_TEXT (objfile),
 				     &objfile->static_psymbols,
 				     0, symbol.n_value,
 				     psymtab_language, objfile);
@@ -2853,10 +2849,9 @@ scan_xcoff_symtab (struct objfile *objfile)
 		if (strncmp (namestring, "@FIX", 4) == 0)
 		  continue;
 
-		symbol.n_value += ANOFFSET (objfile->section_offsets,
-					    SECT_OFF_TEXT (objfile));
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_BLOCK,
+				     SECT_OFF_TEXT (objfile),
 				     &objfile->global_psymbols,
 				     0, symbol.n_value,
 				     psymtab_language, objfile);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 3/7] change representation of psymbol to flush out accessors
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
  2014-02-20 21:32 ` [RFC 5/7] introduce accessors for psymtab high and low fields Tom Tromey
  2014-02-20 21:32 ` [RFC 4/7] make PSYMBOL_VALUE_ADDRESS take objfile argument Tom Tromey
@ 2014-02-20 21:32 ` Tom Tromey
  2014-02-20 21:32 ` [RFC 2/7] change how psymtab section offsets are handled Tom Tromey
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 21:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This is the psymbol analog to the patch to change the representation
of minimal symbols:

    https://sourceware.org/ml/gdb-patches/2013-10/msg00524.html

It has the same rationale: namely, that we're going to change the code
to apply psymbol offsets at runtime.  This will be done by adding an
argument to the SYMBOL_VALUE_ADDRESS macro -- but since we can't
convert all the symbol types at once, we need a new macro.

Also, as noted before, these macros implement a kind of "phony
polymorphism" that is not actually useful in practice.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (write_psymbols): Update.
	* psympriv.h (struct partial_symbol) <pginfo>: Rename from
	'ginfo'.
	(PSYMBOL_VALUE, PSYMBOL_VALUE_ADDRESS, PSYMBOL_LANGUAGE)
	(PSYMBOL_SECTION, PSYMBOL_OBJ_SECTION, PSYMBOL_SET_LANGUAGE)
	(PSYMBOL_SET_NAMES, PSYMBOL_LINKAGE_NAME, PSYMBOL_DEMANGLED_NAME)
	(PSYMBOL_SEARCH_NAME, PSYMBOL_MATCHES_SEARCH_NAME): New macros.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_sect_psymbol, fixup_psymbol_section)
	(match_partial_symbol, lookup_partial_symbol, relocate_psymtabs)
	(print_partial_symbols, recursively_search_psymtabs)
	(compare_psymbols, psymbol_hash, psymbol_compare)
	(add_psymbol_to_bcache, maintenance_check_psymtabs): Update.
---
 gdb/ChangeLog    |  16 ++++++++
 gdb/dwarf2read.c |   4 +-
 gdb/psympriv.h   |  25 +++++++++++-
 gdb/psymtab.c    | 116 +++++++++++++++++++++++++++----------------------------
 4 files changed, 100 insertions(+), 61 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 72662a5..019f17b 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -22123,7 +22123,7 @@ write_psymbols (struct mapped_symtab *symtab,
       struct partial_symbol *psym = *psymp;
       void **slot;
 
-      if (SYMBOL_LANGUAGE (psym) == language_ada)
+      if (PSYMBOL_LANGUAGE (psym) == language_ada)
 	error (_("Ada is not currently supported by the index"));
 
       /* Only add a given psymbol once.  */
@@ -22133,7 +22133,7 @@ write_psymbols (struct mapped_symtab *symtab,
 	  gdb_index_symbol_kind kind = symbol_kind (psym);
 
 	  *slot = psym;
-	  add_index_entry (symtab, SYMBOL_SEARCH_NAME (psym),
+	  add_index_entry (symtab, PSYMBOL_SEARCH_NAME (psym),
 			   is_static, kind, cu_index);
 	}
     }
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 57442c2..ccf3d59 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -39,7 +39,7 @@ struct partial_symbol
 
   /* The general symbol info required for all types of symbols.  */
 
-  struct general_symbol_info ginfo;
+  struct general_symbol_info pginfo;
 
   /* Name space code.  */
 
@@ -53,9 +53,32 @@ struct partial_symbol
 
 };
 
+#define PSYMBOL_VALUE(symbol)		(symbol)->pginfo.value.ivalue
+#define PSYMBOL_VALUE_ADDRESS(symbol)	(symbol)->pginfo.value.address
+#define PSYMBOL_LANGUAGE(symbol)	(symbol)->pginfo.language
+#define PSYMBOL_SECTION(symbol)		(symbol)->pginfo.section
+#define PSYMBOL_OBJ_SECTION(objfile, symbol)			\
+  (((symbol)->pginfo.section >= 0)				\
+   ? (&(((objfile)->sections)[(symbol)->pginfo.section]))	\
+   : NULL)
+
+#define PSYMBOL_SET_LANGUAGE(symbol,language,obstack)	\
+  (symbol_set_language (&(symbol)->pginfo, (language), (obstack)))
+#define PSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)	\
+  symbol_set_names (&(symbol)->pginfo, linkage_name, len, copy_name, objfile)
+
+#define PSYMBOL_LINKAGE_NAME(symbol)	(symbol)->pginfo.name
+#define PSYMBOL_DEMANGLED_NAME(symbol) \
+  (symbol_demangled_name (&(symbol)->pginfo))
+#define PSYMBOL_SEARCH_NAME(symbol)					 \
+   (symbol_search_name (&(symbol)->pginfo))
+
 #define PSYMBOL_DOMAIN(psymbol)	(psymbol)->domain
 #define PSYMBOL_CLASS(psymbol)		(psymbol)->aclass
 
+#define PSYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
+  (strcmp_iw (PSYMBOL_SEARCH_NAME (symbol), (name)) == 0)
+
 /* A convenience enum to give names to some constants used when
    searching psymtabs.  This is internal to psymtab and should not be
    used elsewhere.  */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 24faef9..fcffee6 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -265,7 +265,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 	     object's symbol table.  */
 	  p = find_pc_sect_psymbol (objfile, tpst, pc, section);
 	  if (p != NULL
-	      && SYMBOL_VALUE_ADDRESS (p)
+	      && PSYMBOL_VALUE_ADDRESS (p)
 	      == BMSYMBOL_VALUE_ADDRESS (msymbol))
 	    return tpst;
 
@@ -274,7 +274,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
 	     symbol tables with line information but no debug
 	     symbols (e.g. those produced by an assembler).  */
 	  if (p != NULL)
-	    this_addr = SYMBOL_VALUE_ADDRESS (p);
+	    this_addr = PSYMBOL_VALUE_ADDRESS (p);
 	  else
 	    this_addr = tpst->textlow;
 
@@ -330,7 +330,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
 		 object's symbol table.  */
 	      p = find_pc_sect_psymbol (objfile, pst, pc, section);
 	      if (!p
-		  || SYMBOL_VALUE_ADDRESS (p)
+		  || PSYMBOL_VALUE_ADDRESS (p)
 		  != BMSYMBOL_VALUE_ADDRESS (msymbol))
 		goto next;
 	    }
@@ -421,19 +421,19 @@ find_pc_sect_psymbol (struct objfile *objfile,
       p = *pp;
       if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
-	  && pc >= SYMBOL_VALUE_ADDRESS (p)
-	  && (SYMBOL_VALUE_ADDRESS (p) > best_pc
+	  && pc >= PSYMBOL_VALUE_ADDRESS (p)
+	  && (PSYMBOL_VALUE_ADDRESS (p) > best_pc
 	      || (psymtab->textlow == 0
-		  && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0)))
+		  && best_pc == 0 && PSYMBOL_VALUE_ADDRESS (p) == 0)))
 	{
 	  if (section)		/* Match on a specific section.  */
 	    {
 	      fixup_psymbol_section (p, objfile);
-	      if (!matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, p),
+	      if (!matching_obj_sections (PSYMBOL_OBJ_SECTION (objfile, p),
 					  section))
 		continue;
 	    }
-	  best_pc = SYMBOL_VALUE_ADDRESS (p);
+	  best_pc = PSYMBOL_VALUE_ADDRESS (p);
 	  best = p;
 	}
     }
@@ -446,19 +446,19 @@ find_pc_sect_psymbol (struct objfile *objfile,
       p = *pp;
       if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
-	  && pc >= SYMBOL_VALUE_ADDRESS (p)
-	  && (SYMBOL_VALUE_ADDRESS (p) > best_pc
+	  && pc >= PSYMBOL_VALUE_ADDRESS (p)
+	  && (PSYMBOL_VALUE_ADDRESS (p) > best_pc
 	      || (psymtab->textlow == 0
-		  && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0)))
+		  && best_pc == 0 && PSYMBOL_VALUE_ADDRESS (p) == 0)))
 	{
 	  if (section)		/* Match on a specific section.  */
 	    {
 	      fixup_psymbol_section (p, objfile);
-	      if (!matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, p),
+	      if (!matching_obj_sections (PSYMBOL_OBJ_SECTION (objfile, p),
 					  section))
 		continue;
 	    }
-	  best_pc = SYMBOL_VALUE_ADDRESS (p);
+	  best_pc = PSYMBOL_VALUE_ADDRESS (p);
 	  best = p;
 	}
     }
@@ -474,7 +474,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
   if (!psym)
     return;
 
-  if (SYMBOL_SECTION (psym) >= 0)
+  if (PSYMBOL_SECTION (psym) >= 0)
     return;
 
   gdb_assert (objfile);
@@ -484,7 +484,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
     case LOC_STATIC:
     case LOC_LABEL:
     case LOC_BLOCK:
-      addr = SYMBOL_VALUE_ADDRESS (psym);
+      addr = PSYMBOL_VALUE_ADDRESS (psym);
       break;
     default:
       /* Nothing else will be listed in the minsyms -- no use looking
@@ -492,7 +492,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
       return;
     }
 
-  fixup_section (&psym->ginfo, addr, objfile);
+  fixup_section (&psym->pginfo, addr, objfile);
 }
 
 static struct symtab *
@@ -582,9 +582,9 @@ match_partial_symbol (struct objfile *objfile,
 	  center = bottom + (top - bottom) / 2;
 	  gdb_assert (center < top);
 	  if (!do_linear_search
-	      && (SYMBOL_LANGUAGE (*center) == language_java))
+	      && (PSYMBOL_LANGUAGE (*center) == language_java))
 	    do_linear_search = 1;
-	  if (ordered_compare (SYMBOL_SEARCH_NAME (*center), name) >= 0)
+	  if (ordered_compare (PSYMBOL_SEARCH_NAME (*center), name) >= 0)
 	    top = center;
 	  else
 	    bottom = center + 1;
@@ -592,9 +592,9 @@ match_partial_symbol (struct objfile *objfile,
       gdb_assert (top == bottom);
 
       while (top <= real_top
-	     && match (SYMBOL_SEARCH_NAME (*top), name) == 0)
+	     && match (PSYMBOL_SEARCH_NAME (*top), name) == 0)
 	{
-	  if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
+	  if (symbol_matches_domain (PSYMBOL_LANGUAGE (*top),
 				     SYMBOL_DOMAIN (*top), domain))
 	    return *top;
 	  top++;
@@ -608,9 +608,9 @@ match_partial_symbol (struct objfile *objfile,
     {
       for (psym = start; psym < start + length; psym++)
 	{
-	  if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
+	  if (symbol_matches_domain (PSYMBOL_LANGUAGE (*psym),
 				     SYMBOL_DOMAIN (*psym), domain)
-	      && match (SYMBOL_SEARCH_NAME (*psym), name) == 0)
+	      && match (PSYMBOL_SEARCH_NAME (*psym), name) == 0)
 	    return *psym;
 	}
     }
@@ -697,11 +697,11 @@ lookup_partial_symbol (struct objfile *objfile,
 	    internal_error (__FILE__, __LINE__,
 			    _("failed internal consistency check"));
 	  if (!do_linear_search
-	      && SYMBOL_LANGUAGE (*center) == language_java)
+	      && PSYMBOL_LANGUAGE (*center) == language_java)
 	    {
 	      do_linear_search = 1;
 	    }
-	  if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center),
+	  if (strcmp_iw_ordered (PSYMBOL_SEARCH_NAME (*center),
 				 search_name) >= 0)
 	    {
 	      top = center;
@@ -717,15 +717,15 @@ lookup_partial_symbol (struct objfile *objfile,
 
       /* For `case_sensitivity == case_sensitive_off' strcmp_iw_ordered will
 	 search more exactly than what matches SYMBOL_MATCHES_SEARCH_NAME.  */
-      while (top >= start && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
+      while (top >= start && PSYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
 	top--;
 
       /* Fixup to have a symbol which matches SYMBOL_MATCHES_SEARCH_NAME.  */
       top++;
 
-      while (top <= real_top && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
+      while (top <= real_top && PSYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
 	{
-	  if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
+	  if (symbol_matches_domain (PSYMBOL_LANGUAGE (*top),
 				     SYMBOL_DOMAIN (*top), domain))
 	    {
 	      do_cleanups (cleanup);
@@ -742,9 +742,9 @@ lookup_partial_symbol (struct objfile *objfile,
     {
       for (psym = start; psym < start + length; psym++)
 	{
-	  if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
+	  if (symbol_matches_domain (PSYMBOL_LANGUAGE (*psym),
 				     SYMBOL_DOMAIN (*psym), domain)
-	      && SYMBOL_MATCHES_SEARCH_NAME (*psym, search_name))
+	      && PSYMBOL_MATCHES_SEARCH_NAME (*psym, search_name))
 	    {
 	      do_cleanups (cleanup);
 	      return (*psym);
@@ -802,18 +802,18 @@ relocate_psymtabs (struct objfile *objfile,
        psym++)
     {
       fixup_psymbol_section (*psym, objfile);
-      if (SYMBOL_SECTION (*psym) >= 0)
-	SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
-						  SYMBOL_SECTION (*psym));
+      if (PSYMBOL_SECTION (*psym) >= 0)
+	PSYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
+						   PSYMBOL_SECTION (*psym));
     }
   for (psym = objfile->static_psymbols.list;
        psym < objfile->static_psymbols.next;
        psym++)
     {
       fixup_psymbol_section (*psym, objfile);
-      if (SYMBOL_SECTION (*psym) >= 0)
-	SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
-						  SYMBOL_SECTION (*psym));
+      if (PSYMBOL_SECTION (*psym) >= 0)
+	PSYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
+						   PSYMBOL_SECTION (*psym));
     }
 }
 
@@ -871,10 +871,10 @@ print_partial_symbols (struct gdbarch *gdbarch,
   while (count-- > 0)
     {
       QUIT;
-      fprintf_filtered (outfile, "    `%s'", SYMBOL_LINKAGE_NAME (*p));
-      if (SYMBOL_DEMANGLED_NAME (*p) != NULL)
+      fprintf_filtered (outfile, "    `%s'", PSYMBOL_LINKAGE_NAME (*p));
+      if (PSYMBOL_DEMANGLED_NAME (*p) != NULL)
 	{
-	  fprintf_filtered (outfile, "  `%s'", SYMBOL_DEMANGLED_NAME (*p));
+	  fprintf_filtered (outfile, "  `%s'", PSYMBOL_DEMANGLED_NAME (*p));
 	}
       fputs_filtered (", ", outfile);
       switch (SYMBOL_DOMAIN (*p))
@@ -947,7 +947,7 @@ print_partial_symbols (struct gdbarch *gdbarch,
 	  break;
 	}
       fputs_filtered (", ", outfile);
-      fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (*p)), outfile);
+      fputs_filtered (paddress (gdbarch, PSYMBOL_VALUE_ADDRESS (*p)), outfile);
       fprintf_filtered (outfile, "\n");
       p++;
     }
@@ -1348,7 +1348,7 @@ recursively_search_psymtabs (struct partial_symtab *ps,
 		   && PSYMBOL_CLASS (*psym) == LOC_BLOCK)
 	       || (kind == TYPES_DOMAIN
 		   && PSYMBOL_CLASS (*psym) == LOC_TYPEDEF))
-	      && (*sym_matcher) (SYMBOL_SEARCH_NAME (*psym), data))
+	      && (*sym_matcher) (PSYMBOL_SEARCH_NAME (*psym), data))
 	    {
 	      /* Found a match, so notify our caller.  */
 	      result = PST_SEARCHED_AND_FOUND;
@@ -1449,8 +1449,8 @@ compare_psymbols (const void *s1p, const void *s2p)
   struct partial_symbol *const *s1 = s1p;
   struct partial_symbol *const *s2 = s2p;
 
-  return strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*s1),
-			    SYMBOL_SEARCH_NAME (*s2));
+  return strcmp_iw_ordered (PSYMBOL_SEARCH_NAME (*s1),
+			    PSYMBOL_SEARCH_NAME (*s2));
 }
 
 void
@@ -1494,15 +1494,15 @@ psymbol_hash (const void *addr, int length)
 {
   unsigned long h = 0;
   struct partial_symbol *psymbol = (struct partial_symbol *) addr;
-  unsigned int lang = psymbol->ginfo.language;
+  unsigned int lang = PSYMBOL_LANGUAGE (psymbol);
   unsigned int domain = PSYMBOL_DOMAIN (psymbol);
   unsigned int class = PSYMBOL_CLASS (psymbol);
 
-  h = hash_continue (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value), h);
+  h = hash_continue (&psymbol->pginfo.value, sizeof (psymbol->pginfo.value), h);
   h = hash_continue (&lang, sizeof (unsigned int), h);
   h = hash_continue (&domain, sizeof (unsigned int), h);
   h = hash_continue (&class, sizeof (unsigned int), h);
-  h = hash_continue (psymbol->ginfo.name, strlen (psymbol->ginfo.name), h);
+  h = hash_continue (psymbol->pginfo.name, strlen (psymbol->pginfo.name), h);
 
   return h;
 }
@@ -1517,12 +1517,12 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
   struct partial_symbol *sym1 = (struct partial_symbol *) addr1;
   struct partial_symbol *sym2 = (struct partial_symbol *) addr2;
 
-  return (memcmp (&sym1->ginfo.value, &sym1->ginfo.value,
-                  sizeof (sym1->ginfo.value)) == 0
-	  && sym1->ginfo.language == sym2->ginfo.language
+  return (memcmp (&sym1->pginfo.value, &sym1->pginfo.value,
+                  sizeof (sym1->pginfo.value)) == 0
+	  && sym1->pginfo.language == sym2->pginfo.language
           && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
           && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
-          && sym1->ginfo.name == sym2->ginfo.name);
+          && sym1->pginfo.name == sym2->pginfo.name);
 }
 
 /* Initialize a partial symbol bcache.  */
@@ -1595,18 +1595,18 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
   /* val and coreaddr are mutually exclusive, one of them *will* be zero.  */
   if (val != 0)
     {
-      SYMBOL_VALUE (&psymbol) = val;
+      PSYMBOL_VALUE (&psymbol) = val;
     }
   else
     {
-      SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
+      PSYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
     }
-  SYMBOL_SECTION (&psymbol) = -1;
-  SYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
+  PSYMBOL_SECTION (&psymbol) = -1;
+  PSYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
   PSYMBOL_DOMAIN (&psymbol) = domain;
   PSYMBOL_CLASS (&psymbol) = class;
 
-  SYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile);
+  PSYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile);
 
   /* Stash the partial symbol away in the cache.  */
   return psymbol_bcache_full (&psymbol,
@@ -2039,12 +2039,12 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
     length = ps->n_static_syms;
     while (length--)
       {
-	sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
+	sym = lookup_block_symbol (b, PSYMBOL_LINKAGE_NAME (*psym),
 				   SYMBOL_DOMAIN (*psym));
 	if (!sym)
 	  {
 	    printf_filtered ("Static symbol `");
-	    puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
+	    puts_filtered (PSYMBOL_LINKAGE_NAME (*psym));
 	    printf_filtered ("' only found in ");
 	    puts_filtered (ps->filename);
 	    printf_filtered (" psymtab\n");
@@ -2056,12 +2056,12 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
     length = ps->n_global_syms;
     while (length--)
       {
-	sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
+	sym = lookup_block_symbol (b, PSYMBOL_LINKAGE_NAME (*psym),
 				   SYMBOL_DOMAIN (*psym));
 	if (!sym)
 	  {
 	    printf_filtered ("Global symbol `");
-	    puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
+	    puts_filtered (PSYMBOL_LINKAGE_NAME (*psym));
 	    printf_filtered ("' only found in ");
 	    puts_filtered (ps->filename);
 	    printf_filtered (" psymtab\n");
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 6/7] add validity bits for psymtab high and low fields
  2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
                   ` (5 preceding siblings ...)
  2014-02-20 21:32 ` [RFC 1/7] remove dead code in end_psymtab Tom Tromey
@ 2014-02-20 22:08 ` Tom Tromey
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-02-20 22:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Right now some psymtab code checks whether a psymtab's textlow or
texthigh fields are valid by comparing against 0.

I imagine this is mildly wrong in the current environment, but once
psymtabs are relocated dynamically, it will no longer be correct,
because it will be much more normal to see a psymtab with a textlow of
zero -- this will just mean it covers the start of the text section.

This patch introduces validity bits to handle this situation more
nicely, and changes users of the code to follow.

2014-02-20  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (end_psymtab): Use texthigh_valid and textlow_valid.
	* mdebugread.c (parse_partial_symbols): Use textlow_valid.
	(psymtab_to_symtab_1): Use texthigh_valid and textlow_valid.
	* psympriv.h (struct partial_symtab) <textlow_, texthigh_>: Update
	comment.
	<textlow_valid, texthigh_valid>: New fields.
	(set_psymtab_textlow, set_psymtab_texthigh): New inline functions.
	(SET_PSYMTAB_TEXTLOW, SET_PSYMTAB_TEXTHIGH): Redefine.
	* xcoffread.c (scan_xcoff_symtab): Use textlow_valid.
---
 gdb/ChangeLog    | 12 ++++++++++++
 gdb/dbxread.c    |  6 ++----
 gdb/mdebugread.c |  8 ++++----
 gdb/psympriv.h   | 33 ++++++++++++++++++++++++++++++---
 gdb/xcoffread.c  |  2 +-
 5 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 66c4071..bdb81ce 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2284,13 +2284,11 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       /* If we know our own starting text address, then walk through all other
          psymtabs for this objfile, and if any didn't know their ending text
          address, set it to our starting address.  Take care to not set our
-         own ending address to our starting address, nor to set addresses on
-         `dependency' files that have both textlow and texthigh zero.  */
+         own ending address to our starting address.  */
 
       ALL_OBJFILE_PSYMTABS (objfile, p1)
       {
-	if (PSYMTAB_TEXTHIGH (p1) == 0 && PSYMTAB_TEXTLOW (p1) != 0
-	    && p1 != pst)
+	if (!p1->texthigh_valid && p1->textlow_valid && p1 != pst)
 	  SET_PSYMTAB_TEXTHIGH (p1, PSYMTAB_TEXTLOW (pst));
       }
     }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index b9a68c0..2cc9be4 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2760,7 +2760,7 @@ parse_partial_symbols (struct objfile *objfile)
 
 			  /* Kludge for Irix 5.2 zero fh->adr.  */
 			  if (!relocatable
-			      && (PSYMTAB_TEXTLOW (pst) == 0
+			      && (!pst->textlow_valid
 				  || procaddr < PSYMTAB_TEXTLOW (pst)))
 			    SET_PSYMTAB_TEXTLOW (pst, procaddr);
 			  if (high > PSYMTAB_TEXTHIGH (pst))
@@ -3558,7 +3558,7 @@ parse_partial_symbols (struct objfile *objfile)
 
 		  /* Kludge for Irix 5.2 zero fh->adr.  */
 		  if (!relocatable
-		      && (PSYMTAB_TEXTLOW (pst) == 0
+		      && (!pst->textlow_valid
 			  || procaddr < PSYMTAB_TEXTLOW (pst)))
 		    SET_PSYMTAB_TEXTLOW (pst, procaddr);
 
@@ -3759,7 +3759,7 @@ parse_partial_symbols (struct objfile *objfile)
          other cases.  */
       save_pst = fdr_to_pst[f_idx].pst;
       if (save_pst != NULL
-	  && PSYMTAB_TEXTLOW (save_pst) != 0
+	  && save_pst->textlow_valid
 	  && !(objfile->flags & OBJF_REORDERED))
 	{
 	  ALL_OBJFILE_PSYMTABS (objfile, pst)
@@ -3973,7 +3973,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
   /* Do nothing if this is a dummy psymtab.  */
 
   if (pst->n_global_syms == 0 && pst->n_static_syms == 0
-      && PSYMTAB_TEXTLOW (pst) == 0 && PSYMTAB_TEXTHIGH (pst) == 0)
+      && !pst->textlow_valid && !pst->texthigh_valid)
     return;
 
   /* Now read the symbols for this symtab.  */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 1824bdd..6d732d6 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -137,7 +137,9 @@ struct partial_symtab
   /* Range of text addresses covered by this file; texthigh is the
      beginning of the next section.  Do not use if PSYMTABS_ADDRMAP_SUPPORTED
      is set.  Do not refer directly to these fields.  Instead, use the
-     accessor macros.  */
+     accessor macros.  The validity of these fields is determined by the
+     textlow_valid and texthigh_valid fields; these are located later
+     in this structure for better packing.  */
 
   CORE_ADDR textlow_;
   CORE_ADDR texthigh_;
@@ -223,6 +225,11 @@ struct partial_symtab
 
   ENUM_BITFIELD (psymtab_search_status) searched_flag : 2;
 
+  /* Validity of the textlow_ and texthigh_ fields.  */
+
+  unsigned int textlow_valid : 1;
+  unsigned int texthigh_valid : 1;
+
   /* Pointer to symtab eventually allocated for this source file, 0 if
      !readin or if we haven't looked for the symtab after it was readin.  */
 
@@ -251,8 +258,28 @@ struct partial_symtab
 #define PSYMTAB_TEXTLOW(PST) ((PST)->textlow_ + 0)
 #define PSYMTAB_TEXTHIGH(PST) ((PST)->texthigh_ + 0)
 
-#define SET_PSYMTAB_TEXTLOW(PST, V) (((PST)->textlow_) = (V))
-#define SET_PSYMTAB_TEXTHIGH(PST, V) (((PST)->texthigh_) = (V))
+/* Set the "textlow" field on the partial symbol table, and mark the
+   field as valid.  */
+
+static inline void
+set_psymtab_textlow (struct partial_symtab *pst, CORE_ADDR low)
+{
+  pst->textlow_ = low;
+  pst->textlow_valid = 1;
+}
+
+/* Set the "texthigh" field on the partial symbol table, and mark the
+   field as valid.  */
+
+static inline void
+set_psymtab_texthigh (struct partial_symtab *pst, CORE_ADDR high)
+{
+  pst->texthigh_ = high;
+  pst->texthigh_valid = 1;
+}
+
+#define SET_PSYMTAB_TEXTLOW(PST, V) set_psymtab_textlow ((PST), (V))
+#define SET_PSYMTAB_TEXTHIGH(PST, V) set_psymtab_texthigh ((PST), (V))
 
 extern void sort_pst_symbols (struct objfile *, struct partial_symtab *);
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 13b4284..2a83894 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2349,7 +2349,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 
 			if (highval > PSYMTAB_TEXTHIGH (pst))
 			  SET_PSYMTAB_TEXTHIGH (pst, highval);
-			if (PSYMTAB_TEXTLOW (pst) == 0
+			if (!pst->textlow_valid
 			    || symbol.n_value < PSYMTAB_TEXTLOW (pst))
 			  SET_PSYMTAB_TEXTLOW (pst, symbol.n_value);
 		      }
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-02-20 22:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20 21:32 [RFC 0/7] make psymbols independent of progspace Tom Tromey
2014-02-20 21:32 ` [RFC 5/7] introduce accessors for psymtab high and low fields Tom Tromey
2014-02-20 21:32 ` [RFC 4/7] make PSYMBOL_VALUE_ADDRESS take objfile argument Tom Tromey
2014-02-20 21:32 ` [RFC 3/7] change representation of psymbol to flush out accessors Tom Tromey
2014-02-20 21:32 ` [RFC 2/7] change how psymtab section offsets are handled Tom Tromey
2014-02-20 21:32 ` [RFC 7/7] make psymbols and psymtabs independent of the program space Tom Tromey
2014-02-20 21:32 ` [RFC 1/7] remove dead code in end_psymtab Tom Tromey
2014-02-20 22:08 ` [RFC 6/7] add validity bits for psymtab high and low fields Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).