This is the mail archive of the binutils@sourceware.org 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]

Gold linker: specify alignment of sections


Hi,

I want to specify alignment for some sections. For ld 2.20.0
the following approach works:

- create a linker script containing only the sections that
  should be aligned, e.g.:

  SECTIONS
  {
      .data ALIGN(0x40): { *(.data) }

      .text ALIGN(0x40): { *(.text) }

      .plt ALIGN(0x10): { *(.plt) }
  }

then link with:

-rpath-link=/path/to/LinkerScript.ld /path/to/LinkerScript.ld

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:

http://sourceware.org/binutils/docs-2.23.1/ld/Implicit-Linker-Scripts.html#Implicit-Linker-Scripts


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?

I have already tried:

- 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.
- In the same vein, when passing the script with the -T option to
  ld 2.20.0 it fails to link since some sections are unspecified.
  It is not a "complete" linker script for my use case.
- 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.
- Unfortunately gold has no option to show its default linker script
  (it doesn't use any). The man pages do not specify how to change
  alignment for the case above with a parameter.

Any help would be greatly appreciated!

Best regards,
Martin Richtarsky


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