From 837504c42dbf7cb67ee328fb0bdf594b70c90209 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 12 Jan 2010 19:12:40 +0000 Subject: * target-reloc.h (visibility_error): New inline function. (relocate_section): Call visibility_error. * testsuite/Makefile.am (check_DATA): Add protected_3.err. (MOSTLYCLEANFILES): Likewise. (protected_4_pic.o, protected_3.err): New targets. * testsuite/protected_4.cc: New file. --- gold/target-reloc.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'gold/target-reloc.h') 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); -- cgit v1.1