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