> 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)
I totally agree here that it could be a challenge. Also it could be quite confusing: if the user wants to get assembler code we must conservatively generate it with -fpic; However producing executable with default options and then objdumping it will give us different assembly with -fno-pic.. And although it could fix those testcases that are failing right now on android that would indeed be hiding our head in the sand. Considering all that, I believe that we are left with only one solution: to carefully add "-fno-pic" or "{ target nonpic }" to the affected tests as we discussed above. Thank you very much for your help! 2012/11/18 Maxim Kuvyrkov <ma...@codesourcery.com>: > 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 >