Patchwork [RFA,v3,4/6] Introduce accessors for psymtab high and low fields

login
register
mail settings
Submitter Tom Tromey
Date June 7, 2018, 4:19 p.m.
Message ID <20180607161955.9800-5-tom@tromey.com>
Download mbox | patch
Permalink /patch/27695/
State New
Headers show

Comments

Tom Tromey - June 7, 2018, 4:19 p.m.
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.

I looked at making the fields private, but this interferes with the
memset in allocate_psymtab, and I didn't want to chase this down.
This conversion can be done later if need be.

gdb/ChangeLog
2018-06-07  Tom Tromey  <tom@tromey.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, dwarf2_build_include_psymtabs):
	Update.
	* mdebugread.c (parse_lines, parse_partial_symbols)
	(psymtab_to_symtab_1): Update.
	* psympriv.h (struct partial_symtab) <m_textlow, m_texthigh>: Rename
	fields.  Update comment.  Now private.
	<text_low, text_high, set_text_low, set_text_high>: New methods.
	* 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    | 66 ++++++++++++++++++++++++++++----------------------------
 gdb/dwarf2read.c | 16 +++++++-------
 gdb/mdebugread.c | 46 ++++++++++++++++++++-------------------
 gdb/psympriv.h   | 39 ++++++++++++++++++++++++++++++---
 gdb/psymtab.c    | 48 ++++++++++++++++++++++-------------------
 gdb/xcoffread.c  | 11 +++++-----
 7 files changed, 153 insertions(+), 94 deletions(-)
Simon Marchi - July 17, 2018, 4:11 p.m.
Hi Tom,

There are some stale references to PSYMTAB_TEXTHIGH.  Just some really tiny
nits, but otherwise it LGTM.

On 2018-06-07 12:19 PM, Tom Tromey wrote:
> diff --git a/gdb/psympriv.h b/gdb/psympriv.h
> index ec2d9923c1b..c1f1defd58c 100644
> --- a/gdb/psympriv.h
> +++ b/gdb/psympriv.h
> @@ -98,6 +98,31 @@ enum psymtab_search_status
>  
>  struct partial_symtab
>  {
> +  /* Return the low text address of this partial_symtab.  */
> +  CORE_ADDR text_low () const
> +  {
> +    return m_textlow;
> +  }
> +
> +  /* Return the high text address of this partial_symtab.  */
> +  CORE_ADDR text_high () const
> +  {
> +    return m_texthigh;
> +  }
> +
> +  /* Set the low text address of this partial_symtab.  */
> +  void set_text_low (CORE_ADDR addr)
> +  {
> +    m_textlow = addr;
> +  }
> +
> +  /* Set the hight text address of this partial_symtab.  */
> +  void set_text_high (CORE_ADDR addr)
> +  {
> +    m_texthigh = addr;
> +  }

I am mildly bothered by the inconsistent naming :).  Can you rename
m_texthigh -> m_text_high (and same for low) so it matches the
accessors?

> @@ -222,6 +248,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))))
> +

This is not needed I think.

Simon

Patch

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 4092d1cab74..e011b5cf417 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1137,12 +1137,12 @@  read_dbx_symtab (minimal_symbol_reader &reader, 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 >= pst->text_low ())
 		{
 		  dbx_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 > pst->text_high ()
+				   ? nlist.n_value : pst->text_high (),
 				   dependency_list, dependencies_used,
 				   textlow_not_set);
 		  pst = (struct partial_symtab *) 0;
