autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [autoconf] Problems Configuring (C Compiler cannot produce executabl


From: Russ Allbery
Subject: Re: [autoconf] Problems Configuring (C Compiler cannot produce executables)
Date: Tue, 21 Aug 2012 21:44:44 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Jeffrey Walton <address@hidden> 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 (address@hidden)             <http://www.eyrie.org/~eagle/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]