This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR target/65248: [5 Regression] Copy relocation in PIE against protected symbol
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Uros Bizjak <ubizjak at gmail dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 4 Mar 2015 13:43:43 +1030
- Subject: Re: [PATCH] PR target/65248: [5 Regression] Copy relocation in PIE against protected symbol
- Authentication-results: sourceware.org; auth=none
- References: <20150228164223 dot GA22402 at gmail dot com> <CAFULd4Z67Vui4RHD3c07zhBu_1WZ5D2vok5zdw3jzUYCO=OsnA at mail dot gmail dot com> <CAMe9rOpU6E6bJeP_gtNP8_+B45ARxuYWpumz7sVqe-bCgyr8SA at mail dot gmail dot com> <20150303081235 dot GH4268 at bubble dot grove dot modra dot org> <CAMe9rOo9Dhzh0ZwCAmSiUeASpBGOFaeBQ065DAKfMYzu-jpSsQ at mail dot gmail dot com>
On Tue, Mar 03, 2015 at 06:20:05AM -0800, H.J. Lu wrote:
> For x86-64, protected data symbols are impossible.
Impossible? This is not even true currently since -fPIC emits code
that looks like it would fully support protected visibiliy variables
in shared libraries.
If you meant to say it is impossible with non-PIC, then even that
statement is going too far. All you'd need to do is have GNU ld emit
dynamic text relocations and possibly add some reloc support to ld.so,
and you'd have support so long as shared libraries loaded within 2G of
the executable. A little horrible, but quite possible.
With some more work, GNU ld could edit the current code sequences
emitted by gcc for non-PIC, to a branch to a patch area where you use
a PIC code sequence.
See also Cary's suggestion at
https://groups.google.com/forum/#!msg/generic-abi/9JX9vdstoVA/g4UGTmRdXJcJ
Or you could just acknowledge that non-PIC has limitations. Another
similar one (same root cause of no GOT indirection) is with weak
symbols, where
extern int foo () __attribute__ ((weak));
if (foo)
foo ();
just doesn't work for foo in a shared library. The non-PIC "if (foo)"
effectively becomes either "if (0)" or "if (1)" at link time, unless
you emit dynamic text relocations or edit the code.
--
Alan Modra
Australia Development Lab, IBM