Handle array- and string-like values in no-op pretty printers
[binutils-gdb.git] / gold / symtab.h
index 88d6c2782ba01c3b9c00a70c8c8b0f9fa374a6cd..4c580408c4db12079b36b434f70aa3256c88915c 100644 (file)
@@ -1,6 +1,6 @@
 // symtab.h -- the gold symbol table   -*- C++ -*-
 
-// Copyright (C) 2006-2017 Free Software Foundation, Inc.
+// Copyright (C) 2006-2023 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -329,6 +329,11 @@ class Symbol
   set_in_reg()
   { this->in_reg_ = true; }
 
+  // Forget this symbol was seen in a regular object.
+  void
+  clear_in_reg()
+  { this->in_reg_ = false; }
+
   // Return whether this symbol has been seen in a dynamic object.
   bool
   in_dyn() const
@@ -339,6 +344,11 @@ class Symbol
   set_in_dyn()
   { this->in_dyn_ = true; }
 
+  // Return whether this symbol is defined in a dynamic object.
+  bool
+  from_dyn() const
+  { return this->source_ == FROM_OBJECT && this->object()->is_dynamic(); }
+
   // Return whether this symbol has been seen in a real ELF object.
   // (IN_REG will return TRUE if the symbol has been seen in either
   // a real ELF object or an object claimed by a plugin.)
@@ -418,22 +428,23 @@ class Symbol
   // Return whether this symbol has an entry in the GOT section.
   // For a TLS symbol, this GOT entry will hold its tp-relative offset.
   bool
-  has_got_offset(unsigned int got_type) const
-  { return this->got_offsets_.get_offset(got_type) != -1U; }
+  has_got_offset(unsigned int got_type, uint64_t addend = 0) const
+  { return this->got_offsets_.get_offset(got_type, addend) != -1U; }
 
   // Return the offset into the GOT section of this symbol.
   unsigned int
-  got_offset(unsigned int got_type) const
+  got_offset(unsigned int got_type, uint64_t addend = 0) const
   {
-    unsigned int got_offset = this->got_offsets_.get_offset(got_type);
+    unsigned int got_offset = this->got_offsets_.get_offset(got_type, addend);
     gold_assert(got_offset != -1U);
     return got_offset;
   }
 
   // Set the GOT offset of this symbol.
   void
-  set_got_offset(unsigned int got_type, unsigned int got_offset)
-  { this->got_offsets_.set_offset(got_type, got_offset); }
+  set_got_offset(unsigned int got_type, unsigned int got_offset,
+                uint64_t addend = 0)
+  { this->got_offsets_.set_offset(got_type, got_offset, addend); }
 
   // Return the GOT offset list.
   const Got_offset_list*
@@ -893,11 +904,18 @@ class Symbol
   set_non_zero_localentry()
   { this->non_zero_localentry_ = true; }
 
+  // Completely override existing symbol.  Everything bar name_,
+  // version_, and is_forced_local_ flag are copied.  version_ is
+  // cleared if from->version_ is clear.  Returns true if this symbol
+  // should be forced local.
+  bool
+  clone(const Symbol* from);
+
  protected:
   // Instances of this class should always be created at a specific
   // size.
   Symbol()
-  { memset(this, 0, sizeof *this); }
+  { memset(static_cast<void*>(this), 0, sizeof *this); }
 
   // Initialize the general fields.
   void
@@ -1182,6 +1200,13 @@ class Sized_symbol : public Symbol
   void
   allocate_common(Output_data*, Value_type value);
 
+  // Completely override existing symbol.  Everything bar name_,
+  // version_, and is_forced_local_ flag are copied.  version_ is
+  // cleared if from->version_ is clear.  Returns true if this symbol
+  // should be forced local.
+  bool
+  clone(const Sized_symbol<size>* from);
+
  private:
   Sized_symbol(const Sized_symbol&);
   Sized_symbol& operator=(const Sized_symbol&);
@@ -1556,6 +1581,10 @@ class Symbol_table
   saw_undefined() const
   { return this->saw_undefined_; }
 
+  void
+  set_has_gnu_output()
+  { this->has_gnu_output_ = true; }
+
   // Allocate the common symbols
   void
   allocate_commons(Layout*, Mapfile*);
@@ -1687,6 +1716,15 @@ class Symbol_table
   version_script() const
   { return version_script_; }
 
+  // Completely override existing symbol.
+  template<int size>
+  void
+  clone(Sized_symbol<size>* to, const Sized_symbol<size>* from)
+  {
+    if (to->clone(from))
+      this->force_local(to);
+  }
+
  private:
   Symbol_table(const Symbol_table&);
   Symbol_table& operator=(const Symbol_table&);
@@ -1802,7 +1840,8 @@ class Symbol_table
   template<int size, bool big_endian>
   Sized_symbol<size>*
   define_special_symbol(const char** pname, const char** pversion,
-                       bool only_if_ref, Sized_symbol<size>** poldsym,
+                       bool only_if_ref, elfcpp::STV visibility,
+                       Sized_symbol<size>** poldsym,
                        bool* resolve_oldsym, bool is_forced_local);
 
   // Define a symbol in an Output_data, sized version.
@@ -1947,6 +1986,8 @@ class Symbol_table
   // The number of global dynamic symbols (including forced-local symbols),
   // or 0 if none.
   unsigned int dynamic_count_;
+  // Set if a STT_GNU_IFUNC or STB_GNU_UNIQUE symbol will be output.
+  bool has_gnu_output_;
   // The symbol hash table.
   Symbol_table_type table_;
   // A pool of symbol names.  This is used for all global symbols.