This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/35499] Symbol resolution optimization should be separately controlled from -fPIC
- From: "ddenisen at altera dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jun 2008 20:34:04 -0000
- Subject: [Bug c++/35499] Symbol resolution optimization should be separately controlled from -fPIC
- References: <bug-35499-15713@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from ddenisen at altera dot com 2008-06-27 20:34 -------
Here's the answer to my question (in case somebody else has the same problem):
You have to use -fPIC for compiling the executable itself (but not the shared
objects) to fix the symbol resolution problem described here. I was originally
omitting -fPIC for both SOs and EXE.
and here's some background info about -fPIC removal:
- Not using -fPIC only works on x86 architecture (but not even on x86_64)
because it allows code pages to be both writable and executable. Not using
-fPIC works because the linker creates text relocations
(http://people.redhat.com/drepper/textrelocs.html) all over code that dynamic
loader fixes up when SO/EXE is loaded.
- Having code pages writable and executable is a huge security thread, so don't
create text relocations if you care about security of your app.
- x86_64 arch allows RIP-related addressing, making position-independent code
virtually free. So don't worry about using PIC for 64-bit apps.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35499