This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Conditionals in Linker Scripts
- From: Nick Clifton <nickc at redhat dot com>
- To: Felix von Leitner <felix-binutils at fefe dot de>, Binutils Mailing List <binutils at sourceware dot org>
- Date: Tue, 11 Dec 2018 12:33:36 +0000
- Subject: Re: Conditionals in Linker Scripts
- References: <20181211115657.GA16903@qarx.de>
Hi Felix,
> but what about the startup code for ctor/dtor
> and static PIE? Is it possible to make a linker script that will only
> pull in the PIE startup code if the output format is "shared library"?
> Is it possible to only pull in the ctor/dtor code if there are ctors or
> dtors?
Yes. If you use different linker scripts for the different sceanarios then
you can arrange for each script to use INPUT() directives to include only the
necessary startup code.
Of course based upon the subject line of your email you would rather have
one linker script that the performs these operations conditionally. But
why is that ? If you are using gcc as your compiler driver then you can
use the spec file syntax to select different linker scripts based upon the
command line options used.
Cheers
Nick