From: Nick Clifton Date: Mon, 3 Jan 2000 18:34:24 +0000 (+0000) Subject: ELF visibility patch from Martin Loewis X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2e13b764859730a6bf359cd73b7e7acd4d95e071;p=binutils-gdb.git ELF visibility patch from Martin Loewis --- diff --git a/gas/ChangeLog b/gas/ChangeLog index e9ad534fca6..9e737058ca2 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2000-01-03 Martin v. Loewis + + * config/obj-elf.c (elf_pseudo_table): Define visibility pseudos. + (obj_elf_visibility): New function. + + * doc/as.texinfo (Visibility): New node: document visibility + pseudo ops. + 1999-12-27 Alan Modra * config/tc-i386.c (MATCH): Relax JumpAbsolute check. Emit a diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 29402eb6326..4fbd8bc6408 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -65,6 +65,7 @@ static void obj_elf_type PARAMS ((int)); static void obj_elf_ident PARAMS ((int)); static void obj_elf_weak PARAMS ((int)); static void obj_elf_local PARAMS ((int)); +static void obj_elf_visibility PARAMS ((int)); static void obj_elf_symver PARAMS ((int)); static void obj_elf_vtable_inherit PARAMS ((int)); static void obj_elf_vtable_entry PARAMS ((int)); @@ -89,6 +90,11 @@ static const pseudo_typeS elf_pseudo_table[] = {"version", obj_elf_version, 0}, {"weak", obj_elf_weak, 0}, + /* These define symbol visibility. */ + {"internal", obj_elf_visibility, STV_INTERNAL}, + {"hidden", obj_elf_visibility, STV_HIDDEN}, + {"protected", obj_elf_visibility, STV_PROTECTED}, + /* These are used for stabs-in-elf configurations. */ {"line", obj_elf_line, 0}, @@ -474,6 +480,48 @@ obj_elf_weak (ignore) demand_empty_rest_of_line (); } +static void +obj_elf_visibility (visibility) + int visibility; +{ + char *name; + int c; + symbolS *symbolP; + asymbol *bfdsym; + elf_symbol_type *elfsym; + + do + { + name = input_line_pointer; + c = get_symbol_end (); + symbolP = symbol_find_or_make (name); + *input_line_pointer = c; + + SKIP_WHITESPACE (); + + bfdsym = symbol_get_bfdsym (symbolP); + elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym); + + assert (elfsym); + + elfsym->internal_elf_sym.st_other = visibility; + + if (c == ',') + { + input_line_pointer ++; + + SKIP_WHITESPACE (); + + if (*input_line_pointer == '\n') + c = '\n'; + } + } + while (c == ','); + + demand_empty_rest_of_line (); +} + + static segT previous_section; static int previous_subsection; diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 330a8b23419..eb5aee84144 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -3195,6 +3195,9 @@ Some machine configurations provide additional directives. * Type:: @code{.type @var{int}} * Val:: @code{.val @var{addr}} @end ifset +@ifset ELF +* Visibility:: @code{.internal @var{name}, .hidden @var{name}, .protected @var{name}} +@end ifset * Uleb128:: @code{.uleb128 @var{expressions}} * Word:: @code{.word @var{expressions}} @@ -4756,6 +4759,40 @@ configured for @code{b.out}, it accepts this directive but ignores it. compact, variable length representation of numbers used by the DWARF symbolic debugging format. @xref{Sleb128,@code{.sleb128}}. +@ifset ELF +@node Visibility +@section @code{.internal}, @code{.hidden}, @code{.protected} +@cindex @code{internal} directive +@cindex @code{hidden} directive +@cindex @code{protected} directive +@cindex symbol visibility + +These directives can be used to set the visibility of a specified symbol. By +default a symbol's visibility is set by its binding (local, global or weak), +but these directives can be used to override that. + +A visibility of @code{protected} means that any references to the symbol from +within the component that defines the symbol must be resolved to the definition +in that component, even if a definition in another component would normally +preempt this. + +A visibility of @code{hidden} means that the symbol is not visible to other +components. Such a symbol is always considered to be protected as well. + +A visibility of @code{internal} is the same as a visibility of @code{hidden}, +except that some extra, processor specific processing must also be performed +upon the symbol. + +For ELF targets, the directives are used like this: + +@smallexample +.internal @var{name} +.hidden @var{name} +.protected @var{name} +@end smallexample + +@end ifset + @node Word @section @code{.word @var{expressions}}