c++ - Gold linker: specify alignment of sections -


i want specify alignment sections. ld 2.20.0 following approach works:

  • create linker script containing sections should 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 script in rpath-link , pass 1 of object files.


now, when linking in same way using gold 2.23.1, script rejected error:

linkerscript.ld: sections seen after other input files; try -t/--script 

so gold wants me specify complete linker script, want change couple attributes. possible?

i have tried:

  • passing script -t option. produces broken executable fails start. understand because -t accepts complete linker scripts, while above "annotation" existing script.
  • in same vein, when passing script -t option ld 2.20.0 fails link since sections unspecified. not "complete" linker script use case.
  • so have tried obtaining complete linker script. ld --verbose print default linker script. had remove couple of symbols not understood gold, afterwards executable produced -t/path/to/linkerscript.ld option didn't work anymore.
  • unfortunately gold has no option show default linker script (it doesn't use any).
  • the man pages not specify how change alignment case above parameter.

any appreciated!

i've found solution solves problem.

  • alignment of data , text sections can achieved including assembler file dummy alignments. alignment of section maximum alignment sepcified anywhere, @ minimum have alignment.

    example file align.s (compile assembler , include object file in link):

     .section .text     .balign 0x40      .section .data     .balign 0x40      .end 
  • the gold linker aligns plt , got entries sizes (16 , 8 bytes, respectively). sufficient use case.

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -