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