Jeffrey Walton <noloader@xxxxxxxxx> writes: > According to Pinksi at GCC, -fPIC can be used for both. Both -fPIC and > -fPIE produce a relocatable section. I know from experience readelf(1) > produces the same result (DYN). > When using -fPIE, the optimizer can begin optomizing sooner. Andrew > Pinski (GCC developer): "With PIE, global variables and functions are > considered to bind local while with PIC they are considered to bind > globally (aka override able)." [1] > Pinski specifically recommended -fPIC because of this situation > (inability to configure executables and shared objects separately when > using the GNU tool chain). Well, all that's fine and good, but then you passed those flags into GCC and they didn't, er, work. :) So reality seems to have come into conflict with the advice you got. This definitely isn't Autoconf's fault, at least. I suspect the actual problem may be more the -Wl,-shared than the -fPIC, since ld -shared specifically means that you are *not* creating an executable, but rather are creating a shared library: -shared -Bshareable Create a shared library. This is currently only supported on ELF, XCOFF and SunOS platforms. On SunOS, the linker will automatically create a shared library if the -e option is not used and there are undefined symbols in the link. But you're passing it *only* to the linker (via -Wl), not to the compiler, so the compiler and the linker now disagree on whether the result is going to be a shared library or an executable, and badness happens. So, well, don't do that. :) I know for certain that the Debian set of hardening flags, which use -fPIE, not -fPIC, for executables, work across a *very large* array of open source software (although we do have to omit -fPIE from the default set since -fPIE breaks some software), and I believe that other distributions do the same. I won't venture to express an opinion on the relative merits of -fPIC versus -fPIE, particularly to compiler experts, but in my humble opinion you should prefer flags that actually function. -- Russ Allbery (rra@xxxxxxxxxxxx) <http://www.eyrie.org/~eagle/> _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf