[v2,03/31] Add bound_symbol

Message ID 20231105-split-objfile-2023-bound-sym-october-v2-3-dbd2d158bbc3@tromey.com
State New
Headers
Series Baby step for objfile splitting |

Commit Message

Tom Tromey Nov. 5, 2023, 6:11 p.m. UTC
  This adds a new bound_symbol type, analogous to bound_minimal_symbol.
That is, it carries a symbol and an objfile and will eventually be
used to relocate an address at point of use when computing a symbol's
value.
---
 gdb/symtab.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
  

Patch

diff --git a/gdb/symtab.h b/gdb/symtab.h
index 042f9dd4621..a518ed83622 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1522,6 +1522,27 @@  struct symbol : public general_symbol_info, public allocate_on_obstack
  CORE_ADDR get_maybe_copied_address () const;
 };
 
+/* A bound symbol is a symbol that is bound to a particular objfile.
+   (Currently all symbols are intrinsically bound, but as part of the
+   objfile-splitting project, eventually they will not have this
+   backlink.)  */
+struct bound_symbol
+{
+  /* The symbol.  Can be NULL.  */
+  struct symbol *symbol;
+
+  /* The objfile.  If SYMBOL is non-NULL, then this must be as well.  */
+  struct objfile *objfile;
+
+  /* Compute the address of the symbol.  */
+  CORE_ADDR address () const
+  { return symbol->value_address (); }
+
+  /* Convenience method to access symbol contents.  */
+  struct symbol *operator-> () const
+  { return symbol; }
+};
+
 /* See block-symbol.h.  */
 inline CORE_ADDR
 block_symbol::address () const