+2019-03-21  Alan Modra  <amodra@gmail.com>
+
+       * scripttempl/alpha.sc, * scripttempl/armbpabi.sc,
+       * scripttempl/crisaout.sc, * scripttempl/elf32cr16.sc,
+       * scripttempl/elf32crx.sc, * scripttempl/elf32xc16x.sc,
+       * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc,
+       * scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc,
+       * scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc,
+       * scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc,
+       * scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc,
+       * scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc,
+       * scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc,
+       * scripttempl/ft32.sc, * scripttempl/i386beos.sc,
+       * scripttempl/iq2000.sc, * scripttempl/mcorepe.sc,
+       * scripttempl/mep.sc, * scripttempl/mips.sc, * scripttempl/moxie.sc,
+       * scripttempl/pe.sc, * scripttempl/pep.sc, * scripttempl/ppcpe.sc,
+       * scripttempl/tic4xcoff.sc, * scripttempl/tic80coff.sc,
+       * scripttempl/v850.sc, * scripttempl/v850_rh850.sc,
+       * scripttempl/visium.sc, * scripttempl/xstormy16.sc: Add KEEP and
+       SORT_NONE to .init and .fini wildcards.
+       * scripttempl/elf32xc16x.sc,
+       * scripttempl/elf32xc16xl.sc,
+       * scripttempl/elf32xc16xs.sc: Add .fini wildcard.
+       * scripttempl/elf_chaos.sc: Add .init output section.
+       * scripttempl/elfd30v.sc: Remove duplicate .init.
+       * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc,
+       * scripttempl/elfm9s12z.sc, * scripttempl/elfxgate.sc: Remove
+       duplicate .init, and add .fini wildcard.
+       * scripttempl/ppcpe.sc (INIT, FINI): Delete.
+       * ldlang.c (update_wild_statements): Special case .init and
+       .fini in the wildcard, not the output section.
+
 2019-03-21  Alan Modra  <amodra@gmail.com>
 
        * emulparams/elf32lm32fd.sh (DYNAMIC_LINK): Undef.
 
            case lang_wild_statement_enum:
              for (sec = s->wild_statement.section_list; sec != NULL;
                   sec = sec->next)
-               {
+               /* Don't sort .init/.fini sections.  */
+               if (strcmp (sec->spec.name, ".init") != 0
+                   && strcmp (sec->spec.name, ".fini") != 0)
                  switch (sec->spec.sorted)
                    {
                    case none:
                    default:
                      break;
                    }
-               }
              break;
 
            case lang_constructors_statement_enum:
              break;
 
            case lang_output_section_statement_enum:
-             /* Don't sort .init/.fini sections.  */
-             if (strcmp (s->output_section_statement.name, ".init") != 0
-                 && strcmp (s->output_section_statement.name, ".fini") != 0)
-               update_wild_statements
-                 (s->output_section_statement.children.head);
+             update_wild_statements
+               (s->output_section_statement.children.head);
              break;
 
            case lang_group_statement_enum:
 
   .text : {
     ${RELOCATING+ _ftext = .;}
     ${RELOCATING+ __istart = .;}
-    ${RELOCATING+ *(.init)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
     ${RELOCATING+ LONG (0x6bfa8001)}
     ${RELOCATING+ eprol = .;}
     *(.text)
     ${RELOCATING+ __fstart = .;}
-    ${RELOCATING+ *(.fini)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+ LONG (0x6bfa8001)}
     ${RELOCATING+ _etext = .;}
   }
 
   .init         ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
   .text         ${RELOCATING-0} :
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
   /* The SymbianOS kernel requires that the PLT go at the end of the
 
     ${CONSTRUCTING+ PROVIDE (___do_global_ctors = .);}
     ${CONSTRUCTING+ SHORT (0xe1fc); /* push srp */}
     ${CONSTRUCTING+ SHORT (0xbe7e);}
-    ${CONSTRUCTING+ *(.init)}
+    ${CONSTRUCTING+ KEEP (*(SORT_NONE(.init)))}
     ${CONSTRUCTING+ SHORT (0x0d3e); /* jump [sp+] */}
     ${CONSTRUCTING+ PROVIDE (__init__end = .);}
     ${CONSTRUCTING+ PROVIDE (___init__end = .);}
     ${CONSTRUCTING+ PROVIDE (___do_global_dtors = .);}
     ${CONSTRUCTING+ SHORT (0xe1fc); /* push srp */}
     ${CONSTRUCTING+ SHORT (0xbe7e);}
-    ${CONSTRUCTING+ *(.fini)}
+    ${CONSTRUCTING+ KEEP (*(SORT_NONE(.fini)))}
     ${CONSTRUCTING+ SHORT (0x0d3e); /* jump [sp+] */}
     ${CONSTRUCTING+ PROVIDE (__fini__end = .);}
     ${CONSTRUCTING+  ___fini__end = .;}
 
   .init :
   {
     __INIT_START = .;
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     __INIT_END = .;
   }${RELOCATING+ > rom}
 
   .fini :
   {
     __FINI_START = .;
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     __FINI_END = .;
   }${RELOCATING+ > rom}
 
 
   .init :
   {
     __INIT_START = .;
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     __INIT_END = .;
   } > rom
 
   .fini :
   {
     __FINI_START = .;
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     __FINI_END = .;
   } > rom
 
 
 {
 .init :
        {
-         *(.init)
+         KEEP (*(SORT_NONE(.init)))
+         ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
        } ${RELOCATING+ >introm}
 
 .text :
 
        } ${RELOCATING+ > vectarea} */
 .init :
        {
-         *(.init)
+         KEEP (*(SORT_NONE(.init)))
+         ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
        } ${RELOCATING+ >introm}
 
 .text :
 
        } ${RELOCATING+ > vectarea} */
 .init :
        {
-         *(.init)
+         KEEP (*(SORT_NONE(.init)))
+         ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
        } ${RELOCATING+ >introm}
 
 .text :
 
   .init         ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
 
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
   ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
 
     *(.gnu.warning)
     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
   } =${NOP-0}
+  .init         ${RELOCATING-0} :
+  {
+    ${RELOCATING+${INIT_START}}
+    KEEP (*(SORT_NONE(.init)))
+    ${RELOCATING+${INIT_END}}
+  } =${NOP-0}
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
   ${RELOCATING+PROVIDE (__etext = .);}
 
   .init         ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
 
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
   ${RELOCATING+PROVIDE (__etext = .);}
 
   .init         ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } ${RELOCATING+ > ${TEXT_MEMORY}}  =${NOP-0}
 
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
 
     ${RELOCATING+PROVIDE (__etext = .);}
 
   .rel.plt             ${RELOCATING-0} : { *(.rel.plt) }
   .rela.plt            ${RELOCATING-0} : { *(.rela.plt) }
 
-  .init                        ${RELOCATING-0} : { *(.init) } =${NOP-0}
+  .init                        ${RELOCATING-0} : { KEEP (*(SORT_NONE(.init))) } =${NOP-0}
   ${DATA_PLT-${PLT}}
 
   /* Internal text space */
   {
     *(.text)
     ${RELOCATING+*(.gnu.linkonce.t*)
-    *(SORT_NONE(.init))
-    *(SORT_NONE(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     _etext = . ;}
   } ${RELOCATING+ > ${TEXT_MEMORY}}
 
 
 
   .init        ${RELOCATING-0} :
   {
-    *(.init)
+    KEEP (*(SORT_NONE(.init)))
   } ${RELOCATING+=${NOP-0}}
 
   ${RELOCATING-${INSTALL_RELOC}}
     /* Put startup code at beginning so that _start keeps same address.  */
     ${RELOCATING+${STARTUP_CODE}}
 
-    ${RELOCATING+*(.init)}
     *(.text)
     ${RELOCATING+*(.text.*)}
     /* .gnu.warning sections are handled specially by elf32.em.  */
     ${RELOCATING+*(.tramp)}
     ${RELOCATING+*(.tramp.*)}
 
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+${FINISH_CODE}}
 
     ${RELOCATING+_etext = .;}
 
 
   .init        ${RELOCATING-0} :
   {
-    *(.init)
+    KEEP (*(SORT_NONE(.init)))
   } ${RELOCATING+=${NOP-0}}
 
   ${RELOCATING-${INSTALL_RELOC}}
     /* Put startup code at beginning so that _start keeps same address.  */
     ${RELOCATING+${STARTUP_CODE}}
 
-    ${RELOCATING+*(.init)}
     *(.text)
     ${RELOCATING+*(.text.*)}
     /* .gnu.warning sections are handled specially by elf32.em.  */
     ${RELOCATING+*(.tramp)}
     ${RELOCATING+*(.tramp.*)}
 
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+${FINISH_CODE}}
 
     ${RELOCATING+_etext = .;}
 
 
   .init        ${RELOCATING-0} :
   {
-    *(.init)
+    KEEP (*(SORT_NONE(.init)))
   } ${RELOCATING+=${NOP-0}}
 
   ${RELOCATING-${INSTALL_RELOC}}
     /* Put startup code at beginning so that _start keeps same address.  */
     ${RELOCATING+${STARTUP_CODE}}
 
-    ${RELOCATING+*(.init)}
     *(.text)
     ${RELOCATING+*(.text.*)}
     /* .gnu.warning sections are handled specially by elf32.em.  */
     ${RELOCATING+*(.tramp)}
     ${RELOCATING+*(.tramp.*)}
 
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+${FINISH_CODE}}
 
     ${RELOCATING+_etext = .;}
 
   }
   ${RELOCATING+ _etext  =  .;}
 
-  .init : { KEEP (*(.init))    } =0
-  .fini : { KEEP (*(.fini))    } =0
+  .init : { KEEP (*(SORT_NONE(.init))) } =0
+  .fini : { KEEP (*(SORT_NONE(.fini))) } =0
 
   ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);}
   ${RELOCATING+PROVIDE (___CTOR_LIST__ = .);}
 
 
   .init        ${RELOCATING-0} :
   {
-    *(.init)
+    KEEP (*(SORT_NONE(.init)))
   } ${RELOCATING+=${NOP-0}}
 
   ${RELOCATING-${INSTALL_RELOC}}
     /* Put startup code at beginning so that _start keeps same address.  */
     ${RELOCATING+${STARTUP_CODE}}
 
-    ${RELOCATING+*(.init)}
     *(.text)
     ${RELOCATING+*(.text.*)}
     /* .gnu.warning sections are handled specially by elf32.em.  */
     ${RELOCATING+*(.tramp)}
     ${RELOCATING+*(.tramp.*)}
 
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+${FINISH_CODE}}
 
     ${RELOCATING+_etext = .;}
 
 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
 INIT_LIT=".init.literal 0 : { *(.init.literal) }"
-INIT=".init         0 : { *(.init)             }"
+INIT=".init         0 : { KEEP (*(SORT_NONE(.init))) }"
 FINI_LIT=".fini.literal 0 : { *(.fini.literal) }"
-FINI=".fini         0 : { *(.fini)             }"
+FINI=".fini         0 : { KEEP (*(SORT_NONE(.fini))) }"
 if test -z "${NO_SMALL_DATA}"; then
   SBSS=".sbss         ${RELOCATING-0} :
   {
 
   .init  ${RELOCATING-0}${RELOCATING+__init_start}  :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0}
 
   .fini ${RELOCATING-0}${RELOCATING+ADDR(.init)+SIZEOF(.init)} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0}
 
 
     *(.text${RELOCATING+*})
     ${RELOCATING+*(.strings)
     *(._pm*)
-    *(.init)
-    *(.fini)
+    KEEP (*(SORT_NONE(.init)))
+    KEEP (*(SORT_NONE(.fini)))
     _etext = .;
     . = ALIGN(4);}
   } ${RELOCATING+ > flash}
 
   .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
   {
     ${RELOCATING+ __text_start__ = . ;}
-    ${RELOCATING+ *(.init)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
     *(.text)
     ${R_TEXT}
     *(.glue_7t)
                        LONG (-1); *(.ctors); *(.ctor); LONG (0); }
     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
                        LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
-    ${RELOCATING+ *(.fini)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
     /* ??? Why is .gcc_exc here?  */
     ${RELOCATING+ *(.gcc_exc)}
     ${RELOCATING+ etext = .;}
 
   .init        ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
 
   .fini    ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
   ${RELOCATING+PROVIDE (__etext = .);}
 
 {
   .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
   {
-    ${RELOCATING+ *(.init)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
     *(.text)
     ${R_TEXT}
     ${RELOCATING+ *(.text.*)}
                        LONG (-1); *(.ctors); *(.ctor); LONG (0); }
     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
                        LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
-    ${RELOCATING+ *(.fini)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
     /* ??? Why is .gcc_exc here?  */
     ${RELOCATING+ *(.gcc_exc)}
     ${RELOCATING+ etext = .;}
 
   .init         ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } =${NOP-0}
 
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
   ${RELOCATING+PROVIDE (__etext = .);}
 
 {
   ${RELOCATING+. = ${TEXT_START_ADDR};}
   .text : {
-    ${RELOCATING+ _ftext = . };
-    *(.init)
-    ${RELOCATING+ eprol  =  .};
+    ${RELOCATING+_ftext = .;
+    KEEP (*(SORT_NONE(.init)))
+    eprol  =  .;}
     *(.text)
-    *(.fini)
-    ${RELOCATING+ etext  =  .};
-    ${RELOCATING+ _etext  =  .};
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))
+    etext  =  .;
+    _etext  =  .;}
   }
   ${RELOCATING+. = ${DATA_ADDR};}
   .rdata : {
 
   .text :
   {
     *(.text)
-      .init : { KEEP (*(.init)) } =0
-      .fini : { KEEP (*(.fini)) } =0
+    ${RELOCATING+KEEP (*(SORT_NONE(.init)))
+    KEEP (*(SORT_NONE(.fini)))
     *(.strings)
-    ${RELOCATING+ _etext = . ; }
+    _etext = . ; }
   } ${RELOCATING+ > ram}
   ${CONSTRUCTING+${TORS}}
   .data :
 
   ${RELOCATING+. = ALIGN(__section_alignment__);}
   .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
   {
-    ${RELOCATING+ KEEP(*(.init))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.init)))}
     *(.text)
     ${R_TEXT}
     ${RELOCATING+ *(.text.*)}
        KEEP(*(SORT_BY_NAME(.dtors.*)));
        LONG (0);
      }
-    ${RELOCATING+ KEEP (*(.fini))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     /* ??? Why is .gcc_exc here?  */
     ${RELOCATING+ *(.gcc_exc)}
     ${RELOCATING+PROVIDE (etext = .);}
 
   ${RELOCATING+. = ALIGN(__section_alignment__);}
   .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
   {
-    ${RELOCATING+ KEEP(*(.init))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.init)))}
     *(.text)
     ${R_TEXT}
     ${RELOCATING+ *(.text.*)}
        KEEP (*(SORT_BY_NAME(.dtors.*)));
        LONG (0); LONG (0);
      }
-    ${RELOCATING+ KEEP (*(.fini))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     /* ??? Why is .gcc_exc here?  */
     ${RELOCATING+ *(.gcc_exc)}
     ${RELOCATING+PROVIDE (etext = .);}
 
 # are permitted in any medium without royalty provided the copyright
 # notice and this notice are preserved.
 #
-# These are substituted in as variables in order to get '}' in a shell
-# conditional expansion.
-
-INIT='.init : { *(.init) }'
-FINI='.fini : { *(.fini) }'
 
 cat <<EOF
 /* Copyright (C) 2014-2019 Free Software Foundation, Inc.
   /* text - the usual meaning */
   .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
        {
-           ${RELOCATING+ *(.init);}
+           ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
            *(.text)
            ${RELOCATING+ *(.text.*)}
            *(.gcc_except_table)
                        LONG (-1); *(.ctors); *(.ctor); LONG (0); }
            ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
                        LONG (-1); *(.dtors); *(.dtor); LONG (0); }
-           ${RELOCATING+ *(.fini);}
+           ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
            ${RELOCATING+ etext = .};
        }
 
 
   /* Program code.  */
   .text : {
     ${RELOCATING+  __text =  .;}
-    ${RELOCATING+ *(.init)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
     *(.text)
     ${CONSTRUCTING+ ___CTOR_LIST__ = .;}
     ${CONSTRUCTING+ LONG(___CTOR_END__ - ___CTOR_LIST__ - 2)}
     ${CONSTRUCTING+ *(.dtors)}
     ${CONSTRUCTING+ LONG(0)}
     ${CONSTRUCTING+ ___DTOR_END__  = .;}
-    ${RELOCATING+ *(.fini)}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+  __etext =  .;}
   } ${RELOCATING+ > ${TEXT_MEMORY}}
   /* Global initialised variables.  */
 
 SECTIONS
 {
   .text ${RELOCATING+ $TEXT_START_ADDR} : {
-    *(.init)
-    *(.fini)
+    ${RELOCATING+KEEP (*(SORT_NONE(.init)))
+    KEEP (*(SORT_NONE(.fini)))}
     *(.text)
   }
   .const ALIGN(4) : {
 
   .rela.bss    : { *(.rela.bss) }
   .rel.plt     : { *(.rel.plt) }
   .rela.plt    : { *(.rela.plt) }
-  .init                : { KEEP (*(.init)) } =0
+  .init                : { KEEP (*(SORT_NONE(.init))) } =0
   .plt         : { *(.plt) }
 
   .text                :
     *(.call_table_text)
   }
 
-  .fini                : { KEEP (*(.fini)) } =0
+  .fini                : { KEEP (*(SORT_NONE(.fini))) } =0
   .rodata      : { *(.rodata) ${RELOCATING+*(.rodata.*) *(.gnu.linkonce.r*)} }
   .rodata1     : { *(.rodata1) }
 
 
   .rela.bss    : { *(.rela.bss) }
   .rel.plt     : { *(.rel.plt) }
   .rela.plt    : { *(.rela.plt) }
-  .init                : { KEEP (*(.init)) } =0
+  .init                : { KEEP (*(SORT_NONE(.init))) } =0
   .plt         : { *(.plt) }
 
   .text                :
     *(.call_table_text)
   }
 
-  .fini                : { KEEP (*(.fini)) } =0
+  .fini                : { KEEP (*(SORT_NONE(.fini))) } =0
   .rodata      :
   {
        *(.rodata)
 
 SECTIONS
 {
   .init ${RELOCATING-0} : {
-    KEEP (*(.init))
-    ${RELOCATING+KEEP (*(.fini))}
+    KEEP (*(SORT_NONE(.init)))
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+ _einit  =  .;}
   } ${RELOCATING+ > init}
 
 
   .init        ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   }${RELOCATING+ > ROM =${NOP-0}}
   .fini    ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   }${RELOCATING+ > ROM =${NOP-0}}
   ${RELOCATING+PROVIDE (__etext = .);}