+// Issue an error or warning due to symbol resolution. IS_ERROR
+// indicates an error rather than a warning. MSG is the error
+// message; it is expected to have a %s for the symbol name. TO is
+// the existing symbol. DEFINED/OBJECT is where the new symbol was
+// found.
+
+// FIXME: We should have better location information here. When the
+// symbol is defined, we should be able to pull the location from the
+// debug info if there is any.
+
+void
+Symbol_table::report_resolve_problem(bool is_error, const char* msg,
+ const Symbol* to, Defined defined,
+ Object* object)
+{
+ std::string demangled(to->demangled_name());
+ size_t len = strlen(msg) + demangled.length() + 10;
+ char* buf = new char[len];
+ snprintf(buf, len, msg, demangled.c_str());
+
+ const char* objname;
+ switch (defined)
+ {
+ case OBJECT:
+ objname = object->name().c_str();
+ break;
+ case COPY:
+ objname = _("COPY reloc");
+ break;
+ case DEFSYM:
+ case UNDEFINED:
+ objname = _("command line");
+ break;
+ case SCRIPT:
+ objname = _("linker script");
+ break;
+ case PREDEFINED:
+ case INCREMENTAL_BASE:
+ objname = _("linker defined");
+ break;
+ default:
+ gold_unreachable();
+ }
+
+ 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);
+}
+