+// Return true if we are should issue an error saying that SYM is an
+// undefined symbol. This is called if there is a relocation against
+// SYM.
+
+inline bool
+issue_undefined_symbol_error(const Symbol* sym)
+{
+ // We only report global symbols.
+ if (sym == NULL)
+ return false;
+
+ // We only report undefined symbols.
+ if (!sym->is_undefined() && !sym->is_placeholder())
+ return false;
+
+ // We don't report weak symbols.
+ if (sym->is_weak_undefined())
+ return false;
+
+ // We don't report symbols defined in discarded sections,
+ // unless they're placeholder symbols that should have been
+ // provided by a plugin.
+ if (sym->is_defined_in_discarded_section() && !sym->is_placeholder())
+ return false;
+
+ // If the target defines this symbol, don't report it here.
+ if (parameters->target().is_defined_by_abi(sym))
+ return false;
+
+ // See if we've been told to ignore whether this symbol is
+ // undefined.
+ const char* const u = parameters->options().unresolved_symbols();
+ if (u != NULL)
+ {
+ if (strcmp(u, "ignore-all") == 0)
+ return false;
+ if (strcmp(u, "report-all") == 0)
+ return true;
+ if (strcmp(u, "ignore-in-object-files") == 0 && !sym->in_dyn())
+ return false;
+ if (strcmp(u, "ignore-in-shared-libs") == 0 && !sym->in_reg())
+ return false;
+ }
+
+ // If the symbol is hidden, report it.
+ if (sym->visibility() == elfcpp::STV_HIDDEN)
+ return true;
+
+ // When creating a shared library, only report unresolved symbols if
+ // -z defs was used.
+ if (parameters->options().shared() && !parameters->options().defs())
+ return false;
+
+ // Otherwise issue a warning.
+ return true;
+}
+
+template<int size, bool big_endian>
+inline void
+issue_discarded_error(
+ const Relocate_info<size, big_endian>* relinfo,
+ size_t shndx,
+ section_offset_type offset,
+ unsigned int r_sym,
+ const Symbol* gsym)
+{
+ Sized_relobj_file<size, big_endian>* object = relinfo->object;
+
+ if (gsym == NULL)
+ {
+ gold_error_at_location(
+ relinfo, shndx, offset,
+ _("relocation refers to local symbol \"%s\" [%u], "
+ "which is defined in a discarded section"),
+ object->get_symbol_name(r_sym), r_sym);
+ }
+ else
+ {
+ gold_error_at_location(
+ relinfo, shndx, offset,
+ _("relocation refers to global symbol \"%s\", "
+ "which is defined in a discarded section"),
+ gsym->demangled_name().c_str());
+ }
+
+ bool is_ordinary;
+ typename elfcpp::Elf_types<size>::Elf_Addr value;
+ unsigned int orig_shndx = object->symbol_section_and_value(r_sym, &value,
+ &is_ordinary);
+ if (orig_shndx != elfcpp::SHN_UNDEF)
+ {
+ unsigned int key_symndx;
+ Relobj* kept_obj = object->find_kept_section_object(orig_shndx,
+ &key_symndx);
+ if (key_symndx != 0)
+ gold_info(_(" section group signature: \"%s\""),
+ object->get_symbol_name(key_symndx));
+ if (kept_obj != NULL)
+ gold_info(_(" prevailing definition is from %s"),
+ kept_obj->name().c_str());
+ }
+}
+