@@ -1257,8 +1257,8 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 		  {
 		    dbx_end_psymtab (objfile, pst, psymtab_include_list,
 				     includes_used, symnum * symbol_size,
-				     valu > pst->texthigh
-				     ? valu : pst->texthigh,
+				     (valu > pst->text_high ()
+				      ? valu : pst->text_high ()),
 				     dependency_list, dependencies_used,
 				     prev_textlow_not_set);
 		    pst = (struct partial_symtab *) 0;
@@ -1432,8 +1432,8 @@  read_dbx_symtab (minimal_symbol_reader &reader, 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 (pst->text_high () == 0 || valu > pst->text_high ())
+		pst->set_text_high (valu);
 	      break;
 	    }
 
@@ -1647,7 +1647,7 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      if (pst && textlow_not_set
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
-		  pst->textlow = nlist.n_value;
+		  pst->set_text_low (nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      /* End kludge.  */
@@ -1662,12 +1662,12 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 		 the partial symbol table.  */
 	      if (pst
 		  && (textlow_not_set
-		      || (nlist.n_value < pst->textlow
+		      || (nlist.n_value < pst->text_low ()
 			  && (nlist.n_value
 			      != ANOFFSET (objfile->section_offsets,
 					   SECT_OFF_TEXT (objfile))))))
 		{
-		  pst->textlow = nlist.n_value;
+		  pst->set_text_low (nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      add_psymbol_to_list (sym_name, sym_len, 1,
@@ -1716,7 +1716,7 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      if (pst && textlow_not_set
 		  && gdbarch_sofun_address_maybe_missing (gdbarch))
 		{
-		  pst->textlow = nlist.n_value;
+		  pst->set_text_low (nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      /* End kludge.  */
@@ -1731,12 +1731,12 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 		 the partial symbol table.  */
 	      if (pst
 		  && (textlow_not_set
-		      || (nlist.n_value < pst->textlow
+		      || (nlist.n_value < pst->text_low ()
 			  && (nlist.n_value
 			      != ANOFFSET (objfile->section_offsets,
 					   SECT_OFF_TEXT (objfile))))))
 		{
-		  pst->textlow = nlist.n_value;
+		  pst->set_text_low (nlist.n_value);
 		  textlow_not_set = 0;
 		}
 	      add_psymbol_to_list (sym_name, sym_len, 1,
@@ -1848,10 +1848,10 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	  continue;
 
 	case N_ENDM:
-	  /* Solaris 2 end of module, finish current partial symbol table.
-	     dbx_end_psymtab will set pst->texthigh to the proper value, which
-	     is necessary if a module compiled without debugging info
-	     follows this module.  */
+	  /* Solaris 2 end of module, finish current partial symbol
+	     table.  dbx_end_psymtab will set PSYMTAB_TEXTHIGH(pst) to
+	     the proper value, which is necessary if a module compiled
+	     without debugging info follows this module.  */
 	  if (pst && gdbarch_sofun_address_maybe_missing (gdbarch))
 	    {
 	      dbx_end_psymtab (objfile, pst,
@@ -1912,7 +1912,7 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
   /* If there's stuff to be cleaned up, clean it up.  */
   if (pst)
     {
-      /* Don't set pst->texthigh lower than it already is.  */
+      /* Don't set PSYMTAB_TEXTHIGH(pst) lower than it already is.  */
       CORE_ADDR text_end =
 	(lowest_text_address == (CORE_ADDR) -1
 	 ? (text_addr + ANOFFSET (objfile->section_offsets,
@@ -1922,7 +1922,8 @@  read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 
       dbx_end_psymtab (objfile, pst, psymtab_include_list, includes_used,
 		       symnum * symbol_size,
-		       text_end > pst->texthigh ? text_end : pst->texthigh,
+		       (text_end > pst->text_high ()
+			? text_end : pst->text_high ()),
 		       dependency_list, dependencies_used, textlow_not_set);
     }
 }
@@ -1977,7 +1978,7 @@  dbx_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;
+  pst->set_text_high (capping_text);
 
   /* Under Solaris, the N_SO symbols always have a value of 0,
      instead of the usual address of the .o file.  Therefore,
@@ -1994,7 +1995,7 @@  dbx_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 (pst->text_high () == 0 && last_function_name
       && gdbarch_sofun_address_maybe_missing (gdbarch))
     {
       int n;
@@ -2021,8 +2022,8 @@  dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 	}
 
       if (minsym.minsym)
-	pst->texthigh = (BMSYMBOL_VALUE_ADDRESS (minsym)
-			 + MSYMBOL_SIZE (minsym.minsym));
+	pst->set_text_high (BMSYMBOL_VALUE_ADDRESS (minsym)
+			    + MSYMBOL_SIZE (minsym.minsym));
 
       last_function_name = NULL;
     }
@@ -2031,7 +2032,7 @@  dbx_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;
+    pst->set_text_low (pst->text_high ());
   else
     {
       struct partial_symtab *p1;
@@ -2044,8 +2045,9 @@  dbx_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 (p1->text_high () == 0 && p1->text_low () != 0
+	    && p1 != pst)
+	  p1->set_text_high (pst->text_low ());
       }
     }
 
@@ -2073,9 +2075,7 @@  dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->read_symtab_private =
 	XOBNEW (&objfile->objfile_obstack, 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.  */
@@ -2234,8 +2234,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 = pst->text_low ();
+  text_size = pst->text_high () - pst->text_low ();
   section_offsets = objfile->section_offsets;
 
   dbxread_objfile = objfile;
@@ -2364,13 +2364,13 @@  read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
 
   /* In a Solaris elf file, this variable, which comes from the
      value of the N_SO symbol, will still be 0.  Luckily, text_offset,
-     which comes from pst->textlow is correct.  */
+     which comes from PSYMTAB_TEXTLOW(pst) is correct.  */
   if (last_source_start_addr == 0)
     last_source_start_addr = text_offset;
 
   /* In reordered executables last_source_start_addr may not be the
      lower bound for this symtab, instead use text_offset which comes
-     from pst->textlow which is correct.  */
+     from PSYMTAB_TEXTLOW(pst) which is correct.  */
   if (last_source_start_addr > text_offset)
     last_source_start_addr = text_offset;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 1cabfbb0d45..d29ff8b9bb8 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6503,9 +6503,6 @@  dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
       subpst->dirname = pst->dirname;
     }
 
-  subpst->textlow = 0;
-  subpst->texthigh = 0;
-
   subpst->dependencies
     = XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
   subpst->dependencies[0] = pst;
@@ -6544,7 +6541,8 @@  dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
     return;  /* No linetable, so no includes.  */
 
   /* NOTE: pst->dirname is DW_AT_comp_dir (if present).  */
-  dwarf_decode_lines (lh.get (), pst->dirname, cu, pst, pst->textlow, 1);
+  dwarf_decode_lines (lh.get (), pst->dirname, cu, pst,
+		      pst->text_low (), 1);
 }
 
 static hashval_t
@@ -7968,8 +7966,10 @@  process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 	  best_highpc = highpc;
 	}
     }
-  pst->textlow = gdbarch_adjust_dwarf2_addr (gdbarch, best_lowpc + baseaddr);
-  pst->texthigh = gdbarch_adjust_dwarf2_addr (gdbarch, best_highpc + baseaddr);
+  pst->set_text_low (gdbarch_adjust_dwarf2_addr (gdbarch,
+						 best_lowpc + baseaddr));
+  pst->set_text_high (gdbarch_adjust_dwarf2_addr (gdbarch,
+						  best_highpc + baseaddr));
 
   end_psymtab_common (objfile, pst);
 
@@ -8006,8 +8006,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",
 			  sect_offset_str (per_cu->sect_off),
-			  paddress (gdbarch, pst->textlow),
-			  paddress (gdbarch, pst->texthigh),
+			  paddress (gdbarch, pst->text_low ()),
+			  paddress (gdbarch, pst->text_high ()),
 			  pst->n_global_syms, pst->n_static_syms);
     }
 }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 98f10b465e5..2699cb99b19 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2197,7 +2197,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 = pst->text_low () + pr->adr - lowest_pdr_addr;
 
       l = adr >> 2;		/* in words */
       for (lineno = pr->lnLow; base < halt;)
@@ -2672,7 +2672,7 @@  parse_partial_symbols (minimal_symbol_reader &reader,
 	psymtab_language = prev_language;
       PST_PRIVATE (pst)->pst_language = psymtab_language;
 
-      pst->texthigh = pst->textlow;
+      pst->set_text_high (pst->text_low ());
 
       /* For stabs-in-ecoff files, the second symbol must be @stab.
          This symbol is emitted by mips-tfile to signal that the
@@ -2737,10 +2737,11 @@  parse_partial_symbols (minimal_symbol_reader &reader,
 
 			  /* 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;
+			      && (pst->text_low () == 0
+				  || procaddr < pst->text_low ()))
+			    pst->set_text_low (procaddr);
+			  if (high > pst->text_high ())
+			    pst->set_text_high (high);
 			}
 		    }
 		  else if (sh.st == stStatic)
@@ -3310,8 +3311,8 @@  parse_partial_symbols (minimal_symbol_reader &reader,
 		  case N_ENDM:
 		    /* Solaris 2 end of module, finish current partial
 		       symbol table.  dbx_end_psymtab will set
-		       pst->texthigh to the proper value, which is
-		       necessary if a module compiled without
+		       PSYMTAB_TEXTHIGH(pst) to the proper value,
+		       which is necessary if a module compiled without
 		       debugging info follows this module.  */
 		    if (pst
 			&& gdbarch_sofun_address_maybe_missing (gdbarch))
@@ -3323,8 +3324,8 @@  parse_partial_symbols (minimal_symbol_reader &reader,
 		    continue;
 
 		  case N_RBRAC:
-		    if (sh.value > save_pst->texthigh)
-		      save_pst->texthigh = sh.value;
+		    if (sh.value > save_pst->text_high ())
+		      save_pst->set_text_high (sh.value);
 		    continue;
 		  case N_EINCL:
 		  case N_DSLINE:
@@ -3512,12 +3513,13 @@  parse_partial_symbols (minimal_symbol_reader &reader,
 
 		  /* Kludge for Irix 5.2 zero fh->adr.  */
 		  if (!relocatable
-		      && (pst->textlow == 0 || procaddr < pst->textlow))
-		    pst->textlow = procaddr;
+		      && (pst->text_low () == 0
+			  || procaddr < pst->text_low ()))
+		    pst->set_text_low (procaddr);
 
 		  high = procaddr + sh.value;
-		  if (high > pst->texthigh)
-		    pst->texthigh = high;
+		  if (high > pst->text_high ())
+		    pst->set_text_high (high);
 		  continue;
 
 		case stStatic:	/* Variable */
@@ -3691,7 +3693,7 @@  parse_partial_symbols (minimal_symbol_reader &reader,
       fdr_to_pst[f_idx].pst
 	= dbx_end_psymtab (objfile, save_pst,
 			   psymtab_include_list, includes_used,
-			   -1, save_pst->texthigh,
+			   -1, save_pst->text_high (),
 			   dependency_list, dependencies_used,
 			   textlow_not_set);
       includes_used = 0;
@@ -3710,15 +3712,15 @@  parse_partial_symbols (minimal_symbol_reader &reader,
          other cases.  */
       save_pst = fdr_to_pst[f_idx].pst;
       if (save_pst != NULL
-	  && save_pst->textlow != 0
+	  && save_pst->text_low () != 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)
+		&& save_pst->text_low () >= pst->text_low ()
+		&& save_pst->text_low () < pst->text_high ()
+		&& save_pst->text_high () > pst->text_high ())
 	      {
 		objfile->flags |= OBJF_REORDERED;
 		break;
@@ -3921,7 +3923,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)
+      && pst->text_low () == 0 && pst->text_high () == 0)
     return;
 
   /* Now read the symbols for this symtab.  */
@@ -4070,7 +4072,7 @@  psymtab_to_symtab_1 (struct objfile *objfile,
 
       if (! last_symtab_ended)
 	{
-	  cust = end_symtab (pst->texthigh, SECT_OFF_TEXT (objfile));
+	  cust = end_symtab (pst->text_high (), SECT_OFF_TEXT (objfile));
 	  end_stabs ();
 	}
 
@@ -4146,7 +4148,7 @@  psymtab_to_symtab_1 (struct objfile *objfile,
       top_stack->cur_st = COMPUNIT_FILETABS (cust);
       top_stack->cur_block
 	= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
-      BLOCK_START (top_stack->cur_block) = pst->textlow;
+      BLOCK_START (top_stack->cur_block) = pst->text_low ();
       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 ec2d9923c1b..c1f1defd58c 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -98,6 +98,31 @@  enum psymtab_search_status
 
 struct partial_symtab
 {
+  /* Return the low text address of this partial_symtab.  */
+  CORE_ADDR text_low () const
+  {
+    return m_textlow;
+  }
+
+  /* Return the high text address of this partial_symtab.  */
+  CORE_ADDR text_high () const
+  {
+    return m_texthigh;
+  }
+
+  /* Set the low text address of this partial_symtab.  */
+  void set_text_low (CORE_ADDR addr)
+  {
+    m_textlow = addr;
+  }
+
+  /* Set the hight text address of this partial_symtab.  */
+  void set_text_high (CORE_ADDR addr)
+  {
+    m_texthigh = addr;
+  }
+
+
   /* Chain of all existing partial symtabs.  */
 
   struct partial_symtab *next;
@@ -118,10 +143,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
+     accessors.  */
 
-  CORE_ADDR textlow;
-  CORE_ADDR texthigh;
+  CORE_ADDR m_textlow;
+  CORE_ADDR m_texthigh;
 
   /* If NULL, this is an ordinary partial symbol table.
 
@@ -222,6 +248,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))))
+
 /* Add any kind of symbol to a partial_symbol vector.  */
 
 extern void add_psymbol_to_list (const char *, int,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 58df3c69a78..44587fbf785 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -232,7 +232,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 = pst->text_low ();
 
   gdb_assert (!pst->psymtabs_addrmap_supported);
 
@@ -256,7 +256,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 >= tpst->text_low () && pc < tpst->text_high ())
 	{
 	  struct partial_symbol *p;
 	  CORE_ADDR this_addr;
@@ -277,7 +277,7 @@  find_pc_sect_psymtab_closer (struct objfile *objfile,
 	  if (p != NULL)
 	    this_addr = p->address (objfile);
 	  else
-	    this_addr = tpst->textlow;
+	    this_addr = tpst->text_low ();
 
 	  /* Check whether it is closer than our current
 	     BEST_ADDR.  Since this symbol address is
@@ -361,7 +361,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 >= pst->text_low () && pc < pst->text_high ())
       {
 	struct partial_symtab *best_pst;
 
@@ -415,7 +415,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->text_low () != 0)
+	     ? psymtab->text_low () - 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
@@ -428,7 +429,7 @@  find_pc_sect_psymbol (struct objfile *objfile,
 	  && p->aclass == LOC_BLOCK
 	  && pc >= p->address (objfile)
 	  && (p->address (objfile) > best_pc
-	      || (psymtab->textlow == 0
+	      || (psymtab->text_low () == 0
 		  && best_pc == 0 && p->address (objfile) == 0)))
 	{
 	  if (section != NULL)  /* Match on a specific section.  */
@@ -451,7 +452,7 @@  find_pc_sect_psymbol (struct objfile *objfile,
 	  && p->aclass == LOC_BLOCK
 	  && pc >= p->address (objfile)
 	  && (p->address (objfile) > best_pc
-	      || (psymtab->textlow == 0
+	      || (psymtab->text_low () == 0
 		  && best_pc == 0 && p->address (objfile) == 0)))
 	{
 	  if (section != NULL)  /* Match on a specific section.  */
@@ -806,8 +807,10 @@  psym_relocate (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));
+      p->set_text_low (p->text_low ()
+		       + ANOFFSET (delta, SECT_OFF_TEXT (objfile)));
+      p->set_text_high (p->text_high ()
+			+ ANOFFSET (delta, SECT_OFF_TEXT (objfile)));
     }
 
   for (partial_symbol *psym : objfile->global_psymbols)
@@ -1012,9 +1015,9 @@  dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
     }
 
   fprintf_filtered (outfile, "  Symbols cover text addresses ");
-  fputs_filtered (paddress (gdbarch, psymtab->textlow), outfile);
+  fputs_filtered (paddress (gdbarch, psymtab->text_low ()), outfile);
   fprintf_filtered (outfile, "-");
-  fputs_filtered (paddress (gdbarch, psymtab->texthigh), outfile);
+  fputs_filtered (paddress (gdbarch, psymtab->text_high ()), outfile);
   fprintf_filtered (outfile, "\n");
   fprintf_filtered (outfile, "  Address map supported - %s.\n",
 		    psymtab->psymtabs_addrmap_supported ? "yes" : "no");
@@ -1594,8 +1597,8 @@  start_psymtab_common (struct objfile *objfile,
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (filename, objfile);
-  psymtab->textlow = textlow;
-  psymtab->texthigh = psymtab->textlow;		/* default */
+  psymtab->set_text_low (textlow);
+  psymtab->set_text_high (psymtab->text_low ()); /* default */
   psymtab->globals_offset = global_psymbols.size ();
   psymtab->statics_offset = static_psymbols.size ();
   return psymtab;
@@ -2147,10 +2150,10 @@  maintenance_info_psymtabs (const 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->text_low ()),
 			      gdb_stdout);
 	      printf_filtered (" -- ");
-	      fputs_filtered (paddress (gdbarch, psymtab->texthigh),
+	      fputs_filtered (paddress (gdbarch, psymtab->text_high ()),
 			      gdb_stdout);
 	      printf_filtered ("\n");
 	      printf_filtered ("    psymtabs_addrmap_supported %s\n",
@@ -2230,14 +2233,14 @@  maintenance_check_psymtabs (const char *ignore, int from_tty)
     cust = ps->compunit_symtab;
 
     /* First do some checks that don't require the associated symtab.  */
-    if (ps->texthigh < ps->textlow)
+    if (ps->text_high () < ps->text_low ())
       {
 	printf_filtered ("Psymtab ");
 	puts_filtered (ps->filename);
 	printf_filtered (" covers bad range ");
-	fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, ps->text_low ()), gdb_stdout);
 	printf_filtered (" - ");
-	fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, ps->text_high ()), gdb_stdout);
 	printf_filtered ("\n");
 	continue;
       }
@@ -2282,15 +2285,16 @@  maintenance_check_psymtabs (const char *ignore, int from_tty)
 	  }
 	psym++;
       }
-    if (ps->texthigh != 0
-	&& (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)))
+    if (ps->text_high () != 0
+	&& (ps->text_low () < BLOCK_START (b)
+	    || ps->text_high () > 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, ps->text_low ()), gdb_stdout);
 	printf_filtered (" - ");
-	fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
+	fputs_filtered (paddress (gdbarch, ps->text_high ()), 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 7b9694bcff9..5e621e608d7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2095,8 +2095,6 @@  xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, 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.  */
@@ -2346,10 +2344,11 @@  scan_xcoff_symtab (minimal_symbol_reader &reader,
 			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 > pst->text_high ())
+			  pst->set_text_high (highval);
+			if (pst->text_low () == 0
+			    || symbol.n_value < pst->text_low ())
+			  pst->set_text_low (symbol.n_value);
 		      }
 		    misc_func_recorded = 0;
 		    break;