aboutsummaryrefslogtreecommitdiff
path: root/gold/target-reloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'gold/target-reloc.h')
-rw-r--r--gold/target-reloc.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index 06597e2..4cb3315 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -144,6 +144,31 @@ get_comdat_behavior(const char* name)
return CB_WARNING;
}
+// Give an error for a symbol with non-default visibility which is not
+// defined locally.
+
+inline void
+visibility_error(const Symbol* sym)
+{
+ const char* v;
+ switch (sym->visibility())
+ {
+ case elfcpp::STV_INTERNAL:
+ v = _("internal");
+ break;
+ case elfcpp::STV_HIDDEN:
+ v = _("hidden");
+ break;
+ case elfcpp::STV_PROTECTED:
+ v = _("protected");
+ break;
+ default:
+ gold_unreachable();
+ }
+ gold_error(_("%s symbol '%s' is not defined locally"),
+ v, sym->name());
+}
+
// This function implements the generic part of relocation processing.
// The template parameter Relocate must be a class type which provides
// a single function, relocate(), which implements the machine
@@ -323,6 +348,10 @@ relocate_section(
&& (!parameters->options().shared() // -shared
|| parameters->options().defs())) // -z defs
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
+ else if (sym != NULL
+ && sym->visibility() != elfcpp::STV_DEFAULT
+ && (sym->is_undefined() || sym->is_from_dynobj()))
+ visibility_error(sym);
if (sym != NULL && sym->has_warning())
relinfo->symtab->issue_warning(sym, relinfo, i, offset);