On 18/11/2012, at 7:50 AM, Alexander Ivchenko wrote: > You are right, we are talking about the same things. The only open > question I see is regarding: > >>>>> In other cases we can safely assume >>>>> that the executable will be created and >>>>> in such case it would be a good idea to use -fPIE. > >>> I don't see why it would be a good idea to use -fPIE for most normal >>> user-space applications when -fno-pic would >>> suffice and provide better code. > > Do you agree that if the driver knows that the executable will be at > the end of the build > we can safely use -fno-pic or -fPIE to override -fpic default?
If the driver can be sure that an executable is being compiled (which is a challenge in general case, but simple cases -- compilation of GCC testsuites -- can be accommodated) then it is OK to revert to default for a particular <arch>-linux-gnu target. For most architectures that would mean reverting to -fno-pic, but at least mips-linux-gnu uses -fpic by default in certain configurations. This is me not picking on your proposal, just alerting that -fno-pic may not be the right choice for executables for all targets. > I'm not > quite sure which one is better for Android; -fPIE will > give us all the security advantages of the position independent code > and probably is a better option. Using -fPIE will also bring all the performance drawbacks of PIC, there is a reason why -fPIE is not the most common way of building applications. I don't think Android is too security-concious a platform to warrant -fPIE (does Android even use address-space randomization?). Performance is a more serious consideration for its target market. Alexander, I appreciate you looking into -fpic vs -fno-pic compilation for Android. Thank you, -- Maxim Kuvyrkov CodeSourcery / Mentor Graphics