This is the mail archive of the
mailing list for the binutils project.
Re: PATCH: PR ld/16428: Disallow -shared/-pie, -shared/-static, -pie/-static
- From: Alan Modra <amodra at gmail dot com>
- To: Cary Coutant <ccoutant at google dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Tue, 14 Jan 2014 11:09:45 +1030
- Subject: Re: PATCH: PR ld/16428: Disallow -shared/-pie, -shared/-static, -pie/-static
- Authentication-results: sourceware.org; auth=none
- References: <20140110142001 dot GA6035 at intel dot com> <20140111001259 dot GE5390 at bubble dot grove dot modra dot org> <CAMe9rOo0UtpbdT69cnkK4fZD5pmzQnuX2wMCkBy3GuSLGcmcow at mail dot gmail dot com> <CAHACq4opdALo+T=dvM_PT2M36H+feAqpF6Gsf0sPZy-g=bg8SA at mail dot gmail dot com>
On Mon, Jan 13, 2014 at 02:25:50PM -0800, Cary Coutant wrote:
> >>> + bfd_boolean seen_pie = FALSE, seen_shared = FALSE, seen_static = FALSE;
> >> Do we really want to error on the mere presense of an option on the
> >> command line that is later cancelled by some other option? I think
> >> this is a bad idea.
> > That is what gold does.
> Are there "no" versions of these options? In gold, once any of these
> options is set, it can't be unset.
In effect, yes. -static has these synonyms:
and these antonyms:
What's more, these options in part imply -static:
-N / -omagic
-n / -nmagic
-r / --relocatable
I do not see the point in adding a boolean that singles out one or two
of these options for a warning, when the rest of the linker operates
according to the final state these options leave input_flags.dynamic.
Quite clearly if "-static -pie" is nonsense, then so is "-Bstatic -pie".
Also, I don't see why we should disallow something like
LD="ld -static" LDFLAGS="-pie -Bdynamic".
> (Nevertheless, if there were a way to unset any of them, gold only
> checks the final state of the options -- it wouldn't complain if you
> had, e.g., "--static --shared --nostatic". HJ's patch appears to do it
> this way as well; if there were a --nostatic, it should set
> seen_static to FALSE, and you wouldn't get an error.)
No, HJ's patch does not do it this way at all.
In fact on thinking about it some more, I reject not just HJ's
implementation but the whole idea behind the patch.
I see no reason why "-static -pie" should not work. "-static" does
*not* specify the type of output directly. "-static" chooses input
objects. "-pie" affects output. The two options are logically
orthogonal. You ought to be able to build a PIE that doesn't use any
shared libraries! If it doesn't work, then we have a bug elsewhere.
Australia Development Lab, IBM