public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48568] New: Missing documentation for __attribute__((visibility ("protected"))) on variables.
@ 2011-04-12  8:57 nisse at lysator dot liu.se
  2011-04-12 10:37 ` [Bug c/48568] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: nisse at lysator dot liu.se @ 2011-04-12  8:57 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Missing documentation for __attribute__((visibility
                    ("protected"))) on variables.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nisse@lysator.liu.se


I discovered that __attribute__((visibility ("protected"))) is supported on
variables, not just on functions. This should be documented in the node
"Variable Attributes" in the GCC manual

This feature is useful in particular for accessing read-only tables (allocated
in the .rodata section) from PIC code. By default, access to such data in other
compilation units is done via the GOT table. Using the above attribute (and
assuming that the definition is linked into in the same shared library file),
the GOT lookup is omitted, and instead one gets a direct access via pc-relative
addressing. I was working on GNU/linux x86_64, where this corresponds to 

  .protected table
  lea table(%rip), %rax  # To get the address of the table

rather than the default

  mov table@GOTPCREL(%rip), %rax

in assembler input. I admit I don't fully understand the .protected pseudo op,
but it's appearantly essential for getting the linker to do the right thing
when linking the shared library (gcc -shared table-def.o table-use.o -o
lib.so).

Regards,
/Niels Möller


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

* [Bug c/48568] Missing documentation for __attribute__((visibility ("protected"))) on variables.
  2011-04-12  8:57 [Bug c/48568] New: Missing documentation for __attribute__((visibility ("protected"))) on variables nisse at lysator dot liu.se
@ 2011-04-12 10:37 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-12 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |documentation
           Severity|normal                      |enhancement


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

end of thread, other threads:[~2011-04-12 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-12  8:57 [Bug c/48568] New: Missing documentation for __attribute__((visibility ("protected"))) on variables nisse at lysator dot liu.se
2011-04-12 10:37 ` [Bug c/48568] " rguenth at gcc dot gnu.org

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).