This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gold linker: specify alignment of sections

On Wed, Jul 31, 2013 at 10:30 AM, Martin Richtarsky <> 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

    .balign 0x40
    .balign 0x40

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]