Use unrelocated_addr in psymbols
authorTom Tromey <tom@tromey.com>
Sun, 19 Mar 2023 15:51:32 +0000 (09:51 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 28 Mar 2023 21:12:44 +0000 (15:12 -0600)
This changes psymbols themselves to use unrelocated_addr.  This
transform is largely mechanical.  I don't think it finds any bugs.

gdb/ctfread.c
gdb/dbxread.c
gdb/mdebugread.c
gdb/psympriv.h
gdb/psymtab.c
gdb/symtab.h
gdb/xcoffread.c

index 41411abef2b85acc579d3ea7126cc6c616ee6044..005862c109742fdc7c74817484213abf8405c138 100644 (file)
@@ -1291,7 +1291,8 @@ ctf_psymtab_add_enums (struct ctf_context *ccp, ctf_id_t tid)
       ccp->pst->add_psymbol (ename, true,
                             VAR_DOMAIN, LOC_CONST, -1,
                             psymbol_placement::GLOBAL,
-                            0, language_c, ccp->partial_symtabs, ccp->of);
+                            unrelocated_addr (0),
+                            language_c, ccp->partial_symtabs, ccp->of);
     }
   if (ctf_errno (ccp->fp) != ECTF_NEXT_END)
     complaint (_("ctf_enum_next ctf_psymtab_add_enums failed - %s"),
@@ -1336,7 +1337,8 @@ ctf_psymtab_add_stt_entries (ctf_dict_t *cfp, ctf_psymtab *pst,
       pst->add_psymbol (tname, true,
                        tdomain, aclass, -1,
                        psymbol_placement::GLOBAL,
-                       0, language_c, pst->context.partial_symtabs, of);
+                       unrelocated_addr (0),
+                       language_c, pst->context.partial_symtabs, of);
     }
 }
 
@@ -1513,7 +1515,8 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
   ccp->pst->add_psymbol (name, false,
                         domain, aclass, section,
                         psymbol_placement::STATIC,
-                        0, language_c, ccp->partial_symtabs, ccp->of);
+                        unrelocated_addr (0),
+                        language_c, ccp->partial_symtabs, ccp->of);
 
   return 0;
 }
@@ -1528,7 +1531,8 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg)
   ccp->pst->add_psymbol (name, true,
                         VAR_DOMAIN, LOC_STATIC, -1,
                         psymbol_placement::GLOBAL,
-                        0, language_c, ccp->partial_symtabs, ccp->of);
+                        unrelocated_addr (0),
+                        language_c, ccp->partial_symtabs, ccp->of);
   return 0;
 }
 
index 1ae527e9bf3fe6a5ce5879e746b0825332af4e1f..677e91d7725f970de34665109bafb68a008b57d9 100644 (file)
@@ -1484,7 +1484,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                                  VAR_DOMAIN, LOC_STATIC,
                                  data_sect_index,
                                  psymbol_placement::STATIC,
