public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65888] New: Need a way to disable copy relocations
@ 2015-04-25 16:22 thiago at kde dot org
  0 siblings, 0 replies; only message in thread
From: thiago at kde dot org @ 2015-04-25 16:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65888

            Bug ID: 65888
           Summary: Need a way to disable copy relocations
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org

Qt would like to optimise libraries by resolving relocations that loop back
into the library in question at link-time, disallowing interposing. The
libraries remain position-independent by always resolving symbols via
PC-relative addressing or via R_xxx_RELATIVE relocations for what pointers need
to be stored in memory (such as virtual tables).

Do do that, we use -Bsymbolic or -Bsymbolic-functions. Either way, this is not
enough:

The problem happens when the symbols used from the libraries get used in the
main application. Due to copy relocation and position-dependent code
generation, those symbols "transfer" to the main application:
 * variables are copy-relocated
 * functions' entry points are now the PLT location in the application

Since the official address of certain variables or functions change, the
link-time resolving that happened inside the library is now different from what
the application and other libraries will resolve.

So far, using -fPIE has been enough to make the main executable not create copy
relocations on i386 and x86-64, with GCC 4.9 and earlier, Clang and ICC. GCC 5
breaks that.

Given the relative code size of the application vs the libraries (the libraries
are at least 10x larger and more complex), I argue that we're optimising for
the wrong thing by using copy relocations. It's a historic mistake that needs
fixing in the ABI.

Please provide a way for libraries to be allowed to use -Bsymbolic and
-fvisibility=protected by making applications never use copy relocations.
Applications should resolve symbols coming from libraries via indirect,
position-independent addressing. We are ok with tagging every symbol in
question with a new __attribute__ (they are already all tagged with
__attribute__((visibility("default")))).


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-25 16:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-25 16:22 [Bug c/65888] New: Need a way to disable copy relocations thiago at kde dot 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).