This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR target/65248: [5 Regression] Copy relocation in PIE against protected symbol


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]