RFC: syntax for a section ordering file

Nick Clifton nickc@redhat.com
Wed Apr 24 13:58:23 GMT 2024


Hi H.J.  Hi Fangrui,

   Is there a defined syntax for the contents of a section ordering file ?
   IE one passed to the linker via the --section-ordering= option ?

   I am attempting to take H.J.'s bfd linker text section ordering file
   patch and extend it to cover other sections.  In doing so, I need to
   be sure that I have the syntax right.

   To my mind if the section ordering file contains the following:

      # A comment
     .text.hot .text.cold,.text.warm
     .data.big
     .data.small
     .text.foo*

   Then this should be roughly equivalent to:

   SECTIONS
   {
     .text : {
       *(.text.hot)
       *(.text.cold)
       *(.text.warm)
       *(.text.foo*)
       *(.text)
       }
     .data : {
       *(.data.big)
       *(.data.small)
       *(.data)
       }
   }

   So all of the .text.<something> entries in the section ordering
   file are placed at the start of the output .text section (even
   if some of them occur after entries for other output sections)
   and all of the .data.<something> entries are placed at the start
   of the .data section.

   This will require co-operation from the linker script to have
   the "INCLUDE config.section-ordering-file" statements at the
   correct places, but I think that it could work.

   But obviously I want the option to be compatible with GOLD and
   LLD and I could not find any clear definitions or examples of
   the syntax used.

Cheers
   Nick



More information about the Binutils mailing list