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