+
+ if (is_error)
+ gold_error("%s: %s", objname, buf);
+ else
+ gold_warning("%s: %s", objname, buf);
+
+ delete[] buf;
+
+ if (to->source() == Symbol::FROM_OBJECT)
+ objname = to->object()->name().c_str();
+ else
+ objname = _("command line");
+ gold_info("%s: %s: previous definition here", program_name, objname);
+}
+
+// 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
+Symbol::clone(const Symbol* from)
+{
+ // Don't allow cloning after dynamic linking info is attached to symbols.
+ // We aren't prepared to merge such.
+ gold_assert(!this->has_symtab_index() && !from->has_symtab_index());
+ gold_assert(!this->has_dynsym_index() && !from->has_dynsym_index());
+ gold_assert(this->got_offset_list() == NULL
+ && from->got_offset_list() == NULL);
+ gold_assert(!this->has_plt_offset() && !from->has_plt_offset());
+
+ if (!from->version_)
+ this->version_ = from->version_;
+ this->u1_ = from->u1_;
+ this->u2_ = from->u2_;
+ this->type_ = from->type_;
+ this->binding_ = from->binding_;
+ this->visibility_ = from->visibility_;
+ this->nonvis_ = from->nonvis_;
+ this->source_ = from->source_;
+ this->is_def_ = from->is_def_;
+ this->is_forwarder_ = from->is_forwarder_;
+ this->has_alias_ = from->has_alias_;
+ this->needs_dynsym_entry_ = from->needs_dynsym_entry_;
+ this->in_reg_ = from->in_reg_;
+ this->in_dyn_ = from->in_dyn_;
+ this->needs_dynsym_value_ = from->needs_dynsym_value_;
+ this->has_warning_ = from->has_warning_;
+ this->is_copied_from_dynobj_ = from->is_copied_from_dynobj_;
+ this->is_ordinary_shndx_ = from->is_ordinary_shndx_;
+ this->in_real_elf_ = from->in_real_elf_;
+ this->is_defined_in_discarded_section_
+ = from->is_defined_in_discarded_section_;
+ this->undef_binding_set_ = from->undef_binding_set_;
+ this->undef_binding_weak_ = from->undef_binding_weak_;
+ this->is_predefined_ = from->is_predefined_;
+ this->is_protected_ = from->is_protected_;
+ this->non_zero_localentry_ = from->non_zero_localentry_;
+
+ return !this->is_forced_local_ && from->is_forced_local_;
+}
+
+template <int size>
+bool
+Sized_symbol<size>::clone(const Sized_symbol<size>* from)
+{
+ this->value_ = from->value_;
+ this->symsize_ = from->symsize_;
+ return Symbol::clone(from);
+}
+
+// A special case of should_override which is only called for a strong
+// defined symbol from a regular object file. This is used when
+// defining special symbols.
+
+bool
+Symbol_table::should_override_with_special(const Symbol* to,
+ elfcpp::STT fromtype,
+ Defined defined)
+{
+ bool adjust_common_sizes;
+ bool adjust_dyn_def;
+ unsigned int frombits = global_flag | regular_flag | def_flag;
+ bool ret = Symbol_table::should_override(to, frombits, fromtype, defined,
+ NULL, &adjust_common_sizes,
+ &adjust_dyn_def, false);
+ gold_assert(!adjust_common_sizes && !adjust_dyn_def);
+ return ret;
+}
+
+// Override symbol base with a special symbol.
+
+void
+Symbol::override_base_with_special(const Symbol* from)
+{
+ bool same_name = this->name_ == from->name_;
+ gold_assert(same_name || this->has_alias());
+
+ // If we are overriding an undef, remember the original binding.
+ if (this->is_undefined())
+ this->set_undef_binding(this->binding_);
+
+ this->source_ = from->source_;
+ switch (from->source_)
+ {
+ case FROM_OBJECT:
+ case IN_OUTPUT_DATA:
+ case IN_OUTPUT_SEGMENT:
+ this->u1_ = from->u1_;
+ this->u2_ = from->u2_;
+ break;
+ case IS_CONSTANT:
+ case IS_UNDEFINED:
+ break;
+ default:
+ gold_unreachable();
+ break;
+ }
+
+ if (same_name)
+ {
+ // When overriding a versioned symbol with a special symbol, we
+ // may be changing the version. This will happen if we see a
+ // special symbol such as "_end" defined in a shared object with
+ // one version (from a version script), but we want to define it
+ // here with a different version (from a different version
+ // script).
+ this->version_ = from->version_;
+ }
+ this->type_ = from->type_;
+ this->binding_ = from->binding_;
+ this->override_visibility(from->visibility_);
+ this->nonvis_ = from->nonvis_;
+
+ // Special symbols are always considered to be regular symbols.
+ this->in_reg_ = true;
+
+ if (from->needs_dynsym_entry_)
+ this->needs_dynsym_entry_ = true;
+ if (from->needs_dynsym_value_)
+ this->needs_dynsym_value_ = true;
+
+ this->is_predefined_ = from->is_predefined_;
+
+ // We shouldn't see these flags. If we do, we need to handle them
+ // somehow.
+ gold_assert(!from->is_forwarder_);
+ gold_assert(!from->has_plt_offset());
+ gold_assert(!from->has_warning_);
+ gold_assert(!from->is_copied_from_dynobj_);
+ gold_assert(!from->is_forced_local_);
+}
+
+// Override a symbol with a special symbol.
+
+template<int size>
+void
+Sized_symbol<size>::override_with_special(const Sized_symbol<size>* from)
+{
+ this->override_base_with_special(from);
+ this->value_ = from->value_;
+ this->symsize_ = from->symsize_;
+}
+
+// Override TOSYM with the special symbol FROMSYM. This handles all
+// aliases of TOSYM.
+
+template<int size>
+void
+Symbol_table::override_with_special(Sized_symbol<size>* tosym,
+ const Sized_symbol<size>* fromsym)
+{
+ tosym->override_with_special(fromsym);
+ if (tosym->has_alias())
+ {
+ Symbol* sym = this->weak_aliases_[tosym];
+ gold_assert(sym != NULL);
+ Sized_symbol<size>* ssym = this->get_sized_symbol<size>(sym);
+ do
+ {
+ ssym->override_with_special(fromsym);
+ sym = this->weak_aliases_[ssym];
+ gold_assert(sym != NULL);
+ ssym = this->get_sized_symbol<size>(sym);
+ }
+ while (ssym != tosym);
+ }
+ if (tosym->binding() == elfcpp::STB_LOCAL
+ || ((tosym->visibility() == elfcpp::STV_HIDDEN
+ || tosym->visibility() == elfcpp::STV_INTERNAL)
+ && (tosym->binding() == elfcpp::STB_GLOBAL
+ || tosym->binding() == elfcpp::STB_GNU_UNIQUE
+ || tosym->binding() == elfcpp::STB_WEAK)
+ && !parameters->options().relocatable()))
+ this->force_local(tosym);