Home | History | Annotate | Download | only in ldscripts
      1 /* Script for -pie -z combreloc -z now -z relro: position independent executable, combine & sort relocs */
      2 OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips",
      3 	      "elf32-tradlittlemips")
      4 OUTPUT_ARCH(mips)
      5 ENTRY(__start)
      6 SECTIONS
      7 {
      8   /* Read-only sections, merged into text segment: */
      9   PROVIDE (__executable_start = 0); . = 0 + SIZEOF_HEADERS;
     10   .interp         : { *(.interp) }
     11   .reginfo        : { *(.reginfo) }
     12   .note.gnu.build-id : { *(.note.gnu.build-id) }
     13   .hash           : { *(.hash) }
     14   .gnu.hash       : { *(.gnu.hash) }
     15   .dynsym         : { *(.dynsym) }
     16   .dynstr         : { *(.dynstr) }
     17   .gnu.version    : { *(.gnu.version) }
     18   .gnu.version_d  : { *(.gnu.version_d) }
     19   .gnu.version_r  : { *(.gnu.version_r) }
     20   .rel.dyn        :
     21     {
     22       *(.rel.init)
     23       *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
     24       *(.rel.fini)
     25       *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
     26       *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
     27       *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
     28       *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
     29       *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
     30       *(.rel.ctors)
     31       *(.rel.dtors)
     32       *(.rel.got)
     33       *(.rel.dyn)
     34       *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
     35       *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
     36       *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
     37       *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
     38       *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
     39       PROVIDE_HIDDEN (__rel_iplt_start = .);
     40       *(.rel.iplt)
     41       PROVIDE_HIDDEN (__rel_iplt_end = .);
     42       PROVIDE_HIDDEN (__rela_iplt_start = .);
     43       PROVIDE_HIDDEN (__rela_iplt_end = .);
     44     }
     45   .rela.dyn       :
     46     {
     47       *(.rela.init)
     48       *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
     49       *(.rela.fini)
     50       *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
     51       *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
     52       *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
     53       *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
     54       *(.rela.ctors)
     55       *(.rela.dtors)
     56       *(.rela.got)
     57       *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
     58       *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
     59       *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
     60       *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
     61       *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
     62       PROVIDE_HIDDEN (__rel_iplt_start = .);
     63       PROVIDE_HIDDEN (__rel_iplt_end = .);
     64       PROVIDE_HIDDEN (__rela_iplt_start = .);
     65       *(.rela.iplt)
     66       PROVIDE_HIDDEN (__rela_iplt_end = .);
     67     }
     68   .rel.plt        :
     69     {
     70       *(.rel.plt)
     71     }
     72   .rela.plt       :
     73     {
     74       *(.rela.plt)
     75     }
     76   .init           :
     77   {
     78     KEEP (*(.init))
     79   } =0
     80   .plt            : { *(.plt) }
     81   .iplt           : { *(.iplt) }
     82   .text           :
     83   {
     84     _ftext = . ;
     85     *(.text.unlikely .text.*_unlikely)
     86     *(.text.exit .text.exit.*)
     87     *(.text.startup .text.startup.*)
     88     *(.text.hot .text.hot.*)
     89     *(.text .stub .text.* .gnu.linkonce.t.*)
     90     /* .gnu.warning sections are handled specially by elf32.em.  */
     91     *(.gnu.warning)
     92     *(.mips16.fn.*) *(.mips16.call.*)
     93   } =0
     94   .fini           :
     95   {
     96     KEEP (*(.fini))
     97   } =0
     98   PROVIDE (__etext = .);
     99   PROVIDE (_etext = .);
    100   PROVIDE (etext = .);
    101   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
    102   .rodata1        : { *(.rodata1) }
    103   .sdata2         :
    104   {
    105     *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
    106   }
    107   .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
    108   .eh_frame_hdr : { *(.eh_frame_hdr) }
    109   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
    110   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
    111   /* Adjust the address for the data segment.  We want to align at exactly
    112      a page boundary to make life easier for apriori. */
    113   . = ALIGN (CONSTANT (MAXPAGESIZE)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
    114   /* Exception handling  */
    115   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
    116   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
    117   /* Thread Local Storage sections  */
    118   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
    119   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
    120   /* Ensure the __preinit_array_start label is properly aligned.  We
    121      could instead move the label definition inside the section, but
    122      the linker would then create the section even if it turns out to
    123      be empty, which isn't pretty.  */
    124   . = ALIGN(32 / 8);
    125   PROVIDE_HIDDEN (__preinit_array_start = .);
    126   .preinit_array     :
    127   {
    128     KEEP (*(.preinit_array))
    129   }
    130   PROVIDE_HIDDEN (__preinit_array_end = .);
    131   PROVIDE_HIDDEN (__init_array_start = .);
    132   .init_array     :
    133   {
    134     KEEP (*crtbegin*.o(.init_array))
    135     KEEP (*(SORT(.init_array.*)))
    136     KEEP (*(.init_array))
    137   }
    138   PROVIDE_HIDDEN (__init_array_end = .);
    139   PROVIDE_HIDDEN (__fini_array_start = .);
    140   .fini_array     :
    141   {
    142     KEEP (*crtbegin*.o(.fini_array))
    143     KEEP (*(SORT(.fini_array.*)))
    144     KEEP (*(.fini_array))
    145   }
    146   PROVIDE_HIDDEN (__fini_array_end = .);
    147   .ctors          :
    148   {
    149     /* gcc uses crtbegin.o to find the start of
    150        the constructors, so we make sure it is
    151        first.  Because this is a wildcard, it
    152        doesn't matter if the user does not
    153        actually link against crtbegin.o; the
    154        linker won't look for a file to match a
    155        wildcard.  The wildcard also means that it
    156        doesn't matter which directory crtbegin.o
    157        is in.  */
    158     KEEP (*crtbegin.o(.ctors))
    159     KEEP (*crtbegin*.o(.ctors))
    160     /* We don't want to include the .ctor section from
    161        the crtend.o file until after the sorted ctors.
    162        The .ctor section from the crtend file contains the
    163        end of ctors marker and it must be last */
    164     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
    165     KEEP (*(SORT(.ctors.*)))
    166     KEEP (*(.ctors))
    167   }
    168   .dtors          :
    169   {
    170     KEEP (*crtbegin.o(.dtors))
    171     KEEP (*crtbegin*.o(.dtors))
    172     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
    173     KEEP (*(SORT(.dtors.*)))
    174     KEEP (*(.dtors))
    175   }
    176   .jcr            : { KEEP (*(.jcr)) }
    177   .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
    178   .got.plt        : { *(.got.plt) }
    179   .dynamic        : { *(.dynamic) }
    180   . = DATA_SEGMENT_RELRO_END (0, .);
    181   .data           :
    182   {
    183     _fdata = . ;
    184     *(.data .data.* .gnu.linkonce.d.*)
    185     SORT(CONSTRUCTORS)
    186   }
    187   .data1          : { *(.data1) }
    188   . = .;
    189   _gp = ALIGN(16) + 0x7ff0;
    190   .got            : { *(.got) }
    191   /* We want the small data sections together, so single-instruction offsets
    192      can access them all, and initialized data all before uninitialized, so
    193      we can shorten the on-disk segment size.  */
    194   .sdata          :
    195   {
    196     *(.sdata .sdata.* .gnu.linkonce.s.*)
    197   }
    198   .lit8           : { *(.lit8) }
    199   .lit4           : { *(.lit4) }
    200   _edata = .; PROVIDE (edata = .);
    201   __bss_start = .;
    202   _fbss = .;
    203   .sbss           :
    204   {
    205     *(.dynsbss)
    206     *(.sbss .sbss.* .gnu.linkonce.sb.*)
    207     *(.scommon)
    208   }
    209   .bss            :
    210   {
    211    *(.dynbss)
    212    *(.bss .bss.* .gnu.linkonce.b.*)
    213    *(COMMON)
    214    /* Align here to ensure that the .bss section occupies space up to
    215       _end.  Align after .bss to ensure correct alignment even if the
    216       .bss section disappears because there are no input sections.  */
    217    . = ALIGN(32 / 8);
    218   }
    219   . = ALIGN(32 / 8);
    220   . = ALIGN(32 / 8);
    221   _end = .;
    222   _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
    223   PROVIDE (end = .);
    224   . = DATA_SEGMENT_END (.);
    225   /* Stabs debugging sections.  */
    226   .stab          0 : { *(.stab) }
    227   .stabstr       0 : { *(.stabstr) }
    228   .stab.excl     0 : { *(.stab.excl) }
    229   .stab.exclstr  0 : { *(.stab.exclstr) }
    230   .stab.index    0 : { *(.stab.index) }
    231   .stab.indexstr 0 : { *(.stab.indexstr) }
    232   .comment       0 : { *(.comment) }
    233   /* DWARF debug sections.
    234      Symbols in the DWARF debugging sections are relative to the beginning
    235      of the section so we begin them at 0.  */
    236   /* DWARF 1 */
    237   .debug          0 : { *(.debug) }
    238   .line           0 : { *(.line) }
    239   /* GNU DWARF 1 extensions */
    240   .debug_srcinfo  0 : { *(.debug_srcinfo .zdebug_srcinfo) }
    241   .debug_sfnames  0 : { *(.debug_sfnames .zdebug_sfnames) }
    242   /* DWARF 1.1 and DWARF 2 */
    243   .debug_aranges  0 : { *(.debug_aranges .zdebug_aranges) }
    244   .debug_pubnames 0 : { *(.debug_pubnames .zdebug_pubnames) }
    245   /* DWARF 2 */
    246   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.* .zdebug_info) }
    247   .debug_abbrev   0 : { *(.debug_abbrev .zdebug_abbrev) }
    248   .debug_line     0 : { *(.debug_line .zdebug_line) }
    249   .debug_frame    0 : { *(.debug_frame .zdebug_frame) }
    250   .debug_str      0 : { *(.debug_str .zdebug_str) }
    251   .debug_loc      0 : { *(.debug_loc .zdebug_loc) }
    252   .debug_macinfo  0 : { *(.debug_macinfo .zdebug_macinfo) }
    253   /* SGI/MIPS DWARF 2 extensions */
    254   .debug_weaknames 0 : { *(.debug_weaknames .zdebug_weaknames) }
    255   .debug_funcnames 0 : { *(.debug_funcnames .zdebug_funcnames) }
    256   .debug_typenames 0 : { *(.debug_typenames .zdebug_typenames) }
    257   .debug_varnames  0 : { *(.debug_varnames .zdebug_varnames) }
    258   /* DWARF 3 */
    259   .debug_pubtypes 0 : { *(.debug_pubtypes .zdebug_pubtypes) }
    260   .debug_ranges   0 : { *(.debug_ranges .zdebug_ranges) }
    261   .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
    262   .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
    263   .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
    264   .gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) }
    265   .gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) }
    266   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
    267 }
    268