]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sun, 7 Feb 2021 21:15:12 +0000 (21:15 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 10 Feb 2021 14:38:08 +0000 (14:38 +0000)
Delete two more symbol/section related macros.  This time it's
SYMBOL_SECTION and MSYMBOL_SECTION.

As with general_symbol_info::m_name it is not currently possible to
make general_symbol_info::m_section private as general_symbol_info
must remain a POD type.

But other than failing to make the new m_section private, this change
does what you'd expect, adds a get and set member function and updates
all users to use the new functions instead of the previous wrapper
macros.

There should be no user visible change after this commit.

gdb/ChangeLog:

* coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index
and set_section_index member functions where appropriate.
* coffread.c (coff_symtab_read): Likewise.
(process_coff_symbol): Likewise.
* ctfread.c (set_symbol_address): Likewise.
* dwarf2/read.c (add_partial_symbol): Likewise.
(var_decode_location): Likewise.
* language.c: Likewise.
* minsyms.c (minimal_symbol_reader::record_full): Likewise.
(compact_minimal_symbols): Likewise.
(minimal_symbol_upper_bound): Likewise.
* objfiles.c (relocate_one_symbol): Likewise.
* psympriv.h (partial_symbol::obj_section): Likewise.
(partial_symbol::address): Likewise.
* psymtab.c (partial_symtab::add_psymbol): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* symmisc.c (dump_msymbols): Likewise.
* symtab.c (general_symbol_info::obj_section): Likewise.
(fixup_section): Likewise.
(get_msymbol_address): Likewise.
* symtab.h (general_symbol_info::section): Rename to...
(general_symbol_info::m_section): ...this.
(general_symbol_info::set_section_index): New member function.
(general_symbol_info::section_index): Likewise.
(SYMBOL_SECTION): Delete.
(MSYMBOL_VALUE_ADDRESS): Make use of section_index and
set_section_index member functions where appropriate.
(MSYMBOL_SECTION): Delete.
(symbol::symbol): Update to initialize 'm_section'.
* xcoffread.c (read_xcoff_symtab): Make use of set_section_index.
(process_xcoff_symbol): Likewise.

15 files changed:
gdb/ChangeLog
gdb/coff-pe-read.c
gdb/coffread.c
gdb/ctfread.c
gdb/dwarf2/read.c
gdb/language.c
gdb/minsyms.c
gdb/objfiles.c
gdb/psympriv.h
gdb/psymtab.c
gdb/stabsread.c
gdb/symmisc.c
gdb/symtab.c
gdb/symtab.h
gdb/xcoffread.c

index 67c99801c60aea0ddf79fe3a22e85f0b7e449e95..6de7954fe031f062f9ef32f2240c909e7ffd9fdf 100644 (file)
@@ -1,3 +1,37 @@
+2021-02-10  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index
+       and set_section_index member functions where appropriate.
+       * coffread.c (coff_symtab_read): Likewise.
+       (process_coff_symbol): Likewise.
+       * ctfread.c (set_symbol_address): Likewise.
+       * dwarf2/read.c (add_partial_symbol): Likewise.
+       (var_decode_location): Likewise.
+       * language.c: Likewise.
+       * minsyms.c (minimal_symbol_reader::record_full): Likewise.
+       (compact_minimal_symbols): Likewise.
+       (minimal_symbol_upper_bound): Likewise.
+       * objfiles.c (relocate_one_symbol): Likewise.
+       * psympriv.h (partial_symbol::obj_section): Likewise.
+       (partial_symbol::address): Likewise.
+       * psymtab.c (partial_symtab::add_psymbol): Likewise.
+       * stabsread.c (scan_file_globals): Likewise.
+       * symmisc.c (dump_msymbols): Likewise.
+       * symtab.c (general_symbol_info::obj_section): Likewise.
+       (fixup_section): Likewise.
+       (get_msymbol_address): Likewise.
+       * symtab.h (general_symbol_info::section): Rename to...
+       (general_symbol_info::m_section): ...this.
+       (general_symbol_info::set_section_index): New member function.
+       (general_symbol_info::section_index): Likewise.
+       (SYMBOL_SECTION): Delete.
+       (MSYMBOL_VALUE_ADDRESS): Make use of section_index and
+       set_section_index member functions where appropriate.
+       (MSYMBOL_SECTION): Delete.
+       (symbol::symbol): Update to initialize 'm_section'.
+       * xcoffread.c (read_xcoff_symtab): Make use of set_section_index.
+       (process_xcoff_symbol): Likewise.
+
 2021-02-10  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * breakpoint.c (resolve_sal_pc): Replace SYMBOL_OBJ_SECTION and
index 70eb7a04251094f62be19b558bb109cf75164f0e..90b406f140e6634a975105c65007e130899bc322 100644 (file)
@@ -246,7 +246,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
 
   vma = BMSYMBOL_VALUE_ADDRESS (msymbol);
   msymtype = MSYMBOL_TYPE (msymbol.minsym);
-  section = MSYMBOL_SECTION (msymbol.minsym);
+  section = msymbol.minsym->section_index ();
 
   /* Generate a (hopefully unique) qualified name using the first part
      of the dll name, e.g. KERNEL32!AddAtomA.  This matches the style
index 77752bc9111b02c35535d8a722cd1f7341646f1c..49a2485d38c228124788f32f0fe05cf26ff78a79 100644 (file)
@@ -1026,7 +1026,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
                sym = process_coff_symbol
                  (cs, &main_aux, objfile);
                SYMBOL_VALUE (sym) = tmpaddr + offset;
-               SYMBOL_SECTION (sym) = sec;
+               sym->set_section_index (sec);
              }
          }
          break;
@@ -1565,7 +1565,7 @@ process_coff_symbol (struct coff_symbol *cs,
   /* default assumptions */
   SYMBOL_VALUE (sym) = cs->c_value;
   SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-  SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
+  sym->set_section_index (cs_to_section (cs, objfile));
 
   if (ISFCN (cs->c_type))
     {
index 866977a43cde30ecdcced22e70785098651ba270..928cb3025c38222f260aabd4bd04dc677f1c02db 100644 (file)
@@ -297,7 +297,7 @@ set_symbol_address (struct objfile *of, struct symbol *sym, const char *name)
     {
       SET_SYMBOL_VALUE_ADDRESS (sym, BMSYMBOL_VALUE_ADDRESS (msym));
       SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
-      SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msym.minsym);
+      sym->set_section_index (msym.minsym->section_index ());
     }
 }
 
index 4b901c565f803eb00fdfeaa2a181bbb9be7ae74b..51bf0fbeea5a793b371d1de72862e4e61a26fed9 100644 (file)
@@ -8612,7 +8612,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
   partial_symbol psymbol;
   memset (&psymbol, 0, sizeof (psymbol));
   psymbol.ginfo.set_language (cu->language, &objfile->objfile_obstack);
-  psymbol.ginfo.section = -1;
+  psymbol.ginfo.set_section_index (-1);
 
   /* The code below indicates that the psymbol should be installed by
      setting this.  */
@@ -8641,7 +8641,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 
       psymbol.domain = VAR_DOMAIN;
       psymbol.aclass = LOC_BLOCK;
-      psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+      psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
       psymbol.ginfo.value.address = addr;
 
       if (pdi->main_subprogram && actual_name != NULL)
@@ -8686,7 +8686,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
            {
              psymbol.domain = VAR_DOMAIN;
              psymbol.aclass = LOC_STATIC;
-             psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+             psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
              psymbol.ginfo.value.address = addr;
              where = psymbol_placement::GLOBAL;
            }
@@ -8702,7 +8702,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 
          psymbol.domain = VAR_DOMAIN;
          psymbol.aclass = LOC_STATIC;
-         psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+         psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
          if (has_loc)
            psymbol.ginfo.value.address = addr;
          where = psymbol_placement::STATIC;
@@ -22100,7 +22100,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
          SET_SYMBOL_VALUE_ADDRESS
            (sym,
             SYMBOL_VALUE_ADDRESS (sym)
-            + objfile->section_offsets[SYMBOL_SECTION (sym)]);
+            + objfile->section_offsets[sym->section_index ()]);
          return;
        }
     }
index c23f29169aeb608ec25e3e7190eefb87894bf8ad..0eff76e12f4668e2a711ef5360e6e63828b680f2 100644 (file)
@@ -1052,7 +1052,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   symbol->set_language (lang, nullptr);
   symbol->owner.arch = gdbarch;
   SYMBOL_OBJFILE_OWNED (symbol) = 0;
-  SYMBOL_SECTION (symbol) = 0;
+  symbol->set_section_index (0);
   SYMBOL_TYPE (symbol) = type;
   SYMBOL_DOMAIN (symbol) = VAR_DOMAIN;
   SYMBOL_ACLASS_INDEX (symbol) = LOC_TYPEDEF;
index b861f939fdb6ded0827b605df776292ccf065390..8b8e11a83d0476196315dfbd2fb8df4ddf26c22b 100644 (file)
@@ -1157,7 +1157,7 @@ minimal_symbol_reader::record_full (gdb::string_view name,
     msymbol->m_name = name.data ();
 
   SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
-  MSYMBOL_SECTION (msymbol) = section;
+  msymbol->set_section_index (section);
 
   MSYMBOL_TYPE (msymbol) = ms_type;
 
@@ -1246,7 +1246,8 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
        {
          if (MSYMBOL_VALUE_RAW_ADDRESS (copyfrom)
              == MSYMBOL_VALUE_RAW_ADDRESS ((copyfrom + 1))
-             && MSYMBOL_SECTION (copyfrom) == MSYMBOL_SECTION (copyfrom + 1)
+             && (copyfrom->section_index ()
+                 == (copyfrom + 1)->section_index ())
              && strcmp (copyfrom->linkage_name (),
                         (copyfrom + 1)->linkage_name ()) == 0)
            {
@@ -1551,12 +1552,12 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
     = (minsym.objfile->per_bfd->msymbols.get ()
        + minsym.objfile->per_bfd->minimal_symbol_count);
   msymbol = minsym.minsym;
-  section = MSYMBOL_SECTION (msymbol);
+  section = msymbol->section_index ();
   for (iter = msymbol + 1; iter != past_the_end; ++iter)
     {
       if ((MSYMBOL_VALUE_RAW_ADDRESS (iter)
           != MSYMBOL_VALUE_RAW_ADDRESS (msymbol))
-         && MSYMBOL_SECTION (iter) == section)
+         && iter->section_index () == section)
        break;
     }
 
index 18dc8fabaf13ca8e07cde33046a712ca0c7625eb..2a513d82f1a034cce6a150a4f7ba846c3ce3a89a 100644 (file)
@@ -621,11 +621,11 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
      they can't possibly pass the tests below.  */
   if ((SYMBOL_CLASS (sym) == LOC_LABEL
        || SYMBOL_CLASS (sym) == LOC_STATIC)
-      && SYMBOL_SECTION (sym) >= 0)
+      && sym->section_index () >= 0)
     {
       SET_SYMBOL_VALUE_ADDRESS (sym,
                                SYMBOL_VALUE_ADDRESS (sym)
-                               + delta[SYMBOL_SECTION (sym)]);
+                               + delta[sym->section_index ()]);
     }
 }
 
index b5080e37370f7c548ea88909f826a18de29966c2..1f35ef2a44b9b1bcef30511665fe5c15c2f0d48a 100644 (file)
@@ -40,9 +40,7 @@ struct partial_symbol
      section has been set.  */
   struct obj_section *obj_section (struct objfile *objfile) const
   {
-    if (ginfo.section >= 0)
-      return &objfile->sections[ginfo.section];
-    return nullptr;
+    return ginfo.obj_section (objfile);
   }
 
   /* Return the unrelocated address of this partial symbol.  */
@@ -55,7 +53,8 @@ struct partial_symbol
      the offsets provided in OBJFILE.  */
   CORE_ADDR address (const struct objfile *objfile) const
   {
-    return ginfo.value.address + objfile->section_offsets[ginfo.section];
+    return (ginfo.value.address
+           + objfile->section_offsets[ginfo.section_index ()]);
   }
 
   /* Set the address of this partial symbol.  The address must be
index 58fd067905d7d27288a5d9758c4843e9627a19fa..7f41c010e391b8726e77c37dc358d22516496912 100644 (file)
@@ -1556,7 +1556,7 @@ partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
   memset (&psymbol, 0, sizeof (psymbol));
 
   psymbol.set_unrelocated_address (coreaddr);
-  psymbol.ginfo.section = section;
+  psymbol.ginfo.set_section_index (section);
   psymbol.domain = domain;
   psymbol.aclass = theclass;
   psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
index 33f200abf5972dd31f79d05aac73145fd9262c23..d83f4b40a6a2bbf75f950ef1aa1388821b5de416 100644 (file)
@@ -4590,7 +4590,7 @@ scan_file_globals (struct objfile *objfile)
                            (sym, MSYMBOL_VALUE_ADDRESS (resolve_objfile,
                                                         msymbol));
                        }
-                     SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msymbol);
+                     sym->set_section_index (msymbol->section_index ());
                    }
 
                  if (prev)
index ec4758c264e186531ffbb6c27e6e4d6ff7a21eeb..3703e50c6debdc53c6db2779d7362b0719d63bdc 100644 (file)
@@ -240,7 +240,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
       /* Use the relocated address as shown in the symbol here -- do
         not try to respect copy relocations.  */
       CORE_ADDR addr = (msymbol->value.address
-                       + objfile->section_offsets[msymbol->section]);
+                       + objfile->section_offsets[msymbol->section_index ()]);
       fputs_filtered (paddress (gdbarch, addr), outfile);
       fprintf_filtered (outfile, " %s", msymbol->linkage_name ());
       if (section)
index 9ad7c1f589d08aa82dcdbed6edfb219838d2cf97..3650b49832eb9457fb293fd6cdc6b9cadaaee667 100644 (file)
@@ -1015,8 +1015,8 @@ general_symbol_info::search_name () const
 struct obj_section *
 general_symbol_info::obj_section (const struct objfile *objfile) const
 {
-  if (section >= 0)
-    return &objfile->sections[section];
+  if (section_index () >= 0)
+    return &objfile->sections[section_index ()];
   return nullptr;
 }
 
@@ -1655,7 +1655,7 @@ fixup_section (struct general_symbol_info *ginfo,
   msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->linkage_name (),
                                           objfile);
   if (msym)
-    ginfo->section = MSYMBOL_SECTION (msym);
+    ginfo->set_section_index (msym->section_index ());
   else
     {
       /* Static, function-local variables do appear in the linker
@@ -1707,7 +1707,7 @@ fixup_section (struct general_symbol_info *ginfo,
          if (obj_section_addr (s) - offset <= addr
              && addr < obj_section_endaddr (s) - offset)
            {
-             ginfo->section = idx;
+             ginfo->set_section_index (idx);
              return;
            }
        }
@@ -1716,9 +1716,9 @@ fixup_section (struct general_symbol_info *ginfo,
         section.  If there is no allocated section, then it hardly
         matters what we pick, so just pick zero.  */
       if (fallback == -1)
-       ginfo->section = 0;
+       ginfo->set_section_index (0);
       else
-       ginfo->section = fallback;
+       ginfo->set_section_index (fallback);
     }
 }
 
@@ -6472,7 +6472,8 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
            return BMSYMBOL_VALUE_ADDRESS (found);
        }
     }
-  return minsym->value.address + objf->section_offsets[minsym->section];
+  return (minsym->value.address
+         + objf->section_offsets[minsym->section_index ()]);
 }
 
 \f
