From 9e8aab55f66575920351b391c688bf46c4fd7308 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sat, 2 Mar 2002 21:20:04 -0800 Subject: [PATCH] i386.h (ix86_expand_prologue): Do not emit pic register load if "internal" visibility. * config/i386/i386.h (ix86_expand_prologue): Do not emit pic register load if "internal" visibility. * doc/extend.texi: Document visibility meanings. From-SVN: r50240 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.c | 8 +++++++- gcc/doc/extend.texi | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e6504db49b..3f70e67d95e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-03-02 Richard Henderson + + * config/i386/i386.h (ix86_expand_prologue): Do not emit pic register + load if "internal" visibility. + * doc/extend.texi: Document visibility meanings. + 2002-03-02 Richard Henderson * config/i386/i386.h (ENCODE_SECTION_INFO): MODULE_LOCAL_P applies diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0a354d66677..11c128c3689 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4184,7 +4184,13 @@ ix86_expand_prologue () #endif if (pic_reg_used) - load_pic_register (); + { + tree vis = lookup_attribute ("visibility", DECL_ATTRIBUTES (cfun->decl)); + if (!vis + || strcmp ("internal", + TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (vis))))) + load_pic_register (); + } /* If we are profiling, make sure no instructions are scheduled before the call to mcount. However, if -fpic, the above call will have diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 96db4ad944e..59297d257a5 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2218,6 +2218,31 @@ f () @{ /* @r{Do something.} */; @} int i __attribute__ ((visibility ("hidden"))); @end smallexample +See the ELF gABI for complete details, but the short story is + +@table @dfn +@item hidden +Hidden visibility indicates that the symbol will not be placed into +the dynamic symbol table, so no other @dfn{module} (executable or +shared library) can reference it directly. + +@item protected +Protected visibility indicates that the symbol will be placed in the +dynamic symbol table, but that references within the defining module +will bind to the local symbol. That is, the symbol cannot be overridden +by another module. + +@item internal +Internal visibility is like hidden visibility, but with additional +processor specific semantics. Unless otherwise specified by the psABI, +gcc defines internal visibility to mean that the function is @emph{never} +called from another module. Note that hidden symbols, while then cannot +be referenced directly by other modules, can be referenced indirectly via +function pointers. By indicating that a symbol cannot be called from +outside the module, gcc may for instance omit the load of a PIC register +since it is known that the calling function loaded the correct value. +@end table + Not all ELF targets support this attribute. @item regparm (@var{number})