stateful handling of some ld flags
Alan Modra
amodra@gmail.com
Wed Jul 2 07:49:00 GMT 2014
On Sat, Jun 28, 2014 at 03:48:55PM -0400, Ulrich Drepper wrote:
> This patch is a possible solution for a problem that bugged me for a
> very long time. If you provide rules to link with a set of libraries
> (for instance, when using pkg-config) one cannot use --as-needed,
> --copy-dt-needed-entries, --whole-archive (and the respective inverse
> versions) because it is not known what the current state is. One cannot
> switch back.
>
> Other programs, for instance, gcc have similar problems. A solution is
> to use push/pop pairs.
>
> This patch implements this for this three sets of command line options.
> No need to do this for the linker script equivalent, it already does the
> right thing.
>
> I don't think it is possible to have a general push state/pop state
> pair, there are simply too many settings which can or cannot be assumed
> to be affected.
>
> What do you think?
I like the idea, but a general push/pop affecting input files is not
as hard as you think. Of the flags in input_flags, just four are
persistent control flags: dynamic, add_DT_NEEDED_for_dynamic,
add_DT_NEEDED_for_regular and whole_archive. The rest are controls
for a single file or status flags. One status flag, missing_file,
is persistent.
I'd rather see --push-control/--pop-control options that push/pop
input_flags to a stack, making missing_file sticky on a pop. That
would see the "dynamic" flag covered and any future extensions as
well. Fewer new options are better, and note that we currently allow
abbreviations like "--whole" for "--whole-archive". If you add
"--whole-archive-push" then this abbreviation will no longer be
accepted.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list