index e85ae684c71c249e6726327f793be2e1f3016b1d..efdbada976183944befe725525378111de8c6e87 100644 (file)
@@ -539,7 +539,21 @@ struct general_symbol_info
      section_offsets for this objfile.  Negative means that the symbol
      does not get relocated relative to a section.  */
 
-  short section;
+  short m_section;
+
+  /* Set the index into the obj_section list (within the containing
+     objfile) for the section that contains this symbol.  See M_SECTION
+     for more details.  */
+
+  void set_section_index (short idx)
+  { m_section = idx; }
+
+  /* Return the index into the obj_section list (within the containing
+     objfile) for the section that contains this symbol.  See M_SECTION
+     for more details.  */
+
+  short section_index () const
+  { return m_section; }
 
   /* Return the obj_section from OBJFILE for this symbol.  The symbol
      returned is based on the SECTION member variable, and can be nullptr
@@ -570,7 +584,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
 #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
 #define SYMBOL_BLOCK_VALUE(symbol)     (symbol)->value.block
 #define SYMBOL_VALUE_CHAIN(symbol)     (symbol)->value.chain
-#define SYMBOL_SECTION(symbol)         (symbol)->section
 
 /* Try to determine the demangled name for a symbol, based on the
    language of that symbol.  If the language is set to language_auto,
@@ -755,7 +768,7 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)                         \
   (((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol)    \
    : ((symbol)->value.address                                          \
-      + (objfile)->section_offsets[(symbol)->section]))
+      + (objfile)->section_offsets[(symbol)->section_index ()]))
 /* For a bound minsym, we can easily compute the address directly.  */
 #define BMSYMBOL_VALUE_ADDRESS(symbol) \
   MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
@@ -764,7 +777,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_VALUE_BYTES(symbol)    (symbol)->value.bytes
 #define MSYMBOL_BLOCK_VALUE(symbol)    (symbol)->value.block
 #define MSYMBOL_VALUE_CHAIN(symbol)    (symbol)->value.chain
-#define MSYMBOL_SECTION(symbol)                (symbol)->section
 
 #include "minsyms.h"
 
@@ -1118,7 +1130,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
       language_specific.obstack = nullptr;
       m_language = language_unknown;
       ada_mangled = 0;
-      section = -1;
+      m_section = -1;
       /* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
         initialization of unions, so we initialize it manually here.  */
       owner.symtab = nullptr;
index 8a2348c1df50407299e542acf74131ceaf9f09cd..cd93943a81262a9f326660298b31957aeaf1d02b 100644 (file)
@@ -1372,7 +1372,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
                (fcn_cs_saved.c_value + off,
                 fcn_stab_saved.c_name, 0, 0, objfile);
              if (newobj->name != NULL)
-               SYMBOL_SECTION (newobj->name) = SECT_OFF_TEXT (objfile);
+               newobj->name->set_section_index (SECT_OFF_TEXT (objfile));
            }
          else if (strcmp (cs->c_name, ".ef") == 0)
            {
@@ -1559,7 +1559,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
   /* default assumptions */
   SET_SYMBOL_VALUE_ADDRESS (sym, cs->c_value + off);
   SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-  SYMBOL_SECTION (sym) = secnum_to_section (cs->c_secnum, objfile);
+  sym->set_section_index (secnum_to_section (cs->c_secnum, objfile));
 
   if (ISFCN (cs->c_type))
     {
@@ -1625,7 +1625,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
            sym = define_symbol (cs->c_value + off, cs->c_name, 0, 0, objfile);
            if (sym != NULL)
              {
-               SYMBOL_SECTION (sym) = sec;
+               sym->set_section_index (sec);
              }
            return sym;
          }
@@ -1657,7 +1657,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
              SET_SYMBOL_VALUE_ADDRESS (sym,
                                        SYMBOL_VALUE_ADDRESS (sym)
                                        + static_block_base);
-             SYMBOL_SECTION (sym) = static_block_section;
+             sym->set_section_index (static_block_section);
            }
          return sym;