This is the mail archive of the
mailing list for the binutils project.
Re: Gold linker: specify alignment of sections
- From: Ian Lance Taylor <iant at google dot com>
- To: Martin Richtarsky <ml at martinien dot de>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 2 Aug 2013 06:46:34 -0700
- Subject: Re: Gold linker: specify alignment of sections
- References: <87db65a7811b691ba6a24ff862fb1efe-EhVcX1dJRwNeRwQRAQsKVxcwfgFLV15YQUBGAEFbWkA3VFEKQV51CUtUWF9BSCoDXF1cQlFUUA1c-webmailer2 at server05 dot webmailer dot hosteurope dot de>
On Wed, Jul 31, 2013 at 10:30 AM, Martin Richtarsky <email@example.com> wrote:
> E.g. include the script in rpath-link and also pass it as one of
> the object files. This is an implicit linker script as described here:
> Now, when linking in the same way using gold 2.23.1, the
> script is rejected with this error:
> " LinkerScript.ld: SECTIONS seen after other input files;
> try -T/--script"
> So gold wants me to specify a complete linker script, however I
> only want to change a couple attributes. Is this possible?
You won't get that error if you put your implicit linker script first.
However, I agree that its complex to specify a SECTIONS clause that
does not describe what to do with all sections. Does that really work
with GNU ld? As the docs say, an implicit linker script normally only
includes symbol assignments and INPUT commands and the like. I
suspect that your implicit linker script is overriding the default
SECTIONS clause, with results that may be hard to understand.
> - Passing the script with the -T option. This produces a broken
> executable that fails to start. As I understand this is because
> -T only accepts complete linker scripts, while the above is
> just an implicit linker script.
You didn't really say that the target is. If this is a GNU/Linux
system, then you probably don't need much to get it working.
> - So I have tried obtaining a complete linker script. "ld --verbose"
> will print the default linker script. I had to remove a couple
> of symbols that were not understood by gold, afterwards the executable
> produced with the "-T/path/to/LinkerScript.ld" option didn't work anymore.
That may be a bug in gold.
Since all you want to do is set the alignment of the output section,
and the alignment of an output section is determined by the maximum
alignment of all input sections, I suspect you can get the results you
want by including a little assembler file in your link, something like
Although I admit I'm not sure offhand whether you can set the
alignment of .plt this way. But then I'm pretty sure you can't set
the alignment of .plt with a linker script anyhow.