-                                 nlist.n_value, psymtab_language,
+                                 unrelocated_addr (nlist.n_value),
+                                 psymtab_language,
                                  partial_symtabs, objfile);
              else
                complaint (_("static `%*s' appears to be defined "
@@ -1500,7 +1501,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                                  VAR_DOMAIN, LOC_STATIC,
                                  data_sect_index,
                                  psymbol_placement::GLOBAL,
-                                 nlist.n_value, psymtab_language,
+                                 unrelocated_addr (nlist.n_value),
+                                 psymtab_language,
                                  partial_symtabs, objfile);
              else
                complaint (_("global `%*s' appears to be defined "
@@ -1523,7 +1525,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                    pst->add_psymbol (gdb::string_view (sym_name, sym_len),
                                      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
-                                     0, psymtab_language,
+                                     unrelocated_addr (0),
+                                     psymtab_language,
                                      partial_symtabs, objfile);
                  else
                    complaint (_("enum, struct, or union `%*s' appears "
@@ -1537,7 +1540,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                        pst->add_psymbol (gdb::string_view (sym_name, sym_len),
                                          true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                          psymbol_placement::STATIC,
-                                         0, psymtab_language,
+                                         unrelocated_addr (0),
+                                         psymtab_language,
                                          partial_symtabs, objfile);
                      else
                        complaint (_("typedef `%*s' appears to be defined "
@@ -1555,7 +1559,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                    pst->add_psymbol (gdb::string_view (sym_name, sym_len),
                                      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
-                                     0, psymtab_language,
+                                     unrelocated_addr (0),
+                                     psymtab_language,
                                      partial_symtabs, objfile);
                  else
                    complaint (_("typename `%*s' appears to be defined "
@@ -1621,7 +1626,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                      if (pst != nullptr)
                        pst->add_psymbol (gdb::string_view (p, q - p), true,
                                          VAR_DOMAIN, LOC_CONST, -1,
-                                         psymbol_placement::STATIC, 0,
+                                         psymbol_placement::STATIC,
+                                         unrelocated_addr (0),
                                          psymtab_language,
                                          partial_symtabs, objfile);
                      else
@@ -1645,7 +1651,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
              if (pst != nullptr)
                pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
                                  VAR_DOMAIN, LOC_CONST, -1,
-                                 psymbol_placement::STATIC, 0,
+                                 psymbol_placement::STATIC,
+                                 unrelocated_addr (0),
                                  psymtab_language,
                                  partial_symtabs, objfile);
              else
@@ -1705,7 +1712,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                                  VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
                                  psymbol_placement::STATIC,
-                                 nlist.n_value, psymtab_language,
+                                 unrelocated_addr (nlist.n_value),
+                                 psymtab_language,
                                  partial_symtabs, objfile);
              continue;
 
@@ -1762,7 +1770,8 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                                  VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
                                  psymbol_placement::GLOBAL,
-                                 nlist.n_value, psymtab_language,
+                                 unrelocated_addr (nlist.n_value),
+                                 psymtab_language,
                                  partial_symtabs, objfile);
              continue;
 
index 4bcda4b9d742ceaedda81022d9f04ce062a0be52..e041558764613584212f8b252a1f59301bed417b 100644 (file)
@@ -3056,7 +3056,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                          true, VAR_DOMAIN, LOC_STATIC,
                                          SECT_OFF_DATA (objfile),
                                          psymbol_placement::STATIC,
-                                         sh.value,
+                                         unrelocated_addr (sh.value),
                                          psymtab_language,
                                          partial_symtabs, objfile);
                        continue;
@@ -3069,7 +3069,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                          true, VAR_DOMAIN, LOC_STATIC,
                                          SECT_OFF_DATA (objfile),
                                          psymbol_placement::GLOBAL,
-                                         sh.value,
+                                         unrelocated_addr (sh.value),
                                          psymtab_language,
                                          partial_symtabs, objfile);
                        continue;
@@ -3088,7 +3088,9 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                            pst->add_psymbol
                              (gdb::string_view (namestring, p - namestring),
                               true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
-                              psymbol_placement::STATIC, 0, psymtab_language,
+                              psymbol_placement::STATIC,
+                              unrelocated_addr (0),
+                              psymtab_language,
                               partial_symtabs, objfile);
                            if (p[2] == 't')
                              {
@@ -3097,7 +3099,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                  (gdb::string_view (namestring,
                                                     p - namestring),
                                   true, VAR_DOMAIN, LOC_TYPEDEF, -1,
-                                  psymbol_placement::STATIC, 0,
+                                  psymbol_placement::STATIC,
+                                  unrelocated_addr (0),
                                   psymtab_language,
                                   partial_symtabs, objfile);
                                p += 1;
@@ -3112,7 +3115,9 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                              (gdb::string_view (namestring,
                                                 p - namestring),
                               true, VAR_DOMAIN, LOC_TYPEDEF, -1,
-                              psymbol_placement::STATIC, 0, psymtab_language,
+                              psymbol_placement::STATIC,
+                              unrelocated_addr (0),
+                              psymtab_language,
                               partial_symtabs, objfile);
                          }
                      check_enum:
@@ -3179,7 +3184,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                                  true, VAR_DOMAIN,
                                                  LOC_CONST, -1,
                                                  psymbol_placement::STATIC,
-                                                 0, psymtab_language,
+                                                 unrelocated_addr (0),
+                                                 psymtab_language,
                                                  partial_symtabs, objfile);
                                /* Point past the name.  */
                                p = q;
@@ -3198,7 +3204,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_CONST, -1,
                                          psymbol_placement::STATIC,
-                                         0, psymtab_language,
+                                         unrelocated_addr (0),
+                                         psymtab_language,
                                          partial_symtabs, objfile);
                        continue;
 
@@ -3214,7 +3221,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                          true, VAR_DOMAIN, LOC_BLOCK,
                                          SECT_OFF_TEXT (objfile),
                                          psymbol_placement::STATIC,
-                                         sh.value,
+                                         unrelocated_addr (sh.value),
                                          psymtab_language,
                                          partial_symtabs, objfile);
                        continue;
@@ -3235,7 +3242,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                          true, VAR_DOMAIN, LOC_BLOCK,
                                          SECT_OFF_TEXT (objfile),
                                          psymbol_placement::GLOBAL,
-                                         sh.value,
+                                         unrelocated_addr (sh.value),
                                          psymtab_language,
                                          partial_symtabs, objfile);
                        continue;
@@ -3475,14 +3482,16 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                      VAR_DOMAIN, LOC_BLOCK,
                                      section,
                                      psymbol_placement::GLOBAL,
-                                     sh.value, psymtab_language,
+                                     unrelocated_addr (sh.value),
+                                     psymtab_language,
                                      partial_symtabs, objfile);
                  else
                    pst->add_psymbol (sym_name, true,
                                      VAR_DOMAIN, LOC_BLOCK,
                                      section,
                                      psymbol_placement::STATIC,
-                                     sh.value, psymtab_language,
+                                     unrelocated_addr (sh.value),
+                                     psymtab_language,
                                      partial_symtabs, objfile);
 
                  procaddr = unrelocated_addr (sh.value);
@@ -3549,7 +3558,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                      pst->add_psymbol (sym_name, true,
                                        STRUCT_DOMAIN, LOC_TYPEDEF, -1,
                                        psymbol_placement::STATIC,
-                                       0, psymtab_language,
+                                       unrelocated_addr (0),
+                                       psymtab_language,
                                        partial_symtabs, objfile);
                    }
                  handle_psymbol_enumerators (objfile, partial_symtabs,
@@ -3591,7 +3601,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
              pst->add_psymbol (sym_name, true,
                                VAR_DOMAIN, theclass, section,
                                psymbol_placement::STATIC,
-                               sh.value, psymtab_language,
+                               unrelocated_addr (sh.value),
+                               psymtab_language,
                                partial_symtabs, objfile);
            skip:
              cur_sdx++;        /* Go to next file symbol.  */
@@ -3671,7 +3682,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                VAR_DOMAIN, theclass,
                                section,
                                psymbol_placement::GLOBAL,
-                               svalue, psymtab_language,
+                               unrelocated_addr (svalue),
+                               psymtab_language,
                                partial_symtabs, objfile);
            }
        }
@@ -3805,7 +3817,8 @@ handle_psymbol_enumerators (struct objfile *objfile,
         in psymtabs, just in symtabs.  */
       pst->add_psymbol (name, true,
                        VAR_DOMAIN, LOC_CONST, -1,
-                       psymbol_placement::STATIC, 0,
+                       psymbol_placement::STATIC,
+                       unrelocated_addr (0),
                        psymtab_language, partial_symtabs, objfile);
       ext_sym += external_sym_size;
     }
index 8fb595e2e0b182cc1944046e1e8ffc7ca49d9446..8f059dc5975ae8b9cb7c260b0e1e0d32bb03d848 100644 (file)
@@ -44,24 +44,24 @@ struct partial_symbol
   }
 
   /* Return the unrelocated address of this partial symbol.  */
-  CORE_ADDR unrelocated_address () const
+  unrelocated_addr unrelocated_address () const
   {
-    return ginfo.value_address ();
+    return ginfo.unrelocated_address ();
   }
 
   /* Return the address of this partial symbol, relocated according to
      the offsets provided in OBJFILE.  */
   CORE_ADDR address (const struct objfile *objfile) const
   {
-    return (ginfo.value_address ()
+    return (CORE_ADDR (ginfo.unrelocated_address ())
            + objfile->section_offsets[ginfo.section_index ()]);
   }
 
   /* Set the address of this partial symbol.  The address must be
      unrelocated.  */
-  void set_unrelocated_address (CORE_ADDR addr)
+  void set_unrelocated_address (unrelocated_addr addr)
   {
-    ginfo.set_value_address (addr);
+    ginfo.set_unrelocated_address (addr);
   }
 
   /* Note that partial_symbol does not derive from general_symbol_info
@@ -241,7 +241,7 @@ struct partial_symtab
                    enum address_class theclass,
                    short section,
                    psymbol_placement where,
-                   CORE_ADDR coreaddr,
+                   unrelocated_addr coreaddr,
                    enum language language,
                    psymtab_storage *partial_symtabs,
                    struct objfile *objfile);
index 484199b4be2636d0e34cf28775c76f99ff260de8..c74280761ddd0d6e3193775e893145bdef8652ea 100644 (file)
@@ -675,7 +675,8 @@ print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile,
          break;
        }
       gdb_puts (", ", outfile);
-      gdb_puts (paddress (gdbarch, p->unrelocated_address ()), outfile);
+      gdb_puts (paddress (gdbarch, CORE_ADDR (p->unrelocated_address ())),
+               outfile);
       gdb_printf (outfile, "\n");
     }
 }
@@ -1212,7 +1213,7 @@ partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
                             enum address_class theclass,
                             short section,
                             psymbol_placement where,
-                            CORE_ADDR coreaddr,
+                            unrelocated_addr coreaddr,
                             enum language language,
                             psymtab_storage *partial_symtabs,
                             struct objfile *objfile)
index 6834644ece108544b928ce518725fa9b97442d3c..d1ace398fe2dd8655fb4deca9d152064ebab6018 100644 (file)
@@ -530,6 +530,18 @@ struct general_symbol_info
     m_value.address = address;
   }
 
+  /* Return the unrelocated address of this symbol.  */
+  unrelocated_addr unrelocated_address () const
+  {
+    return m_value.unrel_addr;
+  }
+
+  /* Set the unrelocated address of this symbol.  */
+  void set_unrelocated_address (unrelocated_addr addr)
+  {
+    m_value.unrel_addr = addr;
+  }
+
   /* Name of the symbol.  This is a required field.  Storage for the
      name is allocated on the objfile_obstack for the associated
      objfile.  For languages like C++ that make a distinction between
@@ -554,6 +566,10 @@ struct general_symbol_info
 
     CORE_ADDR address;
 
+    /* The address, if unrelocated.  An unrelocated symbol does not
+       have the runtime section offset applied.  */
+    unrelocated_addr unrel_addr;
+
     /* A common block.  Used with LOC_COMMON_BLOCK.  */
 
     const struct common_block *common_block;
index ff46cd507761848dbe008badd23579c6a9225ba2..cbd427f870937c43ddbd1de6890ace4947dc06f8 100644 (file)
@@ -2499,7 +2499,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                  true, VAR_DOMAIN, LOC_STATIC,
                                  SECT_OFF_DATA (objfile),
                                  psymbol_placement::STATIC,
-                                 symbol.n_value,
+                                 unrelocated_addr (symbol.n_value),
                                  psymtab_language,
                                  partial_symtabs, objfile);
                continue;
@@ -2512,7 +2512,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                  true, VAR_DOMAIN, LOC_STATIC,
                                  SECT_OFF_DATA (objfile),
                                  psymbol_placement::GLOBAL,
-                                 symbol.n_value,
+                                 unrelocated_addr (symbol.n_value),
                                  psymtab_language,
                                  partial_symtabs, objfile);
                continue;
@@ -2532,7 +2532,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                                        p - namestring),
                                      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
-                                     0, psymtab_language,
+                                     unrelocated_addr (0),
+                                     psymtab_language,
                                      partial_symtabs, objfile);
                    if (p[2] == 't')
                      {
@@ -2541,7 +2542,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                          psymbol_placement::STATIC,
-                                         0, psymtab_language,
+                                         unrelocated_addr (0),
+                                         psymtab_language,
                                          partial_symtabs, objfile);
                        p += 1;
                      }
@@ -2555,7 +2557,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                                        p - namestring),
                                      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
-                                     0, psymtab_language,
+                                     unrelocated_addr (0),
+                                     psymtab_language,
                                      partial_symtabs, objfile);
                  }
              check_enum:
@@ -2618,7 +2621,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                        pst->add_psymbol (gdb::string_view (p, q - p), true,
                                          VAR_DOMAIN, LOC_CONST, -1,
                                          psymbol_placement::STATIC,
-                                         0, psymtab_language,
+                                         unrelocated_addr (0),
+                                         psymtab_language,
                                          partial_symtabs, objfile);
                        /* Point past the name.  */
                        p = q;
@@ -2638,7 +2642,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                                    p - namestring),
                                  true, VAR_DOMAIN, LOC_CONST, -1,
                                  psymbol_placement::STATIC,
-                                 0, psymtab_language,
+                                 unrelocated_addr (0),
+                                 psymtab_language,
                                  partial_symtabs, objfile);
                continue;
 
@@ -2653,7 +2658,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                  true, VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
                                  psymbol_placement::STATIC,
-                                 symbol.n_value,
+                                 unrelocated_addr (symbol.n_value),
                                  psymtab_language,
                                  partial_symtabs, objfile);
                continue;
@@ -2680,7 +2685,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                                  true, VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
                                  psymbol_placement::GLOBAL,
-                                 symbol.n_value,
+                                 unrelocated_addr (symbol.n_value),
                                  psymtab_language,
                                  partial_symtabs, objfile);
                continue;