Home | History | Annotate | Download | only in ldscripts
      1 /* Script for ld --shared: link shared library */
      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("elf32-tradlittlemips", "elf32-tradbigmips",
      7 	      "elf32-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   .reginfo         : { *(.reginfo) }
     16   .note.gnu.build-id : { *(.note.gnu.build-id) }
     17   .hash           : { *(.hash) }
     18   .gnu.hash       : { *(.gnu.hash) }
     19   .dynsym         : { *(.dynsym) }
     20   .dynstr         : { *(.dynstr) }
     21   .gnu.version    : { *(.gnu.version) }
     22   .gnu.version_d  : { *(.gnu.version_d) }
     23   .gnu.version_r  : { *(.gnu.version_r) }
     24   .rel.init       : { *(.rel.init) }
     25   .rela.init      : { *(.rela.init) }
     26   .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
     27   .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
     28   .rel.fini       : { *(.rel.fini) }
     29   .rela.fini      : { *(.rela.fini) }
     30   .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
     31   .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
     32   .rel.data.rel.ro   : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
     33   .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
     34   .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
     35   .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
     36   .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
     37   .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
     38   .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
     39   .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
     40   .rel.ctors      : { *(.rel.ctors) }
     41   .rela.ctors     : { *(.rela.ctors) }
     42   .rel.dtors      : { *(.rel.dtors) }
     43   .rela.dtors     : { *(.rela.dtors) }
     44   .rel.got        : { *(.rel.got) }
     45   .rela.got       : { *(.rela.got) }
     46   .rel.dyn        : { *(.rel.dyn) }
     47   .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
     48   .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
     49   .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
     50   .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
     51   .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
     52   .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
     53   .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
     54   .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
     55   .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
     56   .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
     57   .rel.iplt       :
     58     {
     59       *(.rel.iplt)
     60     }
     61   .rela.iplt      :
     62     {
     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   .text           :
     78   {
     79     _ftext = . ;
     80     *(.text.unlikely .text.*_unlikely .text.unlikely.*)
     81     *(.text.exit .text.exit.*)
     82     *(.text.startup .text.startup.*)
     83     *(.text.hot .text.hot.*)
     84     *(.text .stub .text.* .gnu.linkonce.t.*)
     85     /* .gnu.warning sections are handled specially by elf32.em.  */
     86     *(.gnu.warning)
     87     *(.mips16.fn.*) *(.mips16.call.*)
     88   }
     89   .fini           :
     90   {
     91     KEEP (*(SORT_NONE(.fini)))
     92   }
     93   PROVIDE (__etext = .);
     94   PROVIDE (_etext = .);
     95   PROVIDE (etext = .);
     96   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
     97   .rodata1        : { *(.rodata1) }
     98   .eh_frame_hdr : { *(.eh_frame_hdr) }
     99   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
    100   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
    101   .gcc_except_table.*) }
    102   /* These sections are generated by the Sun/Oracle C++ compiler.  */
    103   .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
    104   .exception_ranges*) }
    105   .plt            : { *(.plt) }
    106   .iplt           : { *(.iplt) }
    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)); . = 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(32 / 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   .dynamic        : { *(.dynamic) }
    170   . = DATA_SEGMENT_RELRO_END (0, .);
    171   .got.plt        : { *(.got.plt) }
    172   .data           :
    173   {
    174     _fdata = . ;
    175     *(.data .data.* .gnu.linkonce.d.*)
    176     SORT(CONSTRUCTORS)
    177   }
    178   .data1          : { *(.data1) }
    179   . = .;
    180   HIDDEN (_gp = ALIGN (16) + 0x7ff0);
    181   .got            : { *(.got) }
    182   /* We want the small data sections together, so single-instruction offsets
    183      can access them all, and initialized data all before uninitialized, so
    184      we can shorten the on-disk segment size.  */
    185   .sdata          :
    186   {
    187     *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
    188     *(.sdata .sdata.* .gnu.linkonce.s.*)
    189   }
    190   .lit8           : { *(.lit8) }
    191   .lit4           : { *(.lit4) }
    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(32 / 8);
    211   }
    212   . = ALIGN(32 / 8);
    213   . = SEGMENT_START("ldata-segment", .);
    214   . = ALIGN(32 / 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   .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) }
    261   .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) }
    262   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
    263 }
    264