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