public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/56527] New: Provide an import counterpart to attribute((visibility("protected")))
@ 2013-03-04 20:18 luto at mit dot edu
  2013-03-05  0:37 ` [Bug c/56527] " luto at mit dot edu
  0 siblings, 1 reply; 2+ messages in thread
From: luto at mit dot edu @ 2013-03-04 20:18 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56527

             Bug #: 56527
           Summary: Provide an import counterpart to
                    attribute((visibility("protected")))
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: luto@mit.edu


This is a common idiom:

#ifdef BUILDING_LIBWHATEVER
#define LIBWHATEVER_API __attribute__((visibility("protected")))
#else
#define LIBWHATEVER_API ???
#endif

Protected can be replaced with default without changing anything.  The issue
is: what to specify for imports (the ??? above).

The common approach seems to be __attribute__((visibility("default"))), since
hidden is asking for trouble and protected won't link due to undefined
protected symbols.  Neither one is good.

I want an attribute (which could be a new visibility) that acts like default
visibility for undefined symbols, like default visibility [1] for inline
defined symbols, and fails to compile for non-inline symbols.  (In this
definition, "inline" should probably include implicitly instantiated templates
as well.)

This will catch errors when a non-inline function is defined in the right
place.

[1] This isn't quite ideal.  To avoid interposing a possible protected
instantiation of an inline function, these should probably end up as default
visibility but weak.


P.S.  It would be neat if calls to functions with this attribute generated
explicit GOT references rather than going to the PLT.  (IMO Windows gets this
right.)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/56527] Provide an import counterpart to attribute((visibility("protected")))
  2013-03-04 20:18 [Bug c/56527] New: Provide an import counterpart to attribute((visibility("protected"))) luto at mit dot edu
@ 2013-03-05  0:37 ` luto at mit dot edu
  0 siblings, 0 replies; 2+ messages in thread
From: luto at mit dot edu @ 2013-03-05  0:37 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56527

--- Comment #1 from Andy Lutomirski <luto at mit dot edu> 2013-03-05 00:37:20 UTC ---
In fact, without an improvement like this, protected visibility is unusable on
objects -- anything linking against a protected object will generate a copy
relocation.  The fact that the resulting binary is even loadable is IMO a bug
(whether in binutils for generating it or in glibc for loading it is
debatable.)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-05  0:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-04 20:18 [Bug c/56527] New: Provide an import counterpart to attribute((visibility("protected"))) luto at mit dot edu
2013-03-05  0:37 ` [Bug c/56527] " luto at mit dot edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).