On Tue, Mar 3, 2015 at 7:13 PM, Alan Modra <amo...@gmail.com> wrote: > 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. >
I withdrew my patch. I am working on a new approach for PIE and normal executable. -- H